Welcome to MicroROS V2 Robot Car repository
3. Road Network Annotation
Road Network Description File Annotation
Road Network Description File Annotation1. Course ContentCourse Objectives2. Road Network Annotation2.1 Adding Waypoints3.3 Adding Edges4. Saving the Road Network Description File5. Loading and Modifying the Road Network Description5.1 Loading the Road Network Description File5.2 Editing the Road Network
1. Course Content
- Use the
route_tooltool to annotate the.geojsonformat file describing the road network
Course Objectives
- Master the methods of road network file annotation, editing, and modification
2. Road Network Annotation
ros2 launch microros_v2_bringup toolbox_location_nav.launch.py rviz_config:=roadnet_edit
- Rviz will display the map and two coordinate frames:
mapis the map coordinate frame, andbase_footprintis the coordinate frame of the projection point of the robot chassis center on the ground. Throughbase_footprint, we can know the robot's exact position on the map in real time

2.1 Adding Waypoints
- Click the
Publish Pointtool in the Rviz toolbar to enter waypoint selection mode

- Then click the left mouse button on the small blue dot at the center of the
base_footprintcoordinate frame. Thepositionfield in theRoute Tooltab at the bottom left will automatically be filled with the coordinates of the current point, and then click Create to create a waypoint


- Next, move the robot to the next position where a waypoint needs to be marked. In this demonstration, the robot is directly moved to the next position to be marked
[!TIP]
The robot can be moved via keyboard control, gamepad control,
2D Goal Posenavigation in rviz, or even by physically carrying the robot to the next position to be marked, because the pose map allows the robot's global position to be quickly and accurately located
- As you can see, because the robot was physically moved, the global localization was lost, and the laser contour no longer matches the map environment features. Here we can use the pose map to quickly relocalize

- Click the
2D Pose Estimatetool in the Rviz toolbar

- Then give an estimated pose near the approximate position of the robot

- Afterwards, the robot's accurate position on the global map will be restored immediately
[!TIP]
- The principle of quick relocalization here is to use
slam_toolboxpure localization and the pose map for fast scan-map matching- Note: If, during subsequent waypoint annotation, you observe a deviation between the laser contour and the map environment features (due to odometry cumulative error, wheel slippage, manual displacement, or other factors causing local localization errors), you can use this method to quickly restore the robot's accurate position.

- Repeat the above steps until all waypoints that need to be marked are done (annotate waypoints according to the user's actual needs)
- After finishing the annotation, you can first turn off the TF and LaserScan on the left to check the waypoints

3.3 Adding Edges
- Select Edge in the
Route Tooltab

- Fill in the starting waypoint of the edge in
Start Node IDand the ending waypoint of the edge inEnd Node ID, then click Create to create an edge between waypoints
[!IMPORTANT]
Note!!!
A road network is a topological structure composed of points and edges, and edges are directional. For example, the edge 0---->1 created here is one-way. If a bidirectional edge is needed, you must also create the edge 1---->0.

- Then we also create the 1-0 edge so that waypoints 0 and 1 can be traveled in both directions

- Repeat the above steps to create all edges (whether the edges created here are one-way or bidirectional depends on the actual scenario requirements)

4. Saving the Road Network Description File
- Click save in the
Route Tooltab, then in the pop-up window select the path where the file will be saved. Here we select the~/mappath, fill in the file name in the File name field (it is recommended to keep it consistent with the grid map name for easy distinction), and the file suffix must be .geojson. Finally, click save to save the road network description file

- After saving successfully, the terminal will print a confirmation message

- Afterwards, we can directly view the map.geojson road network description file from the
~/mappath on the host machine. The file contains a JSON-format description of the waypoint and edge information

5. Loading and Modifying the Road Network Description
5.1 Loading the Road Network Description File
- If you need to modify a previously created road network description file later, for example adding, removing, or editing points and edges, you can load the previous road network description file for editing
xxxxxxxxxxros2 launch microros_v2_bringup toolbox_location_nav.launch.py rviz_config:=roadnet_edit


5.2 Editing the Road Network
- If you need to add new waypoints and edges, the operations are the same as the previous steps
- Click
Editto re-edit the information of an existing waypoint or edge

- Click
Removeto remove an existing waypoint or edge
