yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
ROSMASTER M3 PRO📖
0.Configuration and Operation Guide
  • 1. Quick start handle to control the car
  • 2. Log in to the car and view the code
  • 3. Robotic Arm Calibration
  • 4. Enter the Docker (Jetson-Nano and Raspberry Pi 5 users, see here)
  • 5. Assembly video
  • 6. Modify the firmware parameters of the car control board
  • 7. Frequently Asked Questions and Precautions
  • 8. Precautions for DIY Robotic Arm
1.Chassis Control Course
  • 1.ROS control
  • 2.Handle control
  • 3.Keyboard control
  • 4.Angular velocity calibration
  • 5.Line velocity calibration
  • 6.Line patrol automatic driving
  • 7.Patrol
2.Lidar Course
  • 1.Lidar introduction and use
  • 2.Dual Lidar fusion
  • 3.Lidar obstacle avoidance
  • 4.Lidar tracking
  • 5.Lidar guard
  • 6.Gmapping-SLAM mapping
  • 7.Cartographer-SLAM mapping
  • 8.slam_toolbox mapping
  • 9.Navigation2 single-point navigation avoid
  • 10.Navigation2 multi-point navigation avoid
  • 11.Repositioning navigation
  • 12.RTAB-Map mapping
  • 13.RTAB-Map navigation
  • 14.APP mapping navigation
  • 15.Machine code handling
  • 16.Color block transport
  • 17.Navigation via Pose-Constrained Visual Relocalizationnew
3.Depth Camera Course
  • 1.Dabai_DCW2 camera introduction
  • 2.Depth pseudo-color image
  • 3.Depth camera distance measurement
  • 4.Wood block volume measurement
  • 5.Mediapipe gesture recognition
  • 6.Edge detection
  • 7.YOLOv8 object detection
  • 8.Deep learning object tracking
  • 9. Transformer Model Tracking Algorithmnew
4.Robotic Arm and 3D Space Gripping Course
  • 1.Robotic arm solution
  • 2.Robotic arm chassis linkage control
  • 3.Machine code ID sorting
  • 4.Sorting height abnormality machine code
  • 5.Tracking and gripping machine code
  • 6.Color block color sorting
  • 7.Sorting height abnormality color block
  • 8.Tracking and gripping color block
  • 9.Wood block shape sorting
  • 10.KCF tracking and gripping objects
  • 11.Medipipe gesture ID sorting machine code
  • 12.Mediapipe gesture height sorting machine code
  • 13.Desktop tracking and gripping machine code
  • 14.3D tracking machine code
  • 15.Line patrol and obstacle removal
5.Road network planning and navigationnew
  • 1. Introduction To Road Network Planning
  • 2. Build A Pose Map
  • 3. Road Network Annotation
  • 4. Planning And Navigation Between Waypoints
  • 5. Road Network Navigation In Any Pose
  • 6. Path Re-planning
6.OpenClaw Basic Coursenew
  • 1. Introduction to OpenClaw
  • 2. OpenClaw Core Concepts
  • 3. OpenClaw API-KEY Configuration
  • 4. OpenClaw Switch Models
  • 5. OpenClaw System Prompt Words
  • 6. OpenClaw Common CLI Commands
7.OpenClaw Interaction Methodnew
  • 1. OpenClaw Webchat Interaction
  • 2. OpenClaw Tui Interaction
  • 3. OpenClaw Voice Dialogue Interaction
  • 4. OpenClaw WhatsApp Interaction
8.OpenClaw Developmentnew
  • 1. OpenClaw connects to the MCP interface of the robot
  • 2. Robot CLI Command Tool
  • 3. Robot control plugin tool
  • 4. Reply bridge plugin tool
  • 5. OpenClaw multimodal vision
  • 6. OpenClaw chassis control
  • 7. OpenClaw robotic arm control
  • 8. OpenClaw skills development
  • 9. OpenClaw timed tasks
  • 10. OpenClaw multi-agent intelligent agent
  • 11. OpenClaw active interaction
  • 12. OpenClaw vector memory
