Programmatically restart simulation with different object poses
I am trying to create a reinforcement learning like simulation, where after each trial (episode) the simulation is restarted and the object pose is sampled from some initial pose distribution. I have tried to change the object pose by calling the /gazebo/setmodelstate ROS service, but on the next simulation step, the pose changes back.
I have found a question that address the same issue that I have: http://answers.gazebosim.org/question/7113/linksetworldpose-not-behaving-as-expected/ but it does not work for me. I have a model with a link connected through a fixed joint and when I try to detach and re-attach the joint, it still does not work - the hand gets back to the previous state. I have tried both Model::SetLinkWorldPose() SetLinkWorldPose() and Model::SetLinkWorldPose() (for the base link), but it did not prevent the behavior.
What would be the best way to do this? I am using Gazebo 7 with ROS.
Asked by hamzamerzic on 2017-05-21 13:45:37 UTC
Answers
Have you tried Model::SetWorldPose()
(as opposed to SetLinkPose()
)? Seems like it would be more effective than setting the position of an individual link. I know that method has worked for me personally, but your situation is a little different.
Asked by JLiviero on 2017-06-27 14:26:09 UTC
Comments
I haven't tried your recommendation. I will try it and post here. The solution that I went with in the end is to delete the model and then spawn it again at a new pose.
Asked by hamzamerzic on 2017-07-03 04:04:16 UTC
Comments