How can I make a robot joints and links reset completely in gazebo from python?
I want to make an experiment in gazebo using an evolutive learning algorithm to find walking gaits in an hexapod robot. For this, I've built an hexapod consisting in a body and six legs controlled by three revolute joints to emulate servo motors. The experiment will consist in the following stages:
- Spawn the hexapod model in Gazebo
- Generate a population of randomly generated gaits (lists of joint states) to send to the hexapod
- Pick a gait from the population and send each set of joint states in sequence to the respective topics in the hexapod
- Measure how much the hexapod advances for the given gait
- Use the gaits with the biggest advance achieved to build the next population
- Go back to step 2 until the algorithm reaches a limit of iterations and finds a gait that makes the hexapod walk properly
Do develop this, I am programming in python to send the moving commands. I generate a list of the walking patterns I want to test and then I iterate on that list to try the patterns. After that, I measure the advance in x making a service call to
/gazebo/get_model_state
And here comes the problem. To reset the model, I make a service call to
/gazebo/reset_simulation
(I have also tried /gazebo/reset_world)
and my robot model goes back to position <0,0,0> and rotation <0,0,0>. The problem is that after I make this service call, the joints states and the links are not reseted and this causes sometimes the model to go up fliying since the legs intersect with the floor model and the simulator processes this badly.
I wanted to ask if there is some way to make a call to gazebo to reset the model's pose including its joints states so the robot can go back exactly to the state it was spawned in for all of its joints and links.
By now, I'll reset joints positions by calling their respective topics before reseting the simulation, but I find this solution dirty and more time consuming than reseting the whole model with a single call (Time is important, since I have to make lots of iterations).
Thanks in advance to help me with my first question in the forum :)
Did you find any solution to this? I'm having similar problems...
Did you find a way to solve this problem ?
Would like to ask as the previous comments, did you find a solution for this? :)