Welcome to MicroROS Self-balancing Car repository
10.ROS Robot APP navigation
ROS Robot APP Navigation
Note: The virtual machine needs to be in the same LAN as the car, and the ROS_DOMAIN_ID needs to be the same. You can check [Must-Read Before Use] to set the IP and ROS_DOMAIN_ID on the board.
1. Program Function Description
The car connects to the proxy, runs the program, and the mobile phone and the car are connected through a network. Open the [ROS Robot] app downloaded on the phone, enter the IP address of the car, select ROS2, click Connect, and you can connect to the car. Select [Navigation], click [Set Initialization Point] on the App interface to set the car's starting position, click [Set Navigation Point] on the App interface, give the car a target point, and then the car will plan a path to move to that point.
2. Start and connect the agent
Take the supporting virtual machine as an example, enter the following command to start the agent,
#Car agentsudo docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:humble udp4 --port 8899 -v4#Camera agent (start the agent first and then turn on the car switch)docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:humble udp4 --port 9999 -v4 
Then, turn on the car switch and wait for the car to connect to the proxy. The connection is successful as shown in the figure below.

Camera proxy, the connection is successful as shown in the figure below.

3. Start the program
First, start the car to process the underlying data program, and enter the terminal.
xxxxxxxxxxros2 launch yahboomcar_bringup yahboomcar_bringup_launch.py mode:=navxxxxxxxxxx#Parameter description, adjust the speed of the car, the mode is navigation modemode:=nav
Start APP navigation command, terminal input,
Navigation two choices
1. Ordinary version navigation:
xxxxxxxxxxros2 launch yahboomcar_nav navigation_dwb_app_launch.xml maps:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.yamlLoad map parameters: maps:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.yaml (replaceable target map)
2. Fast relocation version navigation:
Start fast relocation,
Note: The .pbstream map file used in this navigation version requires the map to be saved in advance. Refer to the cartograph map construction algorithm tutorial
xxxxxxxxxxros2 launch yahboomcar_nav localization_imu_odom.launch.py use_rviz:=false load_state_filename:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.pbstreamxxxxxxxxxxros2 launch yahboomcar_nav navigation_cartodwb_app_launch.xml maps:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.yamlStart the camera display command, input in the terminal,
xxxxxxxxxx#Start ESP32 cameraros2 run yahboom_esp32_camera sub_imgThe mobile phone APP displays the following figure, enter the IP address of the car, [zh] means Chinese, [en] means English; select ROS2, select the Video Tpoic below: /usb_cam/image_raw/compressed, and finally click [Connect]

After successfully connecting, the display is as follows,

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

Then, combined with the actual position 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 that the position is accurate. As shown in the figure below,

Then, click [Set navigation point], give the car a destination, the car will plan a path and move to the destination according to the path.
4. Code analysis
Here is the launch file for opening 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 launch files and nodes are run here:
rosbridge_websocket_launch.xml: Open the rosbridge service related nodes. After startup, you can connect to ROS through the network
laserscan_to_point_publisher: Publish the point cloud conversion of the radar 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
The launch file for APP fast repositioning navigation, navigation_cartodwb_app_launch.xml, is similar.