Ask Your Question
0

initialize pr2 posture in gazebo

asked 2011-08-24 02:53:13 -0500

updated 2014-11-22 17:05:03 -0500

ngrennan gravatar image

Does anybody know of a way to initialize the PR2 posture in gazebo to something specific? Currently the robot is initialized with the two hands pointing to the front and I move the arms and the head of the robot, but this is quite slow in simulation, and this will be repeated many times automatically.

Any suggestions about how to save the robot position? If I save the gazebo world, do you think I will be able to re-summon the PR2?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2011-08-24 11:47:20 -0500

hsu gravatar image

updated 2011-08-24 11:51:01 -0500

There is a ros service call: /gazebo/set_model_configuration that sets joint angles for a robot. However, for PR2, you might have to call /pr2_controller_manager/switch_controller before and after to disable and re-enable affected mechanism controllers trying to hold positions; otherwise the joints configured will try to return to the previous state immediately after the call.

Please reference gazebo for documentation on the service call. There is a rough example I've put together for testing here as well.

As a python example, I've added a flag in the spawn_model script, so you can start your robot with certain joints at predefined positions, for example:

rosrun gazebo spawn_model -urdf -param robot_description -model pr2 -J head_tilt_joint 0.2 -J head_pan_joint 0.5

Lastly, with regards to saving/resuming simulation state, we don't have anything implemented so far. Most likely by G-turtle.

edit flag offensive delete link more

Comments

This flag doesn't work in Indigo. Any suggestions how to set the initial pose? Regards, J_Schaefer

J_Schaefer gravatar imageJ_Schaefer ( 2016-08-24 05:45:37 -0500 )edit

It doesn't work for me as well. I've read somewhere it is still to be fixed, but I wonder if any solution available now?

johnyang gravatar imagejohnyang ( 2016-09-19 21:10:43 -0500 )edit
1

answered 2011-08-24 11:30:47 -0500

watts gravatar image
edit flag offensive delete link more
1

answered 2018-02-21 15:29:18 -0500

biglotusturtle gravatar image

I was looking for an example of resetting joint angles using the /gazebo/set_model_configuration service in python and couldn't find one so I figured I would post it here:

import rospy
from gazebo_msgs.srv import SetModelConfiguration
from gazebo_msgs.srv import SetModelConfigurationRequest

reset_joints =  rospy.ServiceProxy('/gazebo/set_model_configuration', SetModelConfiguration)

reset_req = SetModelConfigurationRequest()
reset_req.model_name = 'robot'
reset_req.urdf_param_name = 'robot_description'
reset_req.joint_names = ['joint1'] #list
reset_req.joint_positions = [-1.57] #list
res = reset_joints(reset_req)

Hopefully this will help someone else. Let me know if this example doesn't work

edit flag offensive delete link more

Comments

Hello, thank you for your code snippet. I tried that. In principle it should work since the return value is : success: True status_message: "SetModelConfiguration: success" but the robot in the gazebo doesn't move to the desired configuration (physics is unpaused).

mikeda gravatar imagemikeda ( 2019-03-01 09:04:36 -0500 )edit

You may need to first pause physics for this method to work. Does calling this service work from the command line?

biglotusturtle gravatar imagebiglotusturtle ( 2019-03-01 09:54:43 -0500 )edit

Hello, thanks for the reply. I pause and later unpause physics when setting the model configuration. CMD line request indicates a success as well (if corect robot name is provided). But the robot doesn't move... I found out that it returns success though whatever joint_names are specified.

mikeda gravatar imagemikeda ( 2019-03-04 03:34:43 -0500 )edit

The command line actually revealed the following: 1. I pause the physics: rosservice call /gazebo/pause/physics 2. Then I set the Joint configuration -> and gazebo sets the Robot Position accordingly but when I 3. reactivate physics Robot is reset to its original Position. How can I avoid that ?

mikeda gravatar imagemikeda ( 2019-03-04 04:24:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-08-24 02:53:13 -0500

Seen: 1,221 times

Last updated: Feb 21 '18