Hierarichal Controller Implementation in DART with multiple world

Firstly I want to thank you for the help and guidance for our querries. I wish to implement a hierarchical controller in DART. Firstly, I have a simplified model and then a complete model. For a simplified model, I want to send my center of mass to a complete model. I am using GLUT for visualization of my dynamics. I know how to create another world within the given world and add my simplified model to it( considering I am visualizing the complete model). However, I am not sure how to call timeStepping override function within it to get a future reference.

In addition, any help in answering the follow

a) Can we visualize two worlds by switching between the two?
b) How can we call the simplified world to give me reference reading (which means the time of simplified model world should be in the future), considering I have just one timeStepping override function representing the complete model?

Any help will be appreciated.

Thanks

The dart::gui::osg::Viewer class does have some support rendering multiple worlds at once using the function dart::gui::osg::Viewer::addWorldNode(~). However, I have to admit that I haven’t really tested it, so I don’t know how good the results will be.

You might have a better time launching two dart::gui::osg::Viewer instances, each on in their own thread. I haven’t tried that before, so I don’t know how well that would work.

You could also use some of the OSG features to bind the 1 and 2 keys to switch between the two worlds using dart::gui::osg::Viewer::addWorldNode(~) and dart::gui::osg::Viewer::removeWorldNode(~). You can find an example of how to read keystrokes using OSG in the operational_space_control example.

You won’t be able to just use the out-of-the-box behavior, because that’s designed to just step and render one world. You’ll need to do some custom update step where you either

  1. Alternate calling a timestep on the simplified world and the complete world on each timestep
  2. On every update cycle, call a timestep on both the simplified world and then the complete world
  3. Simulate each world in a different thread and use mutexes to synchronize them.

(3) is probably overkill for your situation. (2) is what I’d recommend.