Gazebo | Ignition | Community
Ask Your Question

How to get the position of certain object in gazebo?

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

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


See for getting the position through ROS

wongrufus gravatar imagewongrufus ( 2020-10-13 20:38:09 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

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

chapulina gravatar image

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, 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 -0600 )edit

I have posted a new problem about corresponding content in would you mind give me a hand ?

shin gravatar imageshin ( 2017-05-22 02:31:14 -0600 )edit

answered 2020-10-12 03:56:43 -0600

David Wright gravatar image

Can someone explain the answer to this question? I am in need of the solution to the questions asked by @shin. Found no reasonable solution. Anyone?

edit flag offensive delete link more

Question Tools

1 follower


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

Seen: 16,674 times

Last updated: Oct 12 '20