Hey guys,
I have a few questions, sorry if there are simple answers but I couldn't find them in any of the tutorials.
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)
- 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.
Originally posted by bt on Gazebo Answers with karma: 3 on 2017-09-01
Post score: 0