Robotics StackExchange | Archived questions

Is there any way to get objects position (x, y) from a map?

I've a custom map, i want to get the object positions, like a rectangle i want to get the 4 points of the rectangle. is there a way? i'm using turtlebot3. my robot is in 0,0 position at the starting point.

Asked by ridwan on 2020-06-21 12:27:25 UTC

Comments

What do you mean? Using computational vision or PCL?

Asked by Teo Cardoso on 2020-06-23 13:37:23 UTC

I meant from 3d or 2d map. from rviz or gazebo. I want to get all the objects and the space they are occupying(x,y) in the map. for example i might have a map of 10x10, and there is a square in the map positioning [(1,1),(1,3),(3,1),(3,3)] this square is a object.

Asked by ridwan on 2020-06-24 01:26:14 UTC

Hi. If there are objects been showing in the RVIZ than those objects are been published from somewhere. I think you could verify the topic through the RVIZ, and after knowing which type they are, e.g, markers, you will be able to access their position in your code in the proper way.

Asked by mirella melo on 2020-09-24 21:29:28 UTC

Answers

If I were you, instead of trying to do this directly in RVIZ of Gazebo I would look at how to process the costmap in a custom node, and from there extract the information you want.

Maps in ROS are represented as Occupancy Grids. This stores a discretized (i.e. cells) representation of the environment. From this representation, with the correct logic in a roscpp or rospy node, you can extract the information you want. Here is an example in the ROS nav stack Global Planner Costmap which manipulates this discretized representation in c++. Costmap2D is not exactly a occupancy grid but the concept/representation is similar.

Once you have the grid available to you in c++, I imagine you can produce the logic required to generate the result you want.

Asked by JackB on 2020-09-24 08:35:42 UTC

Comments

@ridwan can you share with us how you solved this problem?

Asked by JackB on 2020-10-01 08:12:50 UTC