Skip to content

Making Maps for ROS from Tango

clakell edited this page Jun 26, 2014 · 6 revisions

The maps created by the device can also be converted simply into image files for a ROS environment. To accomplish this, the tutorial uses netfabb Basic. netfabb Basic was designed for 3D printing, but its slicing environment and cutting tools make it an ideal program to take a particular section of your scan. You do not need to be familiar with netfabb for this tutorial.

The robot only needs to know about the section that influences it: particularly, from the floor to the top of your robot. We will be selecting only this section to create a black and white map.

First, open netfabb and import (Project -> Add Part) your merged file from earlier which is devoid of scattered particles. Because netfabb and MeshLab have different axes, you will need to rotate the mesh to get a top-down view. Go into the menu Part -> Rotate then under "Parameters" click the circle next to "x axis" and press 90 degrees. Click Rotate to finish and close the window. Finally, click the second cube in the top of the project window with an orange top face to show the overhead view of the object.

On the right hand side is the "Cut" area along with vital information about your mesh. Use the cut slider labeled for the Z axis to find the "floor" of the mesh. The green lines identify the edges of the cut. You will need to bring the cutting plane up such that it intersects with the walls and all the objects in the room but not the floor itself. If you are having trouble seeing the edges, or this does not feel precise enough, see section titled Alternative Slicing Method (slower). See these images for more detail:

This image shows the plane intersecting with the floor improperly.

intersection with floor

This image shows the cutting plane intersecting with the chair and the walls, but not the floor itself.

correct cutting

Press "Execute Cut" and then "Cut" in the lower right. Ignore the red warning sign if it comes up. You will not be using this mesh directly, so it does not matter if there are holes. Next, you will need to repeat the process to cut the top of the mesh. Find something in the mesh that is approximately equal to the height of your robot. For this map, it is the seat of the chair. Raise and lower the Z cutting plane using the slider until it just surpasses the height of the object. This does not need to be extremely exact, as the map itself is not exact. Again, press "Execute Cut" and then "Cut." Now you have the slice you need. In the "context area" above the Cut menu, click the little plus sign (+) next to "Parts" then again to the left of "Cuts of filename" and "Cuts of filename (Cut 2)" to see all the parts. Click the orange eyes next to "filename (Cut 1)" and "filename (Cut 2) (Cut 2)." When finished, your context area should look like this:

context area

Make sure that the image you see on the left is the right piece. Zoom out so that you can see your entire map with about an inch of white space on all sides then go into Edit -> Save Screenshot and save it to your disk. Next use your favorite image editor/viewer to bring Contrast up to 100%. In Mac's Preview, this is under Tools -> Adjust Color and dragging the contrast slider all the way to the right. In GIMP, this is under Tools -> Color Tools -> Brightness/Contrast. Most image editors have a contrast adjustment. Lastly, you can use a white paintbrush tool or creative cropping to remove any leftover symbols (such as the red warning symbol) or floating pieces. If there seems to be a dearth of floating parts, see section titled Removing Floaters using Meshlab.

Here are some examples of complete maps using this approach: Kitchen Map Hall Map Smooth Hall Map Rough Hall Map Simple

Alternative Slicing Method (slower):

Alternatively, for a more precise method you can use netfabb's slicing tool to select the correct layers. Go into the menu Extras -> Slice Selected Parts and pick a small layer size (0.01mm or so). Use the slider on the left of the Information menu (lower right) to find the bottom layer. Read the number labeled "Current Z Height" and write it down somewhere. Next, use the slider to find the top layer and record the new number. To return to the mesh, click on the filename in the Parts area of the context menu. In the "Cuts" area, type the first number you found into the box to the right of the "Z" slider and then press "Execute Cut" followed by "Cut." Repeat the process with the second number. This method is more precise because it is easier to see the outline of the slice. Complete the map the same way. The slicing images cannot be used directly because they do not contain the data from the layers above and below. Also notice that there is a grid which will interfere with ROS' system. Slicing area: one layer only

Removing Floaters using Meshlab: If it seems like there are too many floating pieces to be removed by an image editor, you can use MeshLab again to remove the new floating pieces. In netfabb, export the part by using Part -> Export Part -> PLY. You can use any format, but PLY will preserve original attributes of the mesh. Import the part into MeshLab and again use Filters -> Cleaning and Repairing -> Remove Isolated pieces (wrt Diameter) with the max diameter setting at .5. Apply, and if there are more pieces remaining, increase the parameter by using the up arrow to the right and press apply again. Repeat this process until all of the floating pieces you don't want are removed. You will have to again export the mesh out of MeshLab and import it into netfabb to get the top down view needed for the 2D maps.

Final Notes:

For the map to be useful in ROS, you will need to determine the scale. Find a large landmark in the image and measure out its length in reality. Then use your image editor to determine its length in pixels on the map.