Multi-car Navigation2 fast relocation navigation

Note: The virtual machine needs to be in the same LAN as the car, and the ROS_DOMAIN_ID needs to be consistent. You can check [Must-read before use] to set the IP and ROS_DOMAIN_ID on the board.

1. Program function description

After the program is started, you can give the target points of the two cars in rviz. After receiving the command, the two cars will calculate the path based on their own posture and move to their destinations.

2. Basic settings for multi-machine functions

Take two cars as an example. It is recommended to use two computers with matching virtual machines, change the config_robot.py files respectively, set robot.set_ros_namespace() to robot1 and robot2 respectively; set robot.set_udp_config() to the IP addresses of the two virtual machines respectively, and the ROS_DOMAIN_ID of the two cars and the ROS_DOMAIN_ID of the virtual machine need to be set to the same. Then open the terminal in the /home/yahboom directory, enter sudo python3 config_Balance_Car.py to run this program (the rest of the programs other than running multiple cars need to be changed back and re-run this program).

image-20250108211224464

3. Start and connect the agent

Take the matching virtual machine as an example. In the two virtual machines, enter the following command to start the agent of each car.

image-20241226101427280

Then, turn on the switches of the two cars and wait for the two cars to connect to their respective agents. If the connection is successful, the terminal display is as shown in the figure below.

image-20241226101559446

Check the currently started node. In the two virtual machines, randomly select one and open the terminal to enter,

image-20250108211845321

As shown in the figure above, the nodes of both cars have been started. Query the current topic information, input in the terminal,

image-20250108211908765

4. Load the map program

Select one of the two virtual machines at random, open the terminal and input,

Parameter description

Note: Here, yahboom_map.yaml and yahboom_map.pbstream must be built at the same time, that is, the same map, refer to cartograph mapping algorithm to save the map

image-20250109093220837

Note: Lifecycle error may occur here, which is caused by the map not being built.

Take the virtual machine as an example, the map loaded here is,

If you need to modify the default loading of other maps, copy the map's yaml file and pgm file to the

/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/ directory, and then modify the map_server_launch.py ​​program, which is located in /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch, and modify the following places,

image-20250108214656797

Replace the red box with the name of your own map, save and exit, then enter the following command to compile,

Then enter the following command to re-source the environment variable,

5. Start the car's underlying data processing program

In the virtual machine terminal that starts robot1,

In the virtual machine terminal that starts robot2,

image-20250109093335957

yahboomcar_bringup_multi.launch.xml source code path (taking the matching virtual machine as an example),

Here, a pair of tags are used. The command space of all programs in this tag will be robot_name, which is the robot1 or robot2 we defined. Among them, there are some parameter files or topic names, which are also automatically selected and loaded through this robot_name. You can view the content in the code for details.

6. Start the fast relocation program and rviz of the car

Input in the virtual machine terminal that starts robot1, and you can choose any rviz to start.

Parameter Description

In the terminal of the virtual machine that starts robot2, enter,

Parameter description

Note: The testaa.pbstream map of robot1 and robot2 must be the same map

image-20250109101707884

When it prints (pulsed at 101.80% real time)...etc., it proves that the startup is normal

You can see that the map is loaded, but the positioning of the car is not accurate, then we click [2D Pose Estimate】, give the two cars an initial pose respectively. According to the approximate position of the car in the actual environment, click and drag with the mouse in rviz, and the car can be quickly positioned on the map.

image-20250109093755086

Red represents robot1 and blue represents robot2.

The functions of the symbols in Figures 1-4 above are as follows:

[1]: robot1 calibrates the initial pose

[2]: robot1 gives the target point

[3]: robot2 calibrates the initial pose

[4]: robot2 gives the target point

Note: If positioning is still not possible, it may be that the car is in an obstacle area. Please place it in a place with no obstacles around and start again. You can also keep the terminal open, restart the car directly, and wait for the automatic data recovery to re-position it. It may also be that there are too few map feature points when building the map, and the map construction must be more detailed.

As shown in the figure below, if the area scanned by the radar roughly coincides with the actual obstacle, it means that the posture is accurate.

image-20250109094715062

Take the virtual machine as an example, the source code location: /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch

robot1_localization_imu_odom.launch.py

The following nodes are started here:

7. Start the car navigation program

In the virtual machine terminal that starts robot1, enter,

In the virtual machine terminal that starts robot2, enter,

image-20240102204838255

As shown in the figure above, the "Creating bond timer..." appears, indicating that the program is loaded. Then, the corresponding [2D Goal Pose] on riviz can be used to give the target points of the two cars. The cars will generate a path based on their respective postures and surrounding obstacles, and autonomously navigate to their respective destinations.

image-20240102205740408

The yellow route is the route planned by robot1, and the green line is the route planned by robot2.

image-20250109095155649

8. Multi-car navigation expansion

The tutorial takes two cars as an example. If you want to add other cars, you need to make the following modifications.

8.1. Add a URDF model of the car and add a urdf model loader

Note: The path is,

For reference, /home/yahboom/yahboomcar_ws/src/yahboomcar_description/urdf/STM32-V2-V1_robot1.urdf

Change the name and robot1 in the urdf file to other car names, such as robot3.

For reference, /home/yahboom/yahboomcar_ws/src/yahboomcar_description/launch/description_multi_robot1.launch.py Change the name and robot1 in the launch file to other car names. The name needs to be consistent with the newly added urdf.

8.2, Added car ekf parameter table

Note: The path is,

You can refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/ekf_robot1.yaml, change the name and robot1 in the file to other car names, and the name needs to be consistent with the newly added urdf.

8.3, Added launch file for starting positioning

Note: The path is:

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_localization_imu_odom.launch.py, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

8.4, Added car nav2 parameter table and launch file for starting nav2

Note: The path is:

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/robot1_nav_params.yaml, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_navigation_dwb_launch.py, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

8.5, Added [2D Pose Estimate] and [2D Goal Pose] in the rviz toolbar

Note: The path is:

Modify the multi_nav.rviz file, the directory of the file is /home/yahboom/yahboomcar_ws/src/yahboomcar_nav/rviz/multi_nav.rviz, find the following part,

The above are two tools for robot1. You can copy one and put it behind. Change the robot1 that appears to the name of other cars. The name needs to be consistent with the newly added urdf.

After completing the above 5 steps, return to the yahboomcar_ws workspace, compile it using colcon build, and then run the test according to the tutorial. After successful operation, you can add the car model and radar data to display in rviz.