Welcome to MicroROS-Pi5 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
8. ROS Robot APP mapping
ROS Robot App mapping
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, opens the [ROS Robot] app downloaded on the mobile phone, enters the IP address of the car, selects ROS2, and clicks connect to connect to the car. You can control the car by sliding the wheel on the interface, and slowly control the car to complete the mapped area. Finally, click Save Map, and the car will save the currently constructed map.
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. Now you can control the car through commands.

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

Then, start rviz visual mapping. You need to enter the same docker terminal before entering this command. The steps are as follows:
Reopen a new terminal in the Raspberry Pi and enter the command,
xxxxxxxxxxdocker ps -a
You can enter the same docker based on this ID number. Note that the ID number is different every time you enter the docker. Enter the command.

You can enter the same docker based on this ID number. Note that the ID number is different every time you enter the docker. Enter the command.
xxxxxxxxxxdocker exec -it ef0e1b7da319 /bin/bash

When this screen appears, we have entered the same docker. Then start mapping,
xxxxxxxxxx#Choose one of the following drawingsros2 launch yahboomcar_nav map_gmapping_app_launch.xmlros2 launch yahboomcar_nav map_cartographer_app_launch.xml
Start the camera screen..(You need to enter the same docker terminal as above),
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 is displayed:

Use the sliding wheel to control the car to move slowly through the area that needs to be mapped, then click to save the map, enter the map name and click submit to save the map.

The location where the map is saved is as follows.
xxxxxxxxxx/root/yahboomcar_ws/src/yahboomcar_nav/maps
4、Code analysis
Here is an explanation of the launch file that opens the APP mapping, taking gmapping mapping as an example.
map_gmapping_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/map_gmapping_launch.py"/> <include file="$(find-pkg-share robot_pose_publisher_ros2)/launch/robot_pose_publisher_launch.py"/> <include file="$(find-pkg-share yahboom_app_save_map)/yahboom_app_save_map.launch.py"/></launch>The following launch files and nodes are run here:
- 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
- map_gmapping_launch.py:gmapping mapping program
- robot_pose_publisher_launch.py:Car pose publishing program, the car pose is visualized in the APP
- yahboom_app_save_map.launch.py:Program to save maps.