Gazebo | Ignition | Community
Ask Your Question

Get Pose of a model from a plugin

asked 2015-12-16 13:32:57 -0500

Anand George gravatar image

Hi there,

I want to get the current Pose of the model from a plugin. I tried by using this plugin. But it gives an error when compiling
error: ‘gazebo::physics::ModelState’ is not a base of ‘gazebo::physics::Model’
Why this error is coming? And how each coordinate is accessed and is assigned to some other variables?

Thanks in advance!

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2015-12-16 13:55:08 -0500

chapulina gravatar image

The problem is on this line:

gazebo::math::Pose pose = this->model->gazebo::physics::ModelState::GetPose();

The ModelState class is different from the Model class.

You probably want to use this->model->GetWorldPose()

edit flag offensive delete link more


Now that error is not coming. But how can I extract each coordinate from pose? I want to store x,y and z coordinate of the model to other variables. can I use ' x = pose._x ' ?

Anand George gravatar imageAnand George ( 2015-12-16 23:02:16 -0500 )edit

answered 2015-12-17 09:39:42 -0500

Anand George gravatar image

I found this method and is working perfectly.

double x,y,z;
gazebo::math::Pose pose;     
pose = this->model->GetWorldPose();
math::Vector3 v(0, 0, 0);
v = pose.pos;
x = v.x; // x coordinate
y = v.y; // y coordinate
z = v.z; // z coordinate
edit flag offensive delete link more

answered 2019-06-18 06:52:48 -0500

dogukan_altay gravatar image

In gazebo9 is there any alternatives to this rather than calling modelstate services

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-12-16 13:32:57 -0500

Seen: 6,850 times

Last updated: Jun 18 '19