Welcome to ROSMASTER M3 repository
3.Road Network Labelling
Road Network Description File Labelling
Road Network Description File Labelling1. Course Content2. Preparation Work2.1 Start Agent2.2 Road Network Labelling2.3 Start ros2_kilted docker container (Skip for PI5 & RDK mainboards)2.4 Start Road Network Labelling Node2.5 Add Waypoints2.6 Add Edges3. Save Road Network Description File4. Load and Modify Road Network Description4.1 Load Road Network Description File4.2 Edit Road Network
1. Course Content
- Use route_tool tool to label
.geojsonformat files that describe road networks
2. Preparation Work
2.1 Start Agent
- Use the following command to start microROS agent to connect to the chassis
[!WARNING]
If microROS agent is already started, close the previous agent first. Note that this command is different from the previous microROS agent startup command
start_kilted_agent

- Modify ROS communication middleware DDS
[!WARNING]
For Raspberry Pi 5 users, if the ROS container is not started, you need to start the container first,
xxxxxxxxxxbringup_m3Open a terminal inside the container,
xxxxxxxxxxexec_m3Open ~/.bashrc, uncomment this line, and change it to the DDS communication middleware as shown in the figure (only the road network planning and navigation chapter needs to use cyclondds, please restore the environment variables after completing the road network chapter!!)
xxxxxxxxxxvim ~/.bashrc
- RDK & PI5 mainboards
- ORIN mainboard
xxxxxxxxxx:wq #Save and exitsource ~/.bashrc #Update environment
2.2 Road Network Labelling
- When marking the road network, we need to know the specific position of the vehicle in the map, so we need to start the navigation node on the host first. Through the position of the base_footprint coordinate system, we can know the specific position of the vehicle in the map
- (For PI5 users, start in the
m3 container)
xxxxxxxxxxros2 launch m3_bringup nav2.launch.py map:=map.yaml pose_map:=map localization_mode:=slam_toolbox gui:=False
[!NOTE]
Startup parameter description
- map The grid map name to be loaded, here we choose the map saved in the previous lesson
- pose_map The pose map file name to be loaded without file suffix, used for more accurate and fast positioning of the vehicle
- localization_mode Global localization method, here we choose slam_toolbox when marking the road network, which can achieve higher precision global positioning using the pose map
- gui Whether to start rviz, here we choose not to start, it will be started later in the docker container
2.3 Start ros2_kilted docker container (Skip for PI5 & RDK mainboards)
- Start ros2_kilted container (only need to start once, no need to repeat)
xxxxxxxxxxbringup_ros2kilted
- Enter ros2_kilted container terminal
xxxxxxxxxxexec_ros2kilted
2.4 Start Road Network Labelling Node
- Start in ros2_kilted container terminal
(ORIN mainboard)
xxxxxxxxxxros2 launch road_net_route route_tool.launch.py yaml_filename:=map.yaml(PI5 & RDK mainboards) Only need to start rviz, visualization is started on the accompanying virtual machine Rosmaster-RoadNet-Ubuntu24.04,
xxxxxxxxxx#Virtual machine siderviz2 -d /home/yahboom/code_ws/src/road_net_route/rviz/route_tool.rviz- yaml_filename parameter is the grid map file path of the road network to be labeled, here we use the map built in the previous lesson
[!NOTE]
The host's map will be saved in the
~/mappath by default. This path will be automatically mounted to the/root/mapdirectory in the ros2_kilted container, so the map files saved on the host can be used directly in the ros2_kilted container
- The map and two coordinate systems will be displayed in rviz, where map is the map coordinate system, and base_footprint is the coordinate system of the projection point of the vehicle chassis center on the ground. Through base_footprint, we can know the accurate position of the vehicle in the map in real time

2.5 Add Waypoints
- Click the
Publish Pointtool in the rviz toolbar to enter waypoint selection state

- Then click the left mouse button at the center blue dot of the base_footprint coordinate system. The
positionin theRoute Tooltab in the lower left corner will automatically fill in the current point's coordinates, then click Create to create a waypoint


- Then we move the vehicle to the next position where we need to mark a waypoint. In this demonstration, we directly move the vehicle to the next position where we need to mark a waypoint
[!TIP]
Here you can move the robot vehicle through keyboard control, gamepad control,
2D Goal Posenavigation in rviz, or even directly move the vehicle to the next position to be marked, because with the pose map, you can quickly and accurately locate the global position of the vehicle
- As you can see, because the vehicle was moved directly, the global positioning is lost, and the laser contour no longer matches the map environment features. Here we can use the pose map for fast relocalization

- Click the
2D Pose Estimatetool in the rviz toolbar

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

- After that, the accurate positioning of the vehicle in the global map will be immediately restored
[!TIP]
- The principle of fast relocalization here is to use slam_toolbox pure localization and pose map for fast scan-map matching
- Note: When you observe that the laser contour and map environment features have deviations during the subsequent waypoint marking process (due to accumulated odometry errors, wheel slippage, manual movement, and other factors causing local positioning errors), you can use this method to quickly restore the accurate positioning of the vehicle.

- Repeat the above steps until all required waypoints are completed (mark waypoints according to your actual needs)
- After marking is complete, you can close TF and LaserScan on the left side to check the waypoints

2.6 Add Edges
- Select Edge in the
Route Tooltab

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

- Then we create the edge 1-0, so that vehicles can travel in both directions between waypoints 0 and 1

- Repeat the above steps to complete the creation of all edges (whether the edges created here are unidirectional or bidirectional depends on actual scenario requirements)

3. Save Road Network Description File
- Click save in the
Route Tooltab, then select the path to save the file in the pop-up window. Here we choose the/root/mappath, because this path is bound to the host's~/mappath, and you can directly view the saved files on the host later

- 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 suffix must be .geojson. Finally, click save to save the road network description file

- After successful saving, the terminal will print prompt information

- Then we can directly view the map.geojson road network description file from the host's
~/mappath. The file contains JSON format descriptions of waypoint and edge information

- (PI5 & RDK mainboards) Transfer road network file
Use the scp map.geojson sunrise@192.168.11.78:~/map/ command (fill in actual username and ip) to directly transfer to the host's ~/map path, because this path is bound to the /root/map path in the docker container. You can also drag it out from the virtual machine and then transfer it to the host.

4. Load and Modify Road Network Description
4.1 Load Road Network Description File
- If you need to modify the previous road network description file later, such as adding, removing, editing points, or edges, you can load the previous road network description file for editing
- Start in ros2_kilted container terminal (Skip for PI5 & RDK mainboards)
xxxxxxxxxxros2 launch road_net_route route_tool.launch.py yaml_filename:=map.yaml
- yaml_filename parameter is the grid map file path of the road network to be labeled
- (RDK mainboard) Only need to start rviz, visualization is started on the accompanying virtual machine
Rosmaster-RoadNet-Ubuntu24.04,
xxxxxxxxxx#Virtual machine siderviz2 -d /home/yahboom/code_ws/src/road_net_route/rviz/route_tool.rvizClick Load in the
Route Tooltab, then select the road network description file to be edited, and clickopento load


4.2 Edit Road Network
- If you need to add new waypoints and edges, the operation is the same as the previous steps
- Click
Editto re-edit information about existing waypoints or edges

- Click
Removeto remove existing waypoints or edges


