Properly restarting the gazebo simulation for iterative learning

However, many of these solutions don't really answer the question. reset_world seems to break all of the controllers. Just calling it with the pr2 model leads to a flow of red errors.

What I'm using now is the SetModelConfiguration service call. This works well...at the beginning. However, after the 10th or so experiment, the robot arm beings to "fling around" after the service call. After 20 or so experiments, the whole robot starts rocking as it gets called. It's as if the model is colliding with itself. I'm wondering why this is.

Thoughts:
Could it be the effort controller? To test this I set all of the efforts to 0 between experimental runs, and give the controllers a second or two to settle before calling SetModelConfiguration. This didn't help.

Is gazebo storing some sort force? It seems like the controller would remove that. I use the "/gazebo/clear_body_wrenches" and the "/gazebo/clear_joint_forces" service calls to reset all forces, but that doesn't help either.

I'm out of ideas! I'm using gazebo for ROS (obviously), but I believe this may be an underlying gazebo issue, and may have a gazebo solution.

Here is a video showing when I use "SetModelConfiguration" 10 times with the same joint angles. Eventually it settles. I am giving no motor commands at this point, it's simply where the arm "settles" after resetting the joints.

Edit: This problem exists specifically with armed robots. Robots with just a base seem to work just fine.

Comments

That link seems to be broken, but if it's the project I think you're talking about, it uses a turtlebot. A turtlebot is great, since it has no arms/joints and you can just reset the whole simulation. My issue occurs specifically with armed robots (I've tried multiple). I'll modify my question.

If you don't spawn the robot again each iteration, all the small computation errors that have to do with the model will will create a larger error at the end. I don't think iterative learning is viable in gazebo if you don't at least update the pose of the robot manually.