WorldModel3DPluginBase
Declared in world-model-plugin-base.js
Extend this class to implement a custom plugin for the World Model 3D widget as outlined in the code snippet below. A working example - overlay displaying Battery messages as virtual LEDs on the robot - can be found in the Extras repository and also live in our demos.
Static Attributes
static SOURCE_DEFAULT_TOPIC |
String | Null |
Default topic to select or null (default) |
static SOURCE_DESCRIPTION |
String (required) |
Source description to show in the overlay selector |
static SOURCE_MAX_NUM |
Number |
The maximum number of topics this plugin can handle, -1=unlimited (default) |
static SOURCE_TOPIC_TYPE |
String (required) |
Source topic message type |
Instance Attributes
client |
Reference to Browser client |
|
overlays |
{ ‘topic’: custom_topic_data } |
Custom overlay data by topic |
panel |
Reference to widget panel |
|
ui |
Reference to the UI |
|
world_model |
WorldModel3DWidget |
Reference to World Model 3D widget |
Methods
constructor( WorldModel3DWidget world_model ) |
|
addTopic( String topic ) |
Add topic to this plugin, called when the user selects a new topic as overlay input |
clearAllTopics() |
Clear all topics. |
clearTopic( String topic ) |
Clear one topic and all its visuals |
clearVisuals( String topic ) |
Remove all visuals for the topic here |
onModelRemoved() |
Called when robot’s URDF model is removed of updated |
onTopicData( String topic, MsgType msg ) |
Called when data for the topic is received |
onRender() |
Called from the widget’s rendering loop |
onResize() |
Called on panel/window resize |
setupMenu( jQuery menu_els ) |
Setup menu items by adding new lines into the provided menu_els container |
Example
import { WorldModel3DPluginBase } from 'https://bridge.phntm.io/static/widgets/world-model-3d/world-model-plugin-base.js'
export class CustomWorldModel3DPlugin extends WorldModel3DPluginBase {
static SOURCE_TOPIC_TYPE = 'some_msgs/msg/TopicMsgType'; // set your message type
static SOURCE_DESCRIPTION = 'Source description'; // show in the overlay selection
static SOURCE_DEFAULT_TOPIC = null; // default topic id to select or null
static SOURCE_MAX_NUM = -1; // number of allowed topics, -1=unlimited
constructor(world_model) {
super(world_model);
}
addTopic(topic) {
super.addTopic(topic);
// handle topic add
}
setupMenu(menu_els) {
// add custom menu items to menu_els (jQuery List)
}
onTopicData(topic, msg) {
// process received topic data
}
onRender() {
// called from the widget's rendering loop
}
clearVisuals(topic) {
// clear all topic visuals
}
clearTopic(topic) {
// handle your own topic cleanup
super.clearTopic(topic);
}
}