9.OpenClaw Embodied intelligent applicationnew
  • 1. OpenClaw target tracking
  • 2. OpenClaw robotic arm tracking and grasping
  • 3. OpenClaw robotic arm fixed-point placement
  • 4. OpenClaw garbage sorting
  • 5. OpenClaw slam mapping and navigation
  • 6. OpenClaw navigation transfer
  • 7. OpenClaw machine code clip
  • 8. OpenClaw color line patrol
  • 9. OpenClaw visual distance measurement
10.OpenClaw scenario sandboxnew
  • 1. Map description and prop placement
  • 2. Build sand table map
  • 3. Visual relocation markers
  • 4. Map mapping markers
  • 5. OpenClaw scenario sandbox comprehensive case
11.AI Model Basics
  • 1.AI large model types and principles
  • 2.RAG retrieval enhancement and model training samples
  • 3.Embodied intelligent robot system architecture
  • 4.Embodied intelligent functions core source code
12.AI Model Development
  • 01.Register a model service provider account
  • 02. Configuring API-KEY
  • 03. Introduction to Dify
  • 04. Basic Dify Features
  • 05. AI Large Model Development - chatbot
  • 06. Deploy the RAG knowledge base
  • 07. RAG knowledge base + chatbot
  • 08. AI agent workflow
  • 09. Custom wake-up response
  • 10. Core module testing tools
13.AI Large Model (Text Version)
  • 1.Semantic understand instruction following
  • 2.Multimodal visual understand
  • 3.Multimodal visual understand+robotic arm grab
  • 4.Multimodal visual understand+SLAM navigation
  • 5.Robotic arm grab+Multimodal visual understand+SLAM navigation
  • 6.Intention estimation
14.AI Large Model(Voice Version)
  • 1.Semantic understand instruction following
  • 2.Multimodal visual understand
  • 3.Multimodal visual understand+robotic arm grab
  • 4.Multimodal visual understand+SLAM navigation
  • 5.Robotic arm grab+Multimodal visual understand+SLAM navigation
  • 6.Intention estimation
15.Mediapipe Visual Course
  • 1.Hand detection
  • 2.Posture detection
  • 3.Overall detection
  • 4.Facial Landmark Detection
  • 5.Face detection
  • 6.Face special effects
  • 7.3D object recognition
  • 8.Brush
  • 9.Finger control
  • 10.Palm target positioning
  • 11.Fingertip trajectory recognition
  • 12.Fingertip gesture control robotic arm
  • 13.Gesture grabbing and releasing objects
  • 14.Finger control robotic arm
  • 15.Medipipe gesture control robotic arm action group
16.MoveIt2 Simulation Course
  • 1.MovelT2 configuration
  • 2.MovelT2 simulation-reality linkage
  • 3.Random movement
  • 4.Forward kinematics design
  • 5.Inverse kinematics design
  • 6.Cartesian path
  • 7.Trajectory planning
  • 8.Collision detection
  • 9.Scene design
17.Multi-vehicle Course
  • 1.Multi-vehicle chassis control
  • 2.Multi-vehicle robotic arm control
  • 3.Multi-vehicle navigation
  • 4.Multi-vehicle formation
18.Control Board Course
  • 1.Development environment setup
  • 2.Control board STM32 basic routine
  • 3.Control board micro_ros basic routine
19.Docker Course
  • 1、Docker overview and docker installation
  • 2、Common commands for docker image containers
  • 3、Docker images deeply understand and publish images
  • 4、Docker hardware interaction and data processing
  • 5、Enter the bot's docker container
  • 6、Robot development environment construction in Docker
20.Image Processing Basics Course
  • 1. Introduction to Open Source CV
  • 2. Image reading and display
  • 3. Image writing
  • 4. Image quality
  • 5. Pixel Operation
  • 6. Image zoom
  • 7. Image cutting
  • 8. Image translation
  • 9. Image Mirroring
  • 10. Affine Transformation
  • 11. Image Rotation
  • 12. Perspective Transformation
  • 13. Grayscale processing
  • 14. Image Binarization
  • 15. Edge Detection
  • 16. Line drawing
  • 17. Rectangle and circle drawing
  • 18. Drawing text and pictures
