Welcome to ROSMASTER M1 PRO repository
16.Mobile App Mapping And Navigation
App Mapping and Navigation
App Mapping and Navigation1. Course Content2. Preparation4. App Mapping Case5. App Navigation Case6. Source Code Analysis
1. Course Content
Control the car's mapping and navigation through the mobile app 【ROS Robot】.
2. Preparation
Your phone needs to first download the
【ROS Robot】app. Android/iOS phone users, please scan the QR code to download the remote control software. iOS users can also search for and download the mapping and navigation app【ROSRobot】in the App Store.

Then the car and the phone must be on the same local area network; this can be achieved by connecting to the same Wi-Fi.
4. App Mapping Case
Enter the following command in the car's terminal to start the car's app mapping service node
xxxxxxxxxxros2 launch yahboomcar_bringup bringup_app.launch.py
Open
【ROS Robot】, which displays as shown belowEnter the car's IP address ——>
ROS2——>VideoTopic/camera/rgb/image_raw/compressed——> 【Connect】

After successfully connecting, it displays as follows

Use the sliding wheel to control the car to slowly move through the area to be mapped, then click Save Map, enter a map name and click Submit to save the map

The map will be automatically saved in the system's
~/mapdirectory, and the terminal will indicate that the map was saved successfully

5. App Navigation Case
xxxxxxxxxxros2 launch yahboomcar_bringup bringup_app.launch.py navigation_mode:=True Note
Optional parameter description
map_file
Map file path; here the map yaml name is required; the default value is
map.yaml
Open
【ROS Robot】, which displays as shown belowEnter the car's IP address ——>
ROS2——>VideoTopic/camera/rgb/image_raw/compressed——> 【Connect】

As shown below, select the navigation interface:

Then, based on the car's actual pose, click 【Set Initial Pose】 to give the car an initial pose. If the area scanned by the LiDAR roughly overlaps with the actual obstacle, it means the pose is accurate. As shown below,

Click 【Set Navigation Point】 to give the car a destination; the car will plan a path and move to the destination along the path. As shown below:

6. Source Code Analysis
Launch and backend service source code paths:
xxxxxxxxxx~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_bringup/launch/bringup_app.launch.py
xxxxxxxxxx~/yahboomcar_ros2_ws/yahboomcar_ws/src/ros_robot_app/ros_robot_app/
The key startup program is as follows:
The program uses the two launch parameters slam_mode and navigation_mode to decide between the two startup modes of mapping or navigation, and starts the rosbridge WebSocket server to transmit relevant data through the WebSocket protocol.
slam_mode=LaunchConfiguration('slam_mode', default="slam_toolbox") navigation_mode=LaunchConfiguration('navigation_mode', default="False")
#gmapping gmapping_launch=IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(yahboomcar_bringup_dir, 'launch', 'gmapping.launch.py')), launch_arguments={ "rviz": "False", }.items(), condition=IfCondition(PythonExpression(["'", slam_mode, "' == 'gmapping' and '", navigation_mode, "' == 'False' "])) ) #slam_toolbox slam_toolbox_launch=IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(yahboomcar_bringup_dir, 'launch', 'slam_toolbox.launch.py')), launch_arguments={ "rviz": "False", }.items(), condition=IfCondition(PythonExpression(["'", slam_mode, "' == 'slam_toolbox' and '", navigation_mode, "' == 'False' "])) )
#Start Cartographer mapping mode. cartographer_launch=IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(yahboomcar_bringup_dir, 'launch', 'cartographer.launch.py')), launch_arguments={ "rviz": "False", }.items(), condition=IfCondition(PythonExpression(["'", slam_mode, "' == 'cartographer' and '", navigation_mode, "' == 'False' "])) )
#Start the rosbridge node. bringup_rosbridge_server = ExecuteProcess( cmd=['ros2', 'launch', 'rosbridge_server', 'rosbridge_websocket_launch.xml'], output='screen' )
transmission_node = Node( package='ros_robot_app', executable='transmission', name='transmission', parameters=[ {'rgb_topic': GetCameraRgbTopic()}, {'flip_laser_points': flip_laser_points} ], output='screen', )
#Robot pose publishing node robot_pose_publisher=Node( package="ros_robot_app", executable="robot_pose_publisher", name="robot_pose_publisher", output="screen", parameters=[ {"use_sim_time": False}, {"is_stamped": True}, {"map_frame": "map"}, {"base_frame": "base_link"} ] ) #App map saving service node app_save_map_node = Node( package='ros_robot_app', executable="app_save_map", name="app_save_map", output="screen", )
app_nav= IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(yahboomcar_bringup_dir, "launch", 'nav2.launch.py')), launch_arguments={ "map": LaunchConfiguration("map_file"), "rviz": "False", "localization_mode": "amcl", "slam": "False", }.items(), condition=IfCondition(PythonExpression(["'", navigation_mode, "' == 'True'" ])) )
return LaunchDescription([ *declared_arguments, bringup_camera, app_nav, #app navigation node bringup_rosbridge_server, #rosbridge transmission_node, #publish rgb image and laser scan point robot_pose_publisher, #robot pose publishing node gmapping_launch, #gmapping slam slam_toolbox_launch, #slam_toolbox slam cartographer_launch, #cartographer slam app_save_map_node ])