# Generate paths from 3d map

Anyone knows a how can I from a 3D map (described as a .sdf gazebo file) get a data structure as output that difference obstacles from free way in order I can give to my robot a path to it follows (not necessary the best one)? Is there a library for that?

edit retag close merge delete

Please, correct me if I'm wrong. You have a Gazebo world file with a few models of the world. I'm assuming that there are walls and other obstacles. You want to generate a data structure that captures the occupancy of the world. Is that right? If so, you may want to discretize your world into a 2D grid where each cell has a binary value (free or obstacle). One way do this might be to check the bounding box of each model and translate it to grid coordinates for marking them as obstacle.

( 2017-11-06 12:57:15 -0500 )edit

Of course this only works if your obstacles are static, otherwise you have to rerun this process for the dynamic models periodically. If the objects are not solid you will need a different solution. You could cast vertical rays and check if they collide with the ground plane (free) or with a different model (obstacle).

( 2017-11-06 12:57:45 -0500 )edit

I'm new on that @CarlosAguëro. Do you know any way to discretize a 3D world?

( 2017-11-06 15:55:46 -0500 )edit

You need to figure out how to translate from 2D world coordinates to the right cell in your 2D grid. Imagine that you have a 2 meter X 2 meter world and you want to discretize it in cells of 1 squared meter. You'll have a total of 4 cells with cell (0,0)=(-0.5, 0.5), cell(0,1)=(0.5,0.5), cell(1,0)=(-0.5,-0.5) and cell(1,1)=(0.5, -0.5). That means that in order to find out if cell (0,0) is free, you have to check if there's an object in (-0.5, 0.5, any_height) in Gazebo world coordinates.

( 2017-11-06 19:59:47 -0500 )edit

Do you think it would be worth use octrees (like is done in OctoMap Framework) and fill voxels with a binary value to indicates the occupancy volume?

( 2017-11-07 11:29:55 -0500 )edit

Definitely, that sounds like a good idea but I'd start with a very simple custom 2D grid solution to make sure that you have a good understanding of all the steps first. Then, you can incrementally move to octomaps or ROS occupancy grids. Please, share a video with us when you finish it :)

( 2017-11-07 11:57:34 -0500 )edit