Welcome to MicroROS-Pi5 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
9. ROS Robot APP navigation
ROS Robot APP navigation
Note: The ROS_DOMAIN_ID of the Raspberry Pi and the microROS control board need to be consistent. You can check [MicroROS Control Board Parameter Configuration] to set the microROS control board ROS_DOMAIN_ID. Check the tutorial [Connect MicroROS Agent] to determine whether the IDs are consistent.
1、Program function description
The car connects to the agent, runs the program, and the mobile phone is connected to the car through a network. Open the [ROS Robot] app downloaded on your mobile phone, enter the IP address of the car, select ROS2, and click Connect to connect to the car. Select [Navigation], click [Set Initialization Point] on the App interface to set the starting pose of the car, click [Set Navigation Point] on the App interface, and set the target point of the car, and then the car will plan a path to move to that point.
2、Query car information
2.1、Start and connect to the agent
After the Raspberry Pi is successfully powered on, open the terminal and enter the following command to open the agent.
sh ~/start_agent_rpi5.sh

Press the reset button on the microROS control board and wait for the car to connect to the agent. The connection is successful as shown in the figure below.

2.2、Enter the car docker
Open another terminal and enter the following command to enter docker.
xxxxxxxxxxsh ros2_humble.sh
When the following interface appears, you have successfully entered docker, and you can now control the car through commands.

3、starting program
First, enter the following command in the terminal to start the car to process the underlying data program.
xxxxxxxxxxros2 launch yahboomcar_bringup yahboomcar_bringup_launch.py

Enter the following command in the terminal to start the APP navigation command.
xxxxxxxxxxros2 launch yahboomcar_nav navigation_dwb_app_launch.xml maps:=/root/yahboomcar_ws/src/yahboomcar_nav/maps/test1219.yaml
Load map parameters:maps:=/root/yahboomcar_ws/src/yahboomcar_nav/maps/test1219.yaml(Replaceable target map)
Enter the following command in the terminal to start the camera screen.
xxxxxxxxxxros2 launch usb_cam camera.launch.py
The mobile APP displays as shown below. Enter the IP address of the car. 【zh】means Chinese, 【en】means English. Select ROS2, select the first Video Tpoic below, and finally click [Connect]

After successful connection, the following screen will appear.

As shown in the figure below, select the navigation interface.

Then, combined with the actual pose of the car, click [Set Initialization Point] to give the car an initial target point. If the area scanned by the radar roughly coincides with the actual obstacle, it means the pose is accurate. As shown below,

Then, click [Set Navigation Point] and give the car a destination. The car will plan a path and follow the path to the destination.

4、Code analysis
Here is the description of the launch file that opens the APP navigation.
navigation_dwb_app_launch.xml
xxxxxxxxxx<launch <include file="$(find-pkg-share rosbridge_server)/launch/rosbridge_websocket_launch.xml"/> <node name="laserscan_to_point_publisher" pkg="laserscan_to_point_publisher" exec="laserscan_to_point_publisher"/> <include file="$(find-pkg-share yahboomcar_nav)/launch/navigation_dwb_launch.py"/> <include file="$(find-pkg-share robot_pose_publisher_ros2)/launch/robot_pose_publisher_launch.py"/></launch>The following are several launch files and Nodes:
- rosbridge_websocket_launch.xml:Open the rosbridge service-related nodes. After starting, you can connect to ROS through the network.
- laserscan_to_point_publisher:Publish the radar point cloud conversion to the APP for visualization
- navigation_dwb_launch.py:Navigation program
- robot_pose_publisher_launch.py:Car pose publishing program, the car pose is visualized in the APP