Home | Tutorials | Wiki | Issues
Ask Your Question

How to get the position of certain object in gazebo?

asked 2017-05-04 02:36:29 -0500

shin gravatar image

I am interested in using gazebo to simulate the movements of some objects, now I want to get their positions in some time stamps, namely x, y, z coordinates. How can I implement this, maybe with C language ? I have searched this for a long time, but I find no way to implement this, could someone gives me a hand ? Thank you very much !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-04 11:23:31 -0500

This tutorial should be useful to you:

Gazebo Tutorials: Model plugins

It explains how to write a plugin in C++ which is loaded with Gazebo and sets the velocity of a model. In your case, you should change SetLinearVel to GetWorldPose to get the position. You can get the time stamp from common::UpdateInfo.

An alternative approach would be to create a program which subscribes to the ~/pose/info topic as explained on the following tutorial:

Gazebo Tutorials: Topic subscription

edit flag offensive delete link more


I have read through the example in http://gazebosim.org/tutorials?tut=topics_subscribed&cat=transport, and I think I need to modify the function cb(ConstWorldStatisticsPtr &_msg) to output the information I want.For example, I have a world with some objects, I would like to get the pose of certain object, then I must modify the cb() function or even the whole code :gazebo::transport::SubscriberPtr sub = node->Subscribe("~/pose/info", cb); then where can I search for the function should be used?

shin gravatar imageshin ( 2017-05-04 23:56:20 -0500 )edit

I have posted a new problem about corresponding content in http://answers.gazebosim.org/question/16214/how-to-get-image-without-storing-into-disk-from-gazebo/ would you mind give me a hand ?

shin gravatar imageshin ( 2017-05-22 02:31:14 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-05-04 02:36:29 -0500

Seen: 1,224 times

Last updated: May 04 '17