21.Main Control Course
Jetson Nano B01
  • 1. Introduction to the Jetson Nano B01 SUB Board
  • 2. Burn the system image
  • 3. Re-read the memory card or USB drive that has been burned
  • 4. Startup system
  • 5. Jetson Nano B01 System and Desktop Introduction
  • 6. Memory card or USB flash drive expansion
  • 7. Network Configuration
  • 8. SSH remote login & file transfer
  • 9. VNC Remote Login
  • 10. Jetson Nano B01 system backup
  • 11. Jetson Nano Swap space increased
  • 12. Installation and use of Jtop
Jetson Orin Nano_NX
  • 1.Jetson Orin board introduction
  • 2.Restore the factory image system
  • 3.Backup SSD system
  • 4.SSD expansion
  • 5.Network configuration
  • 6.SSH remote login
  • 7.VNC remote control
  • 8.Remote file transfer
  • 9.Jtop tool
  • 10.Exchange space expansion
Raspberry Pi
  • 1. Introduction to Raspberry PI 5
  • 2. Raspberry PI system installation and backup
  • 3. Powering the Raspberry PI 5
  • 4. Startup of Raspberry PI 5
  • 5. Update and upgrade operating system
  • 6. Introduction to raspi-config tool
  • 7. config.txt file description
  • 8. Network Configuration
  • 9. remote access
  • 10. Transfer files remotely
  • 11. Set display resolution and rotation
  • 12. Set screen to sleep
  • 13. Play audio and video
  • 14. Using USB camera
  • 15. Using MIPI camera
  • 16. Get real-time temperature of Raspberry Pi
22.Linux System Course
  • 1.Introduction to Linux system
  • 2.Ubuntu file system
  • 3.Ubuntu common commands
  • 4.Ubuntu common editors
  • 5.Ubuntu software operation commands
  • 6.Virtual machine installation
  • 7.SSH remote control
  • 8.VNC remote control
  • 9.Transfer files remotely
  • 10.Driver library and communication
  • 11.Static IP and hotspot mode
  • 12.Bind device ID
  • 13.Capacity expansion and resource allocation
  • 14.Update system software sources
  • 15.Set root user password
  • 16.sudo free password
  • 17.Connect to WiFi network
  • 18.View system version
  • 19.Customized service management
  • 20.Back up system image
23.ROS2 Basic Course
  • 1.Introduction to ROS2
  • 2.ROS2 install Humble
  • 3.ROS2 development environment
  • 4.ROS2 workspace
  • 5.ROS2 function package
  • 6.ROS2 node
  • 7.ROS2 topic communication
  • 8.ROS2 service communication
  • 9.ROS2 action communication
  • 10.ROS2 custom interface message
  • 11.ROS2 parameter service case
  • 12.ROS2 meta-function package
  • 13.ROS2 distributed communication
  • 14.ROS2 DDS
  • 15.ROS2 time related API
  • 16.ROS2 common command tools
  • 17.ROS2 rviz2 use
  • 18.ROS2 rqt toolbox
  • 19.ROS2 Launch startup file configuration
  • 20.ROS2 recording and playback tool
  • 21.ROS2 URDF model
  • 22.ROS2 Gazebo simulation platform
  • 23.ROS2 TF2 coordinate transformation
Download
  • Mapping_APP(iOS_Android)
  • Robot_Image_System_File
  • Code-Firmware
  • Instruction_Manual
  • VM_File
  • Software_Tools
  • Firmware_DriverFile
  • 3D_Model_File
  • ROS2_Basic_VM
  • Other_Annex
Download ZIP

Welcome to ROSMASTER M3 PRO repository

5. OpenClaw slam mapping and navigation

OpenClaw Slam Mapping And Navigation

OpenClaw Slam Mapping And Navigation1. Course ContentLearning Objectives2. Preparation3. Record Map Mapping File4. OpenClaw Intelligent Navigation5. Source Code Analysis5.1 Navigation — Navigation Function5.2 PreciseAdjustPosition — Precise Position Adjustment6. Parameter Tuning6.1 Navigation Mode Switching Parameters6.2 Precision Adjustment PID Parameters

