You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on adding a new custom layer Planning Scene Extension for the 3D Panel that displays the items in a moveit Planning Scene. I've run into an issue.
For this to work, I need to be able to callService("/get_planning_scene") to get the entire planning scene, before relying on diffs from the topic "/planning_scene".
I've run into a problem in that SceneExtensions don't have access to the BuiltinPanelExtensionContext which includes the callService() function.
I'm thinking of adding the SceneExtensionContext into the SceneExtensionConfig so that when registering the new scene extension it can pass the context into the extension's constructor. I've put code here.
// SceneExtensionConfig.ts// Factory function to create SceneExtensionConfig with context injectionexportfunctioncreateSceneExtensionConfig(context?: Partial<BuiltinPanelExtensionContext>): SceneExtensionConfig{return{reserved: {},// Reserved extensions not shown hereextensionsById: {// Other extensions left out here[FoxgloveGrid.extensionId]: {// Usual registrationinit: (renderer: IRenderer)=>newFoxgloveGrid(renderer),},[PlanningScenes.extensionId]: {// New addition// Inject context (e.g., callService) into PlanningScenesinit: (renderer: IRenderer)=>newPlanningScenes(renderer,context?.callService),supportedInterfaceModes: ["3d"],},// Other extensions not shown here},};}
// ThreeDeeRender.tsxexportfunctionThreeDeeRender(props: Readonly<ThreeDeeRenderProps>): React.JSX.Element{const{ context, interfaceMode, testOptions, customSceneExtensions, customCameraModels }=props;const{
initialState,
saveState,unstable_fetchAsset: fetchAsset,
callService,// Extract callService from contextunstable_setMessagePathDropConfig: setMessagePathDropConfig,}=context;// Code in between not shownuseEffect(()=>{constnewRenderer=canvas
? newRenderer({
canvas,config: configRef.current,
interfaceMode,
fetchAsset,// Use the factory function to create scene extension config with contextsceneExtensionConfig: _.merge({},// DEFAULT_SCENE_EXTENSION_CONFIG, // It used to be thiscreateSceneExtensionConfig({ callService }),// Pass context subset with callService to the factorycustomSceneExtensions??{},),
displayTemporaryError,
testOptions,
customCameraModels,})
: undefined;setRenderer(newRenderer);rendererRef.current=newRenderer;return()=>{rendererRef.current?.dispose();rendererRef.current=undefined;};},[canvas,configRef,config.scene.transforms?.enablePreloading,customSceneExtensions,customCameraModels,interfaceMode,fetchAsset,callService,// Include callService in dependenciestestOptions,displayTemporaryError,]);// Code after not shown}
I'd like some thoughts on if this is a good direction or a bad implementation (contamination).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently working on adding a new custom layer Planning Scene Extension for the 3D Panel that displays the items in a moveit Planning Scene. I've run into an issue.
For this to work, I need to be able to callService("/get_planning_scene") to get the entire planning scene, before relying on diffs from the topic "/planning_scene".
I've run into a problem in that SceneExtensions don't have access to the BuiltinPanelExtensionContext which includes the callService() function.
I'm thinking of adding the SceneExtensionContext into the SceneExtensionConfig so that when registering the new scene extension it can pass the context into the extension's constructor. I've put code here.
I'd like some thoughts on if this is a good direction or a bad implementation (contamination).
Beta Was this translation helpful? Give feedback.
All reactions