Welcome to ROSMASTER M1 PRO repository
2.Road Network Annotation
Road Network Description File Annotation
Road Network Description File Annotation1. Course Content2. Preparation2.1 Starting the Road Network Annotation Program3. Road Network Annotation Case Demonstration3.1 Adding Waypoints3.2 Adding Edges4. Saving the Road Network Description File5. Loading and Modifying the Road Network Description File5.1 Loading the Road Network Description File5.2 Editing the Road Network
1. Course Content
Use the
route_toolutility to annotate the road network and generate a.geojsonfile that describes the road network
2. Preparation
Refer to the LiDAR chapter 【Slam-Toolbox Mapping】 to build a grid map and a pose graph format pose map. After mapping is complete, the
$HOME/mapfolder should contain the following 4 files:

2.1 Starting the Road Network Annotation Program
Method 1: Start via RobotManager

Method 2: Start via the CLI command line
ros2 launch yahboomcar_bringup nav2.launch.py rviz_config:=roadnet_edit localization_mode:=slam_toolbox
RViz will display the map and two coordinate frames, where
mapis the map coordinate frame, andbase_footprintis the coordinate frame of the projection point on the ground at the center of the robot's chassis. Throughbase_footprint, we can know the robot's exact position in the map in real time.

3. Road Network Annotation Case Demonstration
3.1 Adding Waypoints
Click the
Publish Pointtool in the RViz toolbar to enter the waypoint selection state

Then left-click the mouse at the small blue dot at the center of the
base_footprintcoordinate frame. Thepositionfield under theRoute Tooltab at the lower left will automatically fill in the coordinates of the current point, and then click Create to create a waypoint.


Next, we move the robot to the next position where a waypoint needs to be marked. What is demonstrated here is directly carrying the robot to the next position where a waypoint needs to be marked.
Tip
Here the robot can be moved by keyboard control, joystick control, or 2D Goal Pose navigation in RViz, or it can even be carried directly to the next position to be marked, because the pose map allows the robot's global position to be quickly and accurately localized.
As you can see, because the robot was moved directly, the global localization is lost, and the LiDAR contour no longer matches the map's environmental features. Here we can use the pose map to perform fast relocalization.

Click the
2D Pose Estimatetool in the RViz toolbar

Then give an estimated position near the robot's approximate position

After that, the robot's exact localization in the global map will be restored immediately
Tip
The principle of this fast relocalization is to use slam_toolbox pure localization and the pose map to perform fast scan-map matching.
Note: During the waypoint marking process, if you observe that the LiDAR contour deviates from the map's environmental features (cumulative odometry error, wheel slip, manual movement, and various other factors can all cause local localization errors), you can use this method to quickly restore the robot's exact localization.

Repeat the above steps until all the waypoints that need to be marked are completed (mark waypoints according to the user's own actual needs)
After marking is complete, you can first turn off TF and LaserScan on the left to check the waypoints

3.2 Adding Edges
Select Edge in the
Route Tooltab

Fill in the starting waypoint of the edge in
Start Node ID, fill in the ending waypoint of the edge inEnd Node ID, and then click Create to create an edge between the waypoints.
Important
Note!
The road network is a topological structure composed of points and edges, and edges have direction. For example, the edge from 0→1 created here is one-way. If a two-way edge is needed, an edge from 1→0 must also be created.

After that, we create the edge from 1-0 so that waypoints 0 and 1 can be traveled in both directions.

Repeat the above steps to complete the creation of all edges (whether an edge is set as one-way or two-way is determined by the actual scenario requirements). In this case demonstration, all are set as two-way edges.

4. Saving the Road Network Description File
Click save in the
Route Tooltab, then select the path where the file is to be saved in the pop-up window. Here it is saved in the$HOME/map/folder.

Then fill in the file name in File name. It is recommended to keep it consistent with the grid map name for easy distinction; the file extension must be
.geojson. Finally, click save to save the road network description file.

After a successful save, the terminal will print a prompt message

After that, we can directly view the map.geojson road network description file from the host computer's
$HOME/mapfolder. The file contains a JSON-format description of the waypoint and edge information.

5. Loading and Modifying the Road Network Description File
5.1 Loading the Road Network Description File
If the previous road network description file needs to be modified later, for example to add, remove, or edit points and edges, you can load the previous road network description file for editing.
xxxxxxxxxxros2 launch yahboomcar_bringup nav2.launch.py rviz_config:=roadnet_edit localization_mode:=slam_toolbox
The yaml_filename parameter is the path of the grid map file of the road network to be annotated


5.2 Editing the Road Network
If you need to add new waypoints and edges, the operation is 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.