1. Course Content

Learning Objectives

  • Learn to use the RecordMapLocation tool to record map mapping files and establish the correspondence between place names and coordinates
  • Understand the switching logic between Road Network Navigation and normal navigation (Nav2)
  • Master the PID control principle and parameter tuning method of PreciseAdjustPosition
  • Understand the application of visual relocalization (ArUco Tag) in improving navigation accuracy

2. Preparation

[!IMPORTANT]

  • OpenClaw controlled navigation requires building a grid map, pose map, and annotated road network file first. For details, refer to the tutorial [Road Network Planning Navigation - Building Pose Maps and Road Network Annotation]
  • If you need to use the visual relocalization function, you also need to annotate the global position of ArUco markers on the map. For detailed operations, refer to the tutorial [Lidar - Pose Constraint Combined with Visual Relocalization Navigation] or [OpenClaw Open Transfer Sandbox Map - Visual Relocalization Markers]
  • Start the road network container
xxxxxxxxxx
roadnet start
  • Start the MicroROS chassis agent (no need to restart if already started)
xxxxxxxxxx
sh start_agent.sh

image-20260506153635990

  • Start odometry, tf, robotic arm assistance, camera nodes, etc. If you need to enable visual relocalization, add the startup parameter relocation:=True
  • Start with relocalization (start from host)
xxxxxxxxxx
ros2 launch m3pro_bringup car_base.launch.py relocation:=True
  • Start road network navigation (start inside roadnet container)
xxxxxxxxxx
roadnet bash #enter roadnet container terminal
xxxxxxxxxx
ros2 launch road_net_route roadnet_nav2.launch.py rviz_config_file:=/root/volumes/code_ws/src/road_net_route/rviz/nav2_relocaton.rviz
  • Start the MCP service
xxxxxxxxxx
ros2 launch m3pro_bringup mcp_service.launch.py

image-20260506153646571

  • If you need voice reply, you need to start openclaw_bridge additionally, otherwise it can be omitted
xxxxxxxxxx
ros2 run multi_brains_pre openclaw_bridge

 

3. Record Map Mapping File

[!TIP]

  • You can use the robot_control CLI tool or directly ask OpenClaw to record positions and symbols during interaction. The demonstration below uses the CLI tool to record the map mapping file as an example.
ToolParametersFunction
RecordMapLocation--name, --symbolSave current position to map mapping file

 

  • You can use the robot_control CLI tool to record the position of the vehicle's base_link in the map frame
xxxxxxxxxx
robot_control call-tool RecordMapLocation --name "Shipping Area" --symbol B
  • --name specifies the name of the recorded point
  • --symbol specifies the symbol of the recorded point, making it easier for OpenClaw to identify and distinguish

image-20260506201636024

  • If recording is successful, the above content is displayed. If the map mapping file already contains a symbol with the same name, the previous symbol content is automatically overwritten.

image-20260506201724132

 

  • View the map mapping file map_mapping.yaml, file path:
xxxxxxxxxx
$HOME/M3Pro_ws/src/m3pro_bringup/config/map_mapping.yaml
  • View map_mapping.yaml to see the just-recorded location

image-20260506202508066

 

 

4. OpenClaw Intelligent Navigation

[!TIP]

  • You can write commands according to your own needs. The following is a case demonstration. Choose any interaction method. Here we take the web-based WebChat as an example.
  • Navigation function tools
ToolParametersFunction
GetMapMappingNoneGet the mapping relationship of all place names and their corresponding identifiers
Navigation--locationNavigate to the target location by target point identifier
  • Navigate to the Shipping Area. image-20260506203450670

 

5. Source Code Analysis

  • Source path
xxxxxxxxxx
$HOME/M3Pro_ws/src/multi_brains_pre/multi_brains_pre/action_controller.py

5.1 Navigation — Navigation Function

Function Description: Looks up the corresponding coordinates from the map mapping file based on the target location name, then selects the appropriate navigation mode (normal navigation or road network navigation) to execute the navigation task, and performs precise position adjustment after arrival.

