gazebo-classic
gazebo-classic copied to clipboard
Reset model poses button behavior different in DART engine
I just noticed that the reset_model behaviour differs when using the ODE physics and DART Physics engines. The model position is reset in the ODE physics engine, where the model configuration is kept the same. In the DART simulation, both the model positions and configurations are reset.
How to reproduce
- Clone the example repository and branch into a catkin workspace.
- Install the ROS dependencies.
- Build the workspace.
- Run the stick example using the ODE physics engine
roslaunch gazebo_bug_reproduce stick.launch physics:=ode pause:=false. - Move the cube.
- Click the
Edit>>Reset Model Posesbutton. - See that only the model positions are reset.
- Run the stick example using the DART physics engine
roslaunch gazebo_bug_reproduce stick.launch physics:=dart pause:=false. - Click the
Edit>>Reset Model Posesbutton. - See that both the model positions and configurations are reset.
Investigation
ODE behaviour
See gif

DART behaviour
See gif

Inspect code
When using the Edit>>Reset Simulation button, I get the [Wrn] [DARTPhysics.cc:491] Not implemented yet in DART warning. This warning is thrown because the SetSeed method is not yet implemented for dart:
https://github.com/osrf/gazebo/blob/adb08340fe71488045dd79a6465db7d58e3ae06f/gazebo/physics/dart/DARTPhysics.cc#L489-L492
It looks like the Edit>>Reset Model Poses button in the DART physics engine executes similar logic to the Edit>>Reset Simulation button in the ODE physics engine. The logic that DART executes can be found here:
https://github.com/osrf/gazebo/blob/adb08340fe71488045dd79a6465db7d58e3ae06f/gazebo/physics/dart/DARTJoint.cc#L112-L120
This calls DART's setPosition method, which is virtual (see https://github.com/dartsim/dart/blob/df90cdaa042c8b8852ea60dc12b0875b0e00a066/dart/dynamics/Joint.hpp#L303). For our joints, this method is implemented in the dart physics engine as:
this->mAspectState.mPositions[index] = position;
Where the logic that is executed by ODE can be found here:
https://github.com/osrf/gazebo/blob/adb08340fe71488045dd79a6465db7d58e3ae06f/gazebo/physics/ode/ODEJoint.cc#L627-L637
https://github.com/osrf/gazebo/blob/adb08340fe71488045dd79a6465db7d58e3ae06f/deps/opende/src/ode.cpp#L1219-L1223
https://github.com/osrf/gazebo/blob/adb08340fe71488045dd79a6465db7d58e3ae06f/gazebo/physics/Joint.cc#L507-L514
Conclusion
After a glance at the code, the most apparent difference is that the Gazebo Joint::Reset() method is called before DART is asked to reset the joint positions, whereas, for ODE, this is called method is called after ODE is requested to reset the joint positions. Based on the naming (i.e. Reset model poses), the DART implementation is incorrect. I agree with https://github.com/osrf/gazebo/issues/507#issuecomment-616040640 that a method should exist that resets both the model poses and configuration but does not reset the simulation time. Alternatively, we can use the DART behaviour and rename the button to Reset models. In that case, if users want to keep the previous configuration after the reset, they have to set it using the gazebo/set_model_configuration service.
Related issues
- https://github.com/osrf/gazebo/issues/507