RoPod/Tutorials/Load heightmap in GAZEBO: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
No edit summary
Line 39: Line 39:
4. Use STL file in GAZEBO
4. Use STL file in GAZEBO


As a final step, you can use the generated STL file in GAZEBO. It is IMPORTANT to scale DOWN the mesh 1000 times. This because the default units in the STL file are milli-meter and in GAZEBO are meters. If you wish a world higher than 1000mm choose an appropriate scale in z-direction.
As a final step, you can use the generated STL file in GAZEBO. It is IMPORTANT to scale DOWN the mesh 1000 times. This because the default units in the STL file are millimeters and in GAZEBO are meters. If you wish to have walls higher than 1000mm choose an appropriate scale in z-direction.

Revision as of 09:11, 19 September 2017

In principle Gazebo can load directly heightmaps specified in a png grayscale file. However, after following some tutorials, there is a bug in GAZEBO and the heightmap is not loaded correctly. According to comments in forums such functionality has not been paid too much attention since it is more efficient to work with mesh files when checking for collisions.

Therefore, as an alternative one can convert the heightmap into a 3D mesh file and load it in GAZEBO, which works straightforward. The conversion could be made in a program like blender, however here directions are given using open source software.

The conversion process is divided in several steps:

1. Convert PGM to SVG

The conversion is made using the program potrace. If not installed, run:

sudo apt install potrace

Next, use the resolution of your heightmap to compute the corresponding dpi resolution. Use this formula:

dpi resolution = 25.4 / #mmperpixel

For the heightmap of the lab, the resolution is 25mm/pixel, thus 1.016 dpi. Next run the potrace command as follows:

potrace -s heightmap.pgm -a 0 -r 1.016

Then a file named heightmap.svg is created.

2. Convert SVG to openSCAD file

OpenSCAD is an open source software to create mesh files, however it works with its own file types, thus we will later export the mesh to STL file. Thus, to do that, first a conversion from SVG to openSCAD is necessary.

To convert from SVG to openSCAD Inkscape needs to be installed. After installation, a plugin needs to be added to Inkscape. See step 2 on this link http://www.instructables.com/id/Make-a-3D-print-from-a-2D-drawing/#step2 . For the installation of the plugin you need to copy the paths2openscad.py AND the paths2openscad.inx files.

When creating the openSCAD file you can choose the height(mm) and the smoothing factor. Values of 1000 mm (Maximum allowed in the configuration) and 0.5 respectively work fine.

3. Render and create STL file

After installating openSCAD, follow step three from this link http://www.instructables.com/id/Make-a-3D-print-from-a-2D-drawing/#step3 . Thus, in openSCAD render the file generated in the previous step and export it as STL.

4. Use STL file in GAZEBO

As a final step, you can use the generated STL file in GAZEBO. It is IMPORTANT to scale DOWN the mesh 1000 times. This because the default units in the STL file are millimeters and in GAZEBO are meters. If you wish to have walls higher than 1000mm choose an appropriate scale in z-direction.