xxxxxxxxxx
def Navigation(self, location: str) -> list[bool,str]:
    '''Use road network navigation'''
    location = location.strip("'\"")
    try:
        with open(self.map_mapping_file, 'r', encoding='utf-8') as file:
            map_data = yaml.safe_load(file) or {}
​
        target_data = None
        for symbol, data in map_data.items():
            if symbol == location or (isinstance(data, dict) and data.get('name') == location):
                target_data = data
                break
        if target_data is None:
            error_info = f"The map mapping file has no coordinate record for '{location}'."
            self.get_logger().error(error_info)
            return [False,error_info]
    except Exception as e:
        self.get_logger().error(str(e))
        return [False,str(e)]
​
    goal_msg = PoseStamped()
    goal_msg.header.frame_id = "map"
    goal_msg.header.stamp = self.get_clock().now().to_msg()
​
    position = target_data.get('position', {})
    goal_msg.pose.position.x = float(position.get('x', 0.0))
    goal_msg.pose.position.y = float(position.get('y', 0.0))
    goal_msg.pose.position.z = float(position.get('z', 0.0))
​
    orientation = target_data.get('orientation', {})
    goal_msg.pose.orientation.x = float(orientation.get('x', 0.0))
    goal_msg.pose.orientation.y = float(orientation.get('y', 0.0))
    goal_msg.pose.orientation.z = float(orientation.get('z', 0.0))
    goal_msg.pose.orientation.w = float(orientation.get('w', 1.0))
​
    #calculate distance to target
    current_pose = self._get_current_map_pose()
    if current_pose is None:
        self.get_logger().error(Fore.RED + "Failed to get current pose" + Fore.RESET)
        return [False, "Failed to get current pose"]
    distance=math.sqrt((current_pose.transform.translation.x - goal_msg.pose.position.x) ** 2 +
                        (current_pose.transform.translation.y - goal_msg.pose.position.y) ** 2)
​
    if distance < self.nav_mode_threshold:
        #use common navigation
​
        if not self.nav_to_pose_client.wait_for_server(timeout_sec=10.0):
            return [False, "Nav2 action server not available"]
        goal = NavigateToPose.Goal()
        goal.pose.header.frame_id = "map"
        goal.pose.header.stamp = self.get_clock().now().to_msg()
        goal.pose.pose.position.x = float(position.get('x', 0.0))
        goal.pose.pose.position.y = float(position.get('y', 0.0))
        goal.pose.pose.position.z = float(position.get('z', 0.0))
        goal.pose.pose.orientation.x = float(orientation.get('x', 0.0))
        goal.pose.pose.orientation.y = float(orientation.get('y', 0.0))
        goal.pose.pose.orientation.z = float(orientation.get('z', 0.0))
        goal.pose.pose.orientation.w = float(orientation.get('w', 1.0))
​
        send_goal_future = self.nav_to_pose_client.send_goal_async(goal)
        while rclpy.ok() and not send_goal_future.done():
            time.sleep(0.1)
​
        if not send_goal_future.done():
            return [False, "Failed to send navigation goal"]
​
        goal_handle = send_goal_future.result()
        if not goal_handle.accepted:
            return [False, "Navigation goal rejected"]
​
        result_future = goal_handle.get_result_async()
​
        while rclpy.ok() and not result_future.done():
            time.sleep(0.1)
​
        if result_future.done():
            result = result_future.result().result
            time.sleep(3.0)#TODO: why do this? wait for camera to stabilize after navigation
            self._control_aritag_detect(sign='enable')                
            time.sleep(3.0)
            self.PreciseAdjustPosition(goal_msg)
            self._control_aritag_detect(sign='disable')# disable aritag detection,decrease CPU usage
            return [True, "Navigation succeeded"]
        else:
            self._control_aritag_detect(sign='disable')# disable aritag detection
            return [False, "Navigation failed"]
