Home | Tutorials | Wiki | Issues
Ask Your Question

Plugin to find pose of a robot

asked 2016-08-12 11:34:44 -0600

blastpower5 gravatar image

Hi, I'm new to Gazebo and ROS.

I'm trying to find a plugin that I can hook to the sdf file of my robot which will publish its pose in (x,y,z) format. I noticed that there is already a topic being published to called "/gazebo/model_states" which contains the pose of every model in the world. I'm not sure if there's a way to manipulate this to get the pose from one singular model.

Thanks in advance for any help.

edit retag flag offensive close merge delete


To clarify, you'd like the pose to be published over a ROS topic, or a Gazebo topic?

chapulina gravatar imagechapulina ( 2016-08-12 12:15:14 -0600 )edit

A ROS topic would be best, but I think (not sure) either would work.

blastpower5 gravatar imageblastpower5 ( 2016-08-12 14:13:57 -0600 )edit

blastpower5, i just started using the plugins and i can tell that you CAN do the task using both ROS and Gazebo communications. For ROS, you will have to link against the proper libraries. Using Gazebo, it's like the examples. Using a ROS topic would require to link against and include ROS, coding a publisher and publish the information. The plugins work like a normal executable. Since the update function receives a pointer to the model, it's always updated.

wicked88 gravatar imagewicked88 ( 2016-08-16 21:20:16 -0600 )edit

// Continuation : You can then make a forever loop, with a sleep inside, and publish your information.

wicked88 gravatar imagewicked88 ( 2016-08-16 21:20:44 -0600 )edit

If you go to the gazebo folder, under examples/plugin/model_move you can see the structure of a plugin, its a normal c++ program. The Load() function instantiates everything, it's like a constructor. From here, you can do everything, knowing that on startup of the model, the Load function is going to be ran. You also receive this pointer [ ::Load(physics::ModelPtr _parent] which is the pointer to the model, where every data about the model can be read, set and managed, like pose, velocity etc.

wicked88 gravatar imagewicked88 ( 2016-08-16 21:29:08 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-13 20:18:30 -0600

wicked88 gravatar image

Just proceed with the installation of ros-gazebo packages :

$ sudo apt-get install ros-indigo-gazebo-ros-pkgs ros-indigo-gazebo-ros-control

Then, just do $ rosrun gazebo_ros gazebo or $ rosrun gazebo_ros gzserver (to do it headless). You can inspect the rostopic list after that. You will see a bunch of topics, just do $ rostopic echo /gazebo/model_states and you will see the names and poses of the models. Parse that, given the name, and you will have eveything you need. Easy wait out is to write a parser to split the full message and separate it into small messages. Don't know if its possible to atatch a plugin to work with ROS to a model, but if it is, i WOULD LOVE IT.

edit flag offensive delete link more


Thanks for the help! I have also found a plugin that I put in the sdf file of my robot's model: '<plugin name="p3d_base_controller" filename="libgazebo_ros_p3d.so">'. It publishes messages of type nav_msgs/Odometry, which includes both the pose and twist of the robot.

blastpower5 gravatar imageblastpower5 ( 2016-08-17 14:30:29 -0600 )edit

Btw, it's clearly possible and easy to make a ros node inside a plugin, to publish whatever you want :D

wicked88 gravatar imagewicked88 ( 2016-08-20 07:24:22 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-08-12 11:34:44 -0600

Seen: 726 times

Last updated: Aug 13 '16