Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to get a model position in Gazebo World Plugin?

asked 2018-12-17 02:15:08 -0500

kumpakri gravatar image

I am writing a Gazebo World Plugin where I need an information about the position of certain model with respect to world origin. I am using Gazebo-9 and for this version of Gazebo I didn't find any working solution. Can anybody tell me how to achieve this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2018-12-17 11:20:46 -0500

// Get model
auto model = _world->ModelByName("model_name");
// Get pose
auto pose = model->WorldPose();

Checking the API documentation should help you in the future:

edit flag offensive delete link more
0

answered 2018-12-19 03:02:42 -0500

kumpakri gravatar image

updated 2018-12-19 03:03:57 -0500

I couldn't find the WorldPose() method in Model.hh file on my machine, so I ended up using

 physics::ModelPtr model = this->world->ModelByName(model_name);
 physics::LinkPtr link = model->GetLink(link_name);
 ignition::math::Pose3d pose = link->WorldCoGPose();
 ignition::math::Vector3<double> position = pose.Pos();
 double pos[3] = {position.X(), position.Y(), position.Z() };

First, I forgot to include

 #include <gazebo/physics/physics.hh>

So that's why nothing seemed to work.

edit flag offensive delete link more

Comments

`Model::WorldPose` is new on Gazebo 8, if you're using an earlier version, you can use `Model::GetWorldPose`. Note that the CoG pose may be different from the model's origin.

chapulina gravatar imagechapulina ( 2018-12-19 10:56:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-17 02:15:08 -0500

Seen: 611 times

Last updated: Dec 19 '18