​
    else:  
        #use road network navigation
        self.road_net_nav_future = Future()
        self.road_net_nav_pub.publish(goal_msg)
        while not self.road_net_nav_future.done() and rclpy.ok():
            time.sleep(0.1)
        result= self.road_net_nav_future.result()
        if result.data == "road_net_nav_succeeded":
            time.sleep(3.0)#TODO: why do this? wait for camera to stabilize after navigation
            self._control_aritag_detect(sign='enable')#TODO: why do this?  aritag detection causes high CPU usage; enable detection only during PreciseAdjustPosition
            time.sleep(5.0)
            self.PreciseAdjustPosition(goal_msg)
            self._control_aritag_detect(sign='disable')# disable aritag detection,decrease CPU usage
            return [True, result.data]
        else:
            self.get_logger().warn(Fore.YELLOW+f"Navigation to '{location}' failed "+Fore.RESET)
            self._control_aritag_detect(sign='disable')# disable aritag detection
            return [False, result.data]

Process Description:

  1. Parse Target Location: Clean the input location string, remove quotes

  2. Read Map Mapping File: Look up target location coordinate data from map_mapping.yaml

    • Supports lookup by symbol or name
  3. Build Target Pose: Convert the found coordinate data into PoseStamped message format

  4. Calculate Distance: Get current pose, calculate Euclidean distance to target point

  5. Navigation Mode Switching:

    • If distance < nav_mode_threshold (default 0.8 meters): use normal navigation (Nav2)
    • If distance >= nav_mode_threshold: use road network navigation
  6. Execute Navigation:

    • Normal Navigation: Call Nav2's NavigateToPose action, wait for navigation completion
    • Road Network Navigation: Publish target pose to road network navigation topic, wait for navigation result
  7. Precise Position Adjustment: After navigation completes, enable ArUco detection, call PreciseAdjustPosition() for centimeter-level fine adjustment

  8. Disable Detection: After fine adjustment, disable ArUco detection to reduce CPU usage

Key Technical Points:

  • Dual-mode Navigation: Short distances use Nav2 normal navigation, long distances use road network navigation, improving efficiency and reliability
  • Visual Relocalization: After arriving near the target, use ArUco code visual recognition for global relocalization to calibrate errors caused by odometry, etc.
  • CPU Optimization: ArUco detection is only enabled during the fine adjustment phase, avoiding continuous CPU resource usage

5.2 PreciseAdjustPosition — Precise Position Adjustment

Function Description: Uses a PID controller to achieve centimeter-level precise position adjustment, ensuring the robot accurately reaches the target position and angle.

xxxxxxxxxx
def PreciseAdjustPosition(self,precise_pose:PoseStamped):
    '''Precise position adjustment'''
    target_x = precise_pose.pose.position.x
    target_y = precise_pose.pose.position.y
    target_yaw = get_yaw_from_quaternion(precise_pose.pose.orientation)
​
    # init PID controller
    xy_kp, xy_ki, xy_kd = self.precise_adjust_xy_pid
    theta_kp, theta_ki, theta_kd = self.precise_adjust_theta_pid
    xy_integral = 0.0   
    theta_integral = 0.0  
    xy_prev_error = 0.0
    theta_prev_error = 0.0
​
    start_time = time.time()
    last_time = start_time
​
    consecutive_success = 0
    required_success = 5 
​
    for attempt in range(self.precise_adjust_max_iteration):
        current_time = time.time()
        dt = current_time - last_time
        last_time = current_time
​
        transform=self._get_current_map_pose()
        if transform is None:
            self.get_logger().error(self.log.get_text("no_tf"))
            return False
​
        current_x = transform.transform.translation.x
        current_y = transform.transform.translation.y
        current_yaw = get_yaw_from_quaternion(transform.transform.rotation)
​
        dx = target_x - current_x
        dy = target_y - current_y
        error_x = dx * math.cos(current_yaw) + dy * math.sin(current_yaw)
        error_y = -dx * math.sin(current_yaw) + dy * math.cos(current_yaw)
        error_theta = normalize_angle(target_yaw - current_yaw)
        pos_error = math.sqrt(dx * dx + dy * dy)
