Get Pose of a model from a plugin
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!
Asked by Anand George on 2015-12-16 14:32:57 UTC
Answers
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()
Asked by chapulina on 2015-12-16 14:55:08 UTC
Comments
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 ' ?
Asked by Anand George on 2015-12-17 00:02:16 UTC
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
Asked by Anand George on 2015-12-17 10:39:42 UTC
Comments
In gazebo9 is there any alternatives to this rather than calling modelstate services
Asked by dogukan_altay on 2019-06-18 06:52:48 UTC
Comments