Welcome to ROSMASTER A1 PRO repository
15.Mobile App Mapping And Navigation
📱 Mobile APP Mapping and Navigation
1. Course Content
Master using the [ROSRobot] mobile APP on mobile terminals (Android / iOS) to wirelessly remote control the A1 Pro robot for real-time environment mapping, map saving and loading.
Master receiving real-time video stream, observing occupancy raster map and laser point cloud, calibrating initial pose via touch screen, and sending navigation goal points for autonomous cruising on the mobile APP.
2. Preparation
Install APP: Search and install
ROSRobotin the mobile app store (or scan the QR code in the manual to download and install).LAN Connection: Ensure the phone and robot are connected to the same WiFi LAN (or connect to the robot's hotspot WiFi), and record the robot's current IP address (can be viewed by executing
ifconfigin terminal).

3. Mobile APP Mapping Operation
3.1 Start Camera Video Streaming Node
Based on the camera type used, start the corresponding camera node in Terminal 1:
xxxxxxxxxx# If using depth camera:ros2 launch yahboomcar_depth camera_app.launch.py
# If using ordinary USB monocular / robotic arm camera:ros2 launch usb_cam camera.launch.py
3.2 Start APP Mapping Service (Choose One)
Run in Terminal 2 the APP mapping bridge node (this Launch automatically pulls up chassis driver, lidar, SLAM mapping node, Rosbridge WebSocket bridge, and APP map save service):
xxxxxxxxxx# Method A: Gmapping algorithm mapping (recommended)ros2 launch yahboomcar_nav map_gmapping_app_launch.xml
# Method B: Cartographer algorithm mappingros2 launch yahboomcar_nav map_cartographer_app_launch.xml
3.3 APP Connection and Mapping Operation
Connect to Robot: Open the
ROSRobotAPP on the phone, select mapping mode. Enter the robot's LAN IP address, keep the port as default9090, VideoTopic select/usb_cam/image_raw/compressed(if using Nuwa camera, select the corresponding compressed topic), and click 【Connect】.
Remote Control Mapping: After successful connection, the APP interface will display the real-time camera video feed and the raster map generated by the lidar. Use the virtual joystick in the lower-left corner to remote control the robot to move slowly and smoothly, gradually scanning and exploring the entire indoor environment.


Save Map: When the environment outline is completely closed, click the 【Save Map】 button in the upper-right corner of the APP interface, enter the map name (for example
test) in the popup, and click confirm.
View Saved Maps: The APP map save service will automatically call
map_saver_cliin the background to save the map file to the robot system path:xxxxxxxxxxls ~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/
4. Mobile APP Autonomous Navigation Operation
4.1 Start Chassis and Lidar
Run in Terminal 1 (start A1 Pro chassis driver and lidar):
xxxxxxxxxxros2 launch yahboomcar_nav laser_bringup_launch.py
4.2 Start Camera Video Streaming Node
Run in Terminal 2 the camera node:
xxxxxxxxxx# Nuwa camera:ros2 launch yahboomcar_depth camera_app.launch.py
# USB camera:ros2 launch usb_cam camera.launch.py 
4.3 Start APP Navigation Service
Run in Terminal 3 the navigation node:
xxxxxxxxxx#map:=The path needs to be modified according to the actual mainboardros2 launch yahboomcar_nav navigation_teb_app_launch.xml map:=/home/jetson/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/test.yaml
4.4 APP Navigation Operation
Connect to Robot: Open ROSRobot APP, select navigation mode, enter robot IP address and port
9090, VideoTopic select/usb_cam/image_raw/compressed, and click 【Connect】.
Enter Navigation Main Interface: After successful connection, the APP automatically loads the map and robot pose:

Set Initial Point (2D Pose Estimate): Click 【Set Initial Point】, click at the actual physical position of the robot on the phone's map screen and pull out the chassis heading arrow. Observe that the red/green scanning point cloud on the map coincides with the black obstacle contours, representing successful initial pose alignment.

Set Navigation Goal Point (2D Goal Pose): Click 【Set Navigation Point】, click in the traversable free area on the map and set the goal heading. The robot immediately plans an optimal global path, autonomously controls steering and forward movement, smoothly avoids obstacles, and arrives at the destination.

Note
When you need to end the program, press Ctrl+C in each terminal window to stop the program.
5. Core Source Code and Communication Configuration Analysis
5.1 APP Communication Bridge Architecture Analysis
The mobile APP achieves full-duplex communication with the ROS 2 system through standard WebSocket protocol:
rosbridge_websocket:Listens on port
9090, responsible for transparently forwarding ROS 2 topics, services, and mobile APP JSON messages in both directions.APP-published control commands are transformed into
/cmd_velto drive the chassis; APP-set pose points are transformed into/initialposeand/goal_poseand passed to Nav2.
robot_pose_publisher:Real-time listens to the
map -> base_footprintin the TF transformation tree, calculates the robot's absolute coordinates and heading in the global map, and high-frequency sends to the APP interface via/robot_posetopic to draw the robot icon.
laserscan_to_point_publisher:Converts lidar scan data into a compact point cloud format, providing real-time obstacle point cloud outline for APP rendering.
APP Navigation Launch Architecture Configuration (navigation_teb_app_launch.xml):
xxxxxxxxxx<launch> <!-- Start rosbridge websocket bridge service --> <include file="$(find-pkg-share rosbridge_server)/launch/rosbridge_websocket_launch.xml"/> <!-- Start lidar point cloud publishing node --> <node name="laserscan_to_point_publisher" pkg="laserscan_to_point_publisher" exec="laserscan_to_point_publish"/> <!-- Start TEB navigation core --> <include file="$(find-pkg-share yahboomcar_nav)/launch/nav2/navigation_teb_launch.py"/> <!-- Start robot map pose publishing node --> <include file="$(find-pkg-share robot_pose_publisher_ros2)/launch/robot_pose_publisher_launch.py"/></launch>5.2 APP Map Save Service Source Analysis
Source Code Path:
xxxxxxxxxx$HOME/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_app_save_map/yahboomcar_app_save_map/yahboom_app_save_map.py
xxxxxxxxxxclass MinimalService(Node):
def __init__(self): super().__init__('minimal_service') # Create ROS 2 service to receive APP map save requests self.srv = self.create_service(WebSaveMap, 'yahboomAppSaveMap', self.add_three_ints_callback) def run_shellcommand(self, *args): '''Execute shell command and run map_saver_cli in background''' args = sum([(arg if type(arg) == list else [arg]) for arg in args], []) possess = subprocess.Popen(args, stdout=subprocess.PIPE) return possess
def add_three_ints_callback(self, request, response): map_name = request.mapname workspace_src = Path.home() / 'yahboomcar_ros2_ws' / 'yahboomcar_ws' / 'src' map_path = str(workspace_src / 'yahboomcar_nav' / 'maps' / map_name) database_path = workspace_src / 'yahboomcar_app_save_map' / 'yahboomcar_app_save_map' / 'xgo.db' # Record map name and timestamp information into local SQLite database now = datetime.datetime.now() str_time = now.strftime("%Y-%m-%d %H:%M:%S.%f") map_id = hashlib.md5((str_time + map_name).encode()).hexdigest() response.response = request.mapname try: conn = sqlite3.connect(str(database_path)) c = conn.cursor() c.execute("INSERT INTO xgo_map (map_name, map_id, map_path) VALUES (?, ?, ?)", (map_name, map_id, map_path)) # Call Nav2 official map_saver_cli node to save .yaml and .pgm raster map self.run_shellcommand( 'ros2', 'run', 'nav2_map_server', 'map_saver_cli', '-f', map_path, '--ros-args', '-p', 'save_map_timeout:=10.0', '-p', 'map_subscribe_transient_local:=false', ) except sqlite3.IntegrityError as e: response.response = {"msg": str(e)} return response
self.get_logger().info('Map saved successfully: %s -> %s' % (map_name, map_path)) return responseThis node creates the
yahboomAppSaveMapservice (type isWebSaveMap). When the APP clicks Save Map, it sends a request with the map name; while writing map metadata to SQLite database, the node asynchronously callsnav2_map_server'smap_saver_clicommand-line tool to persistently save the current global occupancy raster map asmaps/<map_name>.yamlandmaps/<map_name>.pgm.
5.3 Core Communication Parameters and Port Description
| Communication Module | Service/Topic/Port | Default Config Value | Core Function Description |
|---|---|---|---|
| WebSocket | Listening port | 9090 | ROSBridge service port, handles APP JSON control commands and topic broadcast |
| Video Streaming | Compressed image topic | /usb_cam/image_raw/compressed | Low-latency compressed video stream provided to APP for rendering |
| Pose Publishing | Topic name | /robot_pose | Publishes robot's real-time position and attitude in global map coordinate frame |
| Point Cloud Publishing | Topic name | /scan_point | Lidar point cloud coordinate transformation publishing, used by APP to draw obstacle point cloud |
| Map Save | Service name | yahboomAppSaveMap | Receives map name sent by APP and calls map_saver_cli in background to save |