​
​
        # Check whether the target has been reached
        pos_reached = pos_error < self.precise_adjust_pos_tolerance
        angle_reached = abs(error_theta) < self.precise_adjust_angle_tolerance
​
        if pos_reached and angle_reached:
            consecutive_success += 1
            if consecutive_success >= required_success:
                self.cmd_pub.publish(Twist())
                msg_info=self.log.get_text("sys_log_2", pos_error=round(pos_error, 3), error_theta=round(math.degrees(error_theta)))
                self.get_logger().info(Fore.GREEN + msg_info + Fore.RESET)
                return
        else:
            consecutive_success = 0
​
        # PID Calculation - X Direction
        if dt > 0:
            xy_integral += error_x * dt
            xy_integral = max(-1.0, min(1.0, xy_integral)) 
            xy_derivative = (error_x - xy_prev_error) / dt
        else:
            xy_derivative = 0.0
​
        vx = xy_kp * error_x + xy_ki * xy_integral + xy_kd * xy_derivative
        vx = max(-self.precise_adjust_max_linear_vel, min(self.precise_adjust_max_linear_vel, vx))
​
        # PID Calculation - Y Direction
        # Separate integral term is used for Y direction
        if dt > 0:
            vy_integral = error_y * dt
            vy_integral = max(-1.0, min(1.0, vy_integral))
            vy_derivative = (error_y - (xy_prev_error if abs(error_x) > abs(error_y) else 0)) / dt
        else:
            vy_derivative = 0.0
        vy = xy_kp * error_y + xy_ki * vy_integral + xy_kd * vy_derivative
        vy = max(-self.precise_adjust_max_linear_vel, min(self.precise_adjust_max_linear_vel, vy))
​
        # PID Calculation - Angular Direction
        if dt > 0:
            theta_integral += error_theta * dt
            theta_integral = max(-1.0, min(1.0, theta_integral))  
            theta_derivative = (error_theta - theta_prev_error) / dt
        else:
            theta_derivative = 0.0
​
        omega = theta_kp * error_theta + theta_ki * theta_integral + theta_kd * theta_derivative
        omega = max(-self.precise_adjust_max_angular_vel, min(self.precise_adjust_max_angular_vel, omega))
​
        # When the position error is small, reduce the rotation speed to improve stability
        if pos_error < self.precise_adjust_pos_tolerance * 2:
            omega *= 0.5
​
        #----------------publish twist----------
        twist = Twist()
        twist.linear.x = vx
        twist.linear.y = vy
        twist.angular.z = omega
        self.cmd_pub.publish(twist)
​
        # ----------update PID error-------------
        xy_prev_error = error_x
        theta_prev_error = error_theta
        time.sleep(0.1)  # 10Hz
​
​
    self.cmd_pub.publish(Twist())
    self.get_logger().warn(Fore.YELLOW + self.log.get_text("sys_log_3")+Fore.RESET)

Process Description:

  1. Initialize PID Controller:

    • Read X/Y position PID and angle PID Kp, Ki, Kd parameters from configuration
    • Initialize integral and derivative terms to 0
  2. Loop Adjustment (up to precise_adjust_max_iteration times):

    • Get current pose (via TF transform)
    • Calculate position error (dx, dy) and angle error (error_theta)
    • Convert global coordinate system error to robot body coordinate system (error_x, error_y)
  3. Arrival Check:

    • If position error < precise_adjust_pos_tolerance and angle error < precise_adjust_angle_tolerance
    • Satisfied for 5 consecutive times, consider target reached, stop adjustment
  4. PID Calculation:

    • X Direction: Calculate proportional, integral, derivative terms, output linear velocity vx
    • Y Direction: Independent integral term, output lateral velocity vy (for omnidirectional chassis)
    • Angular Direction: Calculate angular velocity omega
    • All outputs are limited to the maximum speed range

Coordinate System Transformation:

xxxxxxxxxx
# Global coordinate system error converted to robot body coordinate system
error_x = dx * cos(current_yaw) + dy * sin(current_yaw)  # forward/backward
error_y = -dx * sin(current_yaw) + dy * cos(current_yaw) # left/right

 

6. Parameter Tuning

  • Parameter file path:
xxxxxxxxxx
$HOME/M3Pro_ws/src/m3pro_bringup/config/common.yaml

6.1 Navigation Mode Switching Parameters

xxxxxxxxxx
mcp_service:
  ros__parameters:
    # Navigation
    nav_mode_threshold: 0.8  # Navigation mode switching threshold, unit: meters

Parameter Description:

ParameterTypeDescriptionDefaultAdjustment Suggestion
nav_mode_thresholdfloatNavigation mode switching distance threshold (meters)0.8Distances below threshold use normal navigation, above use road network navigation

 

6.2 Precision Adjustment PID Parameters

xxxxxxxxxx
mcp_service:
  ros__parameters:
    # precise_adjust
    precise_adjust_xy_pid: [0.5, 0.0, 0.1]        # X/Y position PID parameters [Kp, Ki, Kd]
    precise_adjust_theta_pid: [1.0, 0.0, 0.2]     # Angle PID parameters [Kp, Ki, Kd]
    precise_adjust_max_linear_vel: 0.1            # Precision adjustment maximum linear velocity, unit: m/s
    precise_adjust_max_angular_vel: 0.5           # Precision adjustment maximum angular velocity, unit: rad/s
    precise_adjust_pos_tolerance: 0.01            # Precision adjustment position tolerance, unit: meters
    precise_adjust_angle_tolerance: 0.05          # Precision adjustment angle tolerance, unit: radians
    precise_adjust_max_iteration: 500             # Precision adjustment maximum iterations

Detailed Parameter Description:

ParameterTypeDescriptionDefaultAdjustment Suggestion
precise_adjust_xy_pid[0] (Kp)floatPosition proportional gain0.5Increase for faster response, but may cause overshoot oscillation
precise_adjust_xy_pid[1] (Ki)floatPosition integral gain0.0Used to eliminate steady-state error, generally keep at 0
precise_adjust_xy_pid[2] (Kd)floatPosition derivative gain0.1Increase to suppress overshoot and improve stability
precise_adjust_theta_pid[0] (Kp)floatAngle proportional gain1.0Angle control requires faster response, usually larger than position Kp
precise_adjust_theta_pid[1] (Ki)floatAngle integral gain0.0Generally keep at 0
precise_adjust_theta_pid[2] (Kd)floatAngle derivative gain0.2Suppress angle oscillation
precise_adjust_max_linear_velfloatMaximum linear velocity (m/s)0.1Speed should be slow during fine adjustment to ensure precision
precise_adjust_max_angular_velfloatMaximum angular velocity (rad/s)0.5Control rotation speed
precise_adjust_pos_tolerancefloatPosition tolerance (meters)0.01Position considered reached at this precision (1 cm)
precise_adjust_angle_tolerancefloatAngle tolerance (radians)0.05Angle considered reached at this precision (approx. 2.86 degrees)
precise_adjust_max_iterationintMaximum iterations500Prevents infinite loops, 500 iterations is about 50 seconds

PID Parameter Tuning Steps:

  1. Initial Setup: Use default parameters, set Ki to 0

  2. Adjust Kp:

    • Gradually increase Kp until the system responds quickly with slight overshoot
    • If oscillating, decrease Kp
  3. Adjust Kd:

    • Gradually increase Kd to suppress overshoot and oscillation
    • If response becomes slow, decrease Kd
  4. Adjust Ki (optional):

    • If steady-state error exists (always off by a few millimeters), appropriately increase Ki

Common Problems and Solutions:

ProblemPossible CauseSolution
Continuous oscillation after reaching targetKp too large or Kd too smallDecrease Kp or increase Kd
Adjustment speed too slowKp too smallAppropriately increase Kp
Fixed offset always presentKi=0 or too smallAppropriately increase Ki (e.g., 0.01~0.05)
Unstable angle adjustmentUnreasonable theta_pid parametersIncrease theta_kp or theta_kd
Fine adjustment timeout failureTolerance too small or insufficient iterationsIncrease tolerance or max_iteration
OpenClaw garbage sorting
OpenClaw navigation transfer

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文