How to get the position of certain object in gazebo?
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 !
Asked by shin on 2017-05-04 02:36:29 UTC
Answers
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
Asked by chapulina on 2017-05-04 11:23:31 UTC
Comments
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?
Asked by shin on 2017-05-04 23:56:20 UTC
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 ?
Asked by shin on 2017-05-22 02:31:14 UTC
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?
Asked by David Wright on 2020-10-12 03:56:43 UTC
Comments
See https://answers.gazebosim.org/question/25915/how-to-get-the-position-of-certain-object-in-gazebo-and-publish-it-on-a-topic-to-use-it-in-px4-or-ros/?answer=25934#post-id-25934 for getting the position through ROS
Asked by wongrufus on 2020-10-13 20:38:09 UTC