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

Error using Python GetModelResponse

asked 2015-02-18 16:39:39 -0600

rnunziata gravatar image

updated 2015-02-18 19:40:53 -0600

This code works in cpp.

 ros::ServiceClient client = n.serviceClient<gazebo_msgs::GetModelState>("/gazebo/get_model_state");
 gazebo_msgs::GetModelState getmodelstate;
 getmodelstate.request.model_name ="rrbot";
 client.call(getmodelstate);

But in python ...

 # Take pose from gazebo: ignore rviz pose: 
 rospy.wait_for_service("/gazebo/get_model_state")
 client = rospy.ServiceProxy("/gazebo/get_model_state", GetModelState)
 getmodelstate = client(model_name="rrbot")

 # Set starting data x,y and theta for odometry used in handelerJointControllerState
 self.theta = getmodelstate.response.pose.orientation.z

I get the following error:

 self.theta = getmodelstate.response.pose.orientation.z
AttributeError: 'GetModelStateResponse' object has no attribute 'response'

Any thoughts on the nature of this error.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-18 21:16:48 -0600

Thomas D gravatar image

updated 2015-02-18 21:21:48 -0600

Take a look at this answer. Looks like you might need to add a relative_entity_name variable in the request and that the response does not have a response field, rather you should use self.theta = getmodelstate.pose.orientation.z. I have not tried the code from the linked answer, but it looks reasonable and was accepted as a solution for making the exact same service calls you are trying to make.

Also, the z field in orientation is part of a quaternion and _not_ equal to yaw. See tf/transformations.py for how to convert quaternions to Euler angles.

edit flag offensive delete link more

Comments

much thanks

rnunziata gravatar image rnunziata  ( 2015-02-18 22:04:30 -0600 )edit

Could you explain what relative_entity_name is?

UserK gravatar image UserK  ( 2016-12-12 19:02:34 -0600 )edit
1

The GetModelState service has a request portion that contains model_name and relative_entity_name. The service documentation states: return pose and twist relative to this entity.

Thomas D gravatar image Thomas D  ( 2016-12-13 07:28:23 -0600 )edit

Thanks, basically thanks to this field you can specify in which frame the pose information should be expressed. You can leave it empty or specify for example "world"

UserK gravatar image UserK  ( 2016-12-13 10:05:40 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-18 16:39:39 -0600

Seen: 1,105 times

Last updated: Feb 18 '15