Mapping
The mapping procedure allows to map the track or more in general an environment.
Preparation
- 
Verify that the bring up is on: Move left and right the wheels of the car a couple of times. 
- 
Open RViz2: from the VNC instance, open a terminal and run rviz2.- Since we still don't have a map, we won't se anything right away. Thus set fixed frame to laserin order to see the lidar scans.
 Note If you don't see the lidar scans or they are stuck move the wheels of the car with the joystick 
- Since we still don't have a map, we won't se anything right away. Thus set fixed frame to 
Scan the environment
- 
Run the mapping algorithm Open a new ssh instance and run From RViz it should be visible that the mapping has started since it starts to build the map. 
- 
Explore the environment - Move the car slowly around the whole environment. Avoid doing many turns. Less you steer better the mapping will be.
- When you feel satisfied with the result, keep the car still and do not stop the mapping algorithm because the map needs still to saved.
 
- Save the map- From RViz make sure to have the SLAM toolbox visible. If not open it clicking on "panels > add new panel > SLAM toolbox plugin"
- Next to the Save Mapbutton write the name that you want to give to the map. A suggested name isYYYYMMDD
- Click the Save Mapbutton. In the logs of the mapping algorithm you should see that the map is successfully saved. You should see 2 new files in the folder where the mapping algorithm was executed. One is a.pgmfile and one is a.yamlfile. Now you can stop the mapping algorithm usingCTRL-Cin the terminal.
- A good practice is to move these 2 files in a new folder called YYYYMMDDinside the/home/ubm/repo/maps/directory.
 
Edit the generated map
In order to improve the localization capabilities and supply the speed profile algorithm with an easier map, the map needs to be manually edited.
- 
Copy the map files to your pc: From a terminal in your pc (not in a ssh instance) run the following command, using the right IP address and the correct path. 
- 
Edit the map for localization - 
Modify the .pgmFile
 Use an image editor to open the.pgmfile. GIMP is recommended for this procedure.Objective: Refine the map to ensure the localization algorithm performs accurately by removing all gray pixels. - All pixels must be either completely black (#000000) or completely white (#FFFFFF).
- Avoid making significant changes to the map, as it should closely resemble what the LiDAR scans will detect.
 
- 
Export the Edited File 
 Save the edited map as a.pgmfile using RAW data formatting. Name the filemapname_edited.pgm.
- 
Modify the .yamlFile- Copy the .yamlfile.
- Update the imageparameter to point tomapname_edited.pgm.
- Save the modified file as mapname_edited.yaml.
 
- Copy the 
 Reference Video 
 The video below demonstrates this procedure:
- 
- 
Edit the map for raceline - 
Modify the mapname_edited.pgmFileObjective: Refine the map to ensure the raceline algorithm performs accurately by providing a smooth path. - Remove parts of the map where the raceline should not go
- There must be only a feasible path. If there are obstacles remove all of them. If there are 2 paths to make the lap give the algorithm only one option
- Make all corners as smooth as possible.
- Sharp corners may be increased a little to avoid crashes.
 
- 
Export the Raceline File Save the edited map as a .pgmfile using RAW data formatting. Name the filemapname_raceline.pgm.
- 
Modify the .yamlFile- Copy the .yamlfile.
- Update the imageparameter to point tomapname_raceline.pgm.
- Save the modified file as mapname_raceline.yaml.
 
- Copy the 
 Reference Video 
 The video below demonstrates this procedure:
-