Teleporting robot via 'rosservice call /gazebo/set_model_state' produces weird behaviour
The problem appears with:
zero gravity worlds (<gravity>0 0 0</gravity>) OR models with gravity disabled (<enableGravity>false</enableGravity>)
- AND models that use
<attach> and <include>
to include additional models (for example a pioneer2dx with attached sonyvid30)
What to do to make it happen: teleport your robot into some location above the ground, for example run
rosservice call /gazebo/set_model_state '{model_state: { model_name: pioneer2dx_model1, pose: { position: { x: 0, y: 0, z: .6 }, orientation: {x: 0, y: 0, z: 0, w: 0 } }, twist: { linear: {x: 0 , y: 0 ,z: 0 } , angular: { x: 0 , y: 0 , z: 0 } } }}'
What I would expect to happen: The robot appears in the specified location, peacefully floating there.
What actually happens: The robot does indeed appear in the specified location. But it is usually rotating wildly, sometimes also drifting away from its position
A good example is the pioneer2dx_camera.world which I think lives somewhere in most Gazebo installations. Just change the <gravity>
specification to zero and try the rosservice call above.
The question is now: Is this a bug? Are there other workarounds known than to not use <attach> and <include>
on models?
Edit: I actually use the Diamondback Ubuntu packages. So maybe this isn't relevant for newer versions.
An example, from the pioneer2dx_camera.world file, which shows the behavior :
<model:physical name="pioneer2dx_model1">
<xyz>0 0 0.145</xyz>
<rpy>0.0 0.0 0.0</rpy>
<model:physical name="sonyvid30_model">
<xyz>0.15 0 0.09</xyz>
<attach>
<parentBody>chassis_body</parentBody>
<myBody>sonyvid30_body</myBody>
</attach>
<include embedded="true">
<xi:include href="../models/sonyvid30.model" />
</include>
</model:physical>
<include embedded="true">
<xi:include href="../models/pioneer2dx.model" />
</include>
</model:physical>
An example which does not show the behavior :
<model:physical name="pioneer2dx_model1">
<xyz>1 1 0.145</xyz>
<rpy>0.0 0.0 0.0</rpy>
<include embedded="true">
<xi:include href="../models/pioneer2dx.model" />
</include>
</model:physical>
Any other models, that do not use the <attach>...</attach> + <include>...</include>
tags are not affected, though I did not test all too many models. This is probably what you meant by "links".
Actually, when watching the "teleport operation" from a distance I can see what probably causes the spinning: The main body, for example the pioneer2dx_model1, appears at the new position instantly, but the attached body, for example the sonyvid30_model seems to remain at the old position for a very short time and then follows main body like it was attached with a rubber band or something the like. The ensuing impact then makes the robot spin and/or drift.