ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to change gravity in Gazebo/questions on reseting the model

asked 2017-09-07 02:11:06 -0600

brendant gravatar image

Hey guys,

I have a few questions, sorry if there are simple answers but I couldn't find them in any of the tutorials. Also, I'm sorry that these are more related to Gazebo, but didn't get any responses from the Gazebo answer page.

I am trying to create a simple walker with 8 joints to use with reinforcement learning algorithms, and so need to reset the model quickly after each episode.

The problem I am having is when I do a service call to reset the world and the model, the plugins need to restart (camera, imu, joint_states) and they take up to minutes to publish again (which is not ideal given the many episodes needed).

So instead I am trying to reset the model_state at the end of the episode back to its starting position. The problem with this is getting the joint positions back to 0.0. I am using the joint_position_controller/command as outlined in the tutorials but they obviously take some time to get back to these positions, and this time seems to be affected by gravity (even after turning up the PID values).

I thought that if I changed gravity to zero, reset the model_state, then I could send the joint commands, and then turn gravity back on.

My questions:

  • How do I reset gravity? Am I missing a gazebo_msg that I need to include in the service call? What I have so far:

 from gazebo_msgs.srv import SetPhysicsProperties
 set_gravity = rospy.ServiceProxy('/gazebo/set_physics_properties', SetPhysicsProperties)
 set_physics = SetPhysicsProperties() # how do I set gravity? 
 set_gravity(set_physics) # this call does not work (not expecting SetPhysicsProperties object) 
But this service call works from the command line:

rosservice call /gazebo/set_physics_properties "
time_step: 0.001
max_update_rate: 1000.0
gravity:
  x: 0.0
  y: 0.0
  z: 0.0
ode_config:
  auto_disable_bodies: False
  sor_pgs_precon_iters: 0
  sor_pgs_iters: 50
  sor_pgs_w: 1.3
  sor_pgs_rms_error_tol: 0.0
  contact_surface_layer: 0.001
  contact_max_correcting_vel: 100.0
  cfm: 0.0
  erp: 0.2
  max_contacts: 20"
-Is there a better way of get the joints to go to a desired position? Currently I have to wait for the joints to reach their positions (determined by process_value_dot because some of the joints don't reach their positions when the robot has fallen over, I assume due to effort constraints):

for i in range(NUM_JOINTS):
    joints[i].publish(0.0)
    data = None
    while not rospy.is_shutdown():
        try:
            data = rospy.wait_for_message('/mybot/joint' + str(i) + '_position_controller/state', JointControllerState, timeout=1)
            if abs(data.process_value_dot) < 0.01:
                break
        except:
            pass
        time.sleep(0.001)
  • This approach I am trying seems very convoluted for simply reseting the model without restarting the plugins. Is there a better way to reset the model quickly (keeping in mind the /gazebo/reset_simulation service call stops the plugins)?

Thanks for your time guys.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-11 17:45:15 -0600

brendant gravatar image
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-09-07 01:56:11 -0600

Seen: 2,592 times

Last updated: Sep 11 '17