How can I make a robot joints and links reset completely in gazebo from python?

asked 2015-05-01 22:28:47 -0500

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:

  1. Spawn the hexapod model in Gazebo
    1. Generate a population of randomly generated gaits (lists of joint states) to send to the hexapod
    2. Pick a gait from the population and send each set of joint states in sequence to the respective topics in the hexapod
    3. Measure how much the hexapod advances for the given gait
    4. Use the gaits with the biggest advance achieved to build the next population
    5. 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 :)

edit retag flag offensive close merge delete

Comments

1

Did you find any solution to this? I'm having similar problems...

Xaser gravatar image Xaser  ( 2017-06-04 05:00:10 -0500 )edit

Did you find a way to solve this problem ?

nf gravatar image nf  ( 2018-05-14 00:18:31 -0500 )edit

Would like to ask as the previous comments, did you find a solution for this? :)

tropic gravatar image tropic  ( 2020-05-05 05:20:10 -0500 )edit