Robotics StackExchange | Archived questions

How can I dynamically get the coordinate of a model in gazebo?

I'm using Gazebo/ROS with TurtleBot. My robot needs to find the distance from itself to all the obstacles that exist in the environment while it is moving. I believe Laserscan has this information, but I am not sure how can I get the position of the models from Gazebo and reuse them in ROS with rospy. Can someone help me with some examples/tutorials?

Asked by Turtle on 2017-03-27 06:26:31 UTC

Comments

Answers

If you are running the gazebo_ros_laser plugin(or similar), it publishes a sensor_msgs/LaserScan.msg to /scan just like a real laser in ROS. Check out the LaserScan Message page for details on the format of the messages published by the /scan topic. One of the data elements in a LaserScan.msg is an array of range values:

float32[] ranges

This has the range data you're probably looking for. It's up to you/your code to determine how to use it, what makes up an object, filter out noise, etc.

You can find the position of the TurtleBot by subscribing to the /tf topic: (About which see here and here, and of course, The ROS Wiki tf Tutorial)

If you don't know how to work with the rospy publish/subscribe framework, there are tutorials on ros.org: Writing Publishers and Subscribers in Python

HTH and please mark this as an answer if it helped you!

Asked by jetdillo on 2017-04-03 09:20:11 UTC

Comments