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

Revision history [back]

click to hide/show revision 1
initial version

The lack of orientation in your service request causes SetModelState to put all links at the same location (overlapping each other), this is definitely a bug, but you can add the following definition to avoid this behavior:

model_state = gazebo.msg.ModelState()
model_state.model_name = 'pr2'
model_state.pose.position.x = 1
model_state.pose.position.y = 2
model_state.pose.position.z = 0
model_state.pose.orientation.x = 0
model_state.pose.orientation.y = 0
model_state.pose.orientation.z = 0
model_state.pose.orientation.w = 1

rospy.wait_for_service('/gazebo/set_model_state')
try:
    sms = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
    print 'Model State: ' + str(model_state)
    sms(model_state)
except rospy.ServiceException, e:
    print "Service call failed: %s"%e

By the way, the recommended message to use is in gazebo_msgs package as I've reference above.