yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MicroROS V2 Robot Car📖
01.Introduction
  • 0.Unboxing Video
  • 1. Readme Learning Route
  • 2. Must Read Before Use
  • 3. Introduction to MicroROS V2 Control Board
  • 4. Introduction to LiDAR
  • 5. Introduction to ESP32 Camera Module
  • 6. FAQ
  • 7. About Charging
02.Assembly course
  • Assembly Video
03.Preparation
  • 1. Quickly Start
  • 2. Write Firmware
  • 3. Install VM and Start System
  • 4. Configure VM and Connect Robot
  • 5. Connect to MicroROS Agent
04.Quick start control course
  • 1. VM Keyboard Remote Control
  • 2. VM Handle Remote Control
  • 3. USB Handle Control
05.Robot control course
  • 1. Robot Information Release
  • 2. Robot Keyboard Control
  • 3. Robot Handle Control
  • 4. Robot State Estimation
  • 5. Linear Speed Calibration
  • 6. Angular Velocity Calibration
  • 7. Robot URDF Model
06.Lidar course
  • 1. Precautions for LiDAR Mapping and Navigation
  • 2. Lidar Avoid
  • 3. Lidar Following
  • 4. Lidar Guard
  • 5. Lidar Patrol
  • 6. Gmapping Mapping
  • 7. Cartographer Mapping
  • 8. Cartographer Quickly Repositioning Navigation
  • 9. Slam Toolx Mapping
  • 10. Navigation2 Single Point Navigation
  • 11. Navigation2 Multi Point Navigation
  • 12. Ros Robot App Mapping And Navigation
07.Road network planning
  • 1. Introduction to Road Network Planning and Quick Start
  • 2. Build a Pose Map
  • 3. Road Network Annotation
  • 4. Planning and Navigation Between Road Networks
  • 5. Road Network Navigation in Any Pose
  • 6. Path Replanning
08.Vision basic course
OpenCV Image Processing
  • 1. Introduction to OpenCV Source CV
  • 2. Open Source CV Geometric Transformation
  • 3. Open Source CV Image Processing and Drawing Text Line Segments
  • 4. Open Source CV Image Beautification
09.Visual General Course (For Standard&Superior version)
4. Yolov11&26 Visual Recognition
  • 1. YOLO Environment Setup
  • 2. CLI Usage
  • 3. Object Detection
  • 4. Instance Segmentation
  • 5. Pose Estimation
  • 6. Image Classification
  • 7. Oriented Bounding Boxes Object Detection
  • 8. Model Prediction
1. ESP32 Visual Recognition Module Configuration
  • 1. Serial Port Configuration WiFi Instructions
  • 2. Use ESP32 Camera Module in Robot Car
  • 3. Servo PTZ Calibration
2. OpenCV Visual Recognition
  • 1. Human Pose Estimation
  • 2. Object Detection
  • 3. AR Vision
  • 4. QR Code
  • 5. Color Recognition
  • 6. Facial Recognition
  • 7. AprilTag Machine Code Recognition
3. Mediapipe Visual Recognition
  • 1. Hand Detection
  • 2. Pose Detection
  • 3. Holistic Detection
  • 4. Facial Detection
  • 5. Facial Recognition
  • 6. Facial Special Effects
  • 7. 3D Object Recognition
  • 8. Brush
  • 9. Gesture Recognition
  • 10. Palm Target Localization
  • 11. Fingertip Trajectory Recognition
10.Visual Advanced Course (Just for Standard version)
1. Visual Control
  • 1. QR Code Recognition Control Action
  • 2. AprilTag Control Car Action Group
  • 3. Gesture Control Car Action Group
  • 4. Visual Line Tracking
2. Visual Tracking
  • 1. Color Tracking
  • 2. Facial Tracking
  • 3. QR Code Tracking
  • 4. Object Recognition And Tracking
  • 5. Mediapipe Palm Tracking
  • 6. Mediapipe Gesture Tracking
  • 7. Mediapipe Human Pose Tracking
  • 8. KCF Object Tracking
  • 9. AprilTag Machine Code Tracking
3. Visual Following
  • 1. Color Follow
  • 2. Face Follow
  • 3. QR Code Follow
  • 4. Mediapipe Palm Follow
  • 5. Mediapipe Gesture Follow
  • 6. Mediapipe Human Posture Follow
  • 7. AprilTag Machine Code Follow
  • 8. Object Follow
11.Visual Advanced Course (Just for Superior version)
1. Visual Control
  • 1. QR Code Recognition Control Action
  • 2. AprilTag Control Car Action Group
  • 3. Gesture Control Car Action Group
  • 4. Visual Line Tracking
2. Visual Tracking
  • 1. Color Tracking
  • 2. Facial Tracking
  • 3. QR Code Tracking
  • 4. YOLO Object Recognition and Tracking
  • 5. Mediapipe Palm Tracking
  • 6. Mediapipe Gesture Tracking
  • 7. Mediapipe Human Pose Tracking
  • 8. KCF Object Tracking
  • 9. AprilTag Machine Code Tracking
3. Visual Follow
  • 1. Color Follow
  • 2. Face Follow
  • 3. QR Code Follow
  • 4. Mediapipe Palm Follow
  • 5. Mediapipe Gesture Follow
  • 6. Mediapipe Human Pose Follow
  • 7. AprilTag Machine Code Follow
  • 8. Object Follow
12.AI Large Model Basic and Applications Course
1. AI Large Model Preparation
  • 1.AI Large Model Preparation
2. AI Large Model Basic Course
  • 1. AI Large Model Types and Principles
  • 2. RAG Retrieval Augmented and Training Samples
  • 3. Embodied Intelligent System Architecture
  • 4. Embodied Intelligence Core Source Code
3. AI Large Model Development
  • 1. Register Model Service Account
  • 2. Configure API KEY
  • 3. Dify Introduction
  • 4. Dify Basic Features
  • 5. RAG Knowledge Base Deployment
  • 6. AI Application Development Chatbot
  • 7. RAG Knowledge Base and Chatbot
  • 8. AI Agent Workflow
4. AI Large Model (Text Version)
  • 1. Semantic Understanding and Instruction Following
  • 2. Multimodal Visual Understanding
  • 3. Multimodal Visual Understanding + Basic Control
  • 4. Multimodal Visual Understanding + Object Following
  • 5. Multimodal Visual Understanding + Visual Line Following
  • 6. Multimodal Visual Understanding + SLAM Navigation
  • 7. Multimodal Visual Understanding + SLAM Navigation + Visual Line Following
  • 8. Multimodal Visual Understanding + SLAM Navigation + Object Following
  • 9. Intent Inference + Multimodal Visual Understanding + SLAM Navigation
13.Openclaw Basics Course
  • 1. Openclaw Introduction
  • 2. Openclaw Core Concepts
  • 3. Openclaw Api-Key Configuration
  • 4. Openclaw Switching Models
  • 5. Openclaw System Prompt
  • 6. Openclaw Common CLI Command
14. Openclaw Interaction Course
  • 1. Openclaw Webchat Interaction
  • 2. Openclaw Tui Interaction
  • 3. Openclaw Whatsapp Interaction
15.Openclaw Development Course
  • 1. Openclaw Robot Mcp Service Integration
  • 2. Robot CLI Command Tools
  • 3. Robot-Control Plugin Tools
  • 4. Openclaw Skills Development
  • 5. Openclaw Scheduled Tasks
  • 6. Openclaw Multi Agent System
  • 7. Openclaw Proactive Interaction
  • 8. Openclaw Vector Memory
16.Openclaw Embodied Intelligence Course
  • 1. OpenClaw Natural Interaction + Basic Control
  • 2. OpenClaw Natural Interaction + Slam Navigation
  • 3. OpenClaw Natural Interaction + Multimodal Visual Understand
  • 4. OpenClaw Natural Interaction + Multimodal Visual Understand + Slam Navigation + Visual Follow
  • 5. OpenClaw Natural Interaction + Multimodal Visual Understand + Slam Navigation + Visual Track
17.Multi-machine Course
  • 1. Multi Machine Handle Control
  • 2. Multi Machine Keyboard Control
  • 3. Multi Machine Navigation
18.MicroROS-V2 Control Board Development Environment
  • 1. Set Up the ESP32-IDF Development Environment
  • 2. ESP32-IDF Configuration Tool
  • 3. ESP Flash Tool Flashing Firmware
  • 4. Install ESP32 Microros Components
  • 5. Install And Start Microros Agent
19.MicroROS-V2 Control Board ESP32 Basic Course
  • 1. Led Light Up
  • 2. Button Function
  • 3. Drive Buzzer
  • 4. Oled
  • 5. Usb Host Function
  • 6. Serial Communication
  • 7. Battery Voltage Detection
  • 8. Drive Pwm Servo
  • 9. Drive Motors
  • 10. Read Motor Encoder Data
  • 11. Pid Motor Speed Control
  • 12. Robot Kinematics Analysis Theory
  • 13. Read Imu Data
  • 14. Read Lidar Data
  • 15. Flash Data Storage
  • 16. Custom Partition Table
  • 17. Bluetooth Communication
  • 18. Wifi Connection
  • 19. ESP32 Visual Recognition Module
20.MicroROS-V2 Control Board Micro_ros Basic Course
  • 1. Publish Topics
  • 2. Subscribe To Topics
  • 3. Multi Topic Subscription And Publishing
  • 4. Subscribe To Buzzer Topic
  • 5. Subscribe To Pwm Servo Topic
  • 6. Subscribe To Speed Control Topic
  • 7. Publish Odometry Topic
  • 8. Publish Imu Data Topic
  • 9. Publish Lidar Data Topic
21. 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
22.Docker Course
  • 1.Docker overview and docker installation
  • 2.Common commands for docker image containers
  • 3.Docker images deeply understand and publish images
23.ROS 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)
  • Code
  • Software_Tools
  • VM_System_File
  • 3D_Model_File
  • ESP32_Firmware
  • Dify LLM Base
  • Instruction_Manual
  • VMware
Download ZIP

Welcome to MicroROS V2 Robot Car repository

3. Robot Handle Control

Robot Handle Control

Robot Handle Control1. Course Content2. Preparation3. Handle Button Operations3.1 Motion Control3.2 Speed Gears3.3 Gimbal Control3.4 Buzzer and Enable Switch4. Source Code Analysis4.1 Overall Architecture4.2 Program Execution Flow

1. Course Content

  • Use a gamepad to control the robot chassis and the gimbal camera
  • Understand the internal implementation source code of gamepad control

 

2. Preparation

  • Plug the USB gamepad receiver into the computer, and choose to connect the USB device to the virtual machine

image-20260727113709794

 

  • Check that the virtual machine correctly recognizes the gamepad receiver. Usually the device is displayed as js*
xxxxxxxxxx
ls /dev/input/js*

image-20260727114504541

  • Start the gamepad control program
xxxxxxxxxx
ros2 launch microros_v2_bringup controller.launch.py control_mode:=joystick

image-20260727114431576

 

3. Handle Button Operations

Handle top buttons

Handle front buttons

3.1 Motion Control

Per-axis independent stick/D-pad arbitration — the stick takes priority, and the D-pad acts as a fallback only when the corresponding stick axis is idle:

InputFunctionCurveDescription
Left stick up/down (LY)Forward / backwardSquare curve (power=2.0)Analog control, with 0.15 deadzone
Right stick left/right (RX)Turn left / turn rightCubic curve (power=3.0)Analog control, with 0.15 deadzone
Left stick left/right (LX)No function—Not used
Right stick up/down (RY)No function—Not used
D-pad up/downForward / backward—Only active when LY is idle (digital fallback)
D-pad left/rightTurn left / turn right—Only active when RX is idle (digital fallback)

3.2 Speed Gears

There are 5 fixed speed gears (G1–G5), default G2:

GearLinear VelocityAngular Velocity
G10.20 m/s0.50 rad/s
G2 ★0.30 m/s1.50 rad/s
G30.50 m/s2.50 rad/s
G40.75 m/s3.75 rad/s
G51.00 m/s5.00 rad/s
ButtonFunction
L1Linear velocity up one gear
L2Linear velocity down one gear
R1Angular velocity up one gear
R2Angular velocity down one gear

Moving up to G5 or down to G1 triggers a double beep.

3.3 Gimbal Control

ButtonFunctionDescription
XServo S1 forwardActive when X is pressed alone
BServo S1 reverseActive when B is pressed alone
YServo S2 reverseActive when Y is pressed alone
AServo S2 forwardActive when A is pressed alone

S1 travel range: -90° ~ +90°, S2 travel range: -90° ~ +20°.

3.4 Buzzer and Enable Switch

ButtonFunction
START (OPTIONS)Press and hold to keep beeping, release to stop
SELECT (SHARE)Toggle the gamepad enable state (/JoyState: True ↔ False)

 

4. Source Code Analysis

  • Source code path
xxxxxxxxxx
$HOME/microros_ws/src/common_demo/common_demo/control/joy_control.py

4.1 Overall Architecture

The node uses a multi-timer parallel architecture: it subscribes to the /joy topic to update the button/stick state, and three timers publish commands at periods of 50ms (chassis velocity), 50ms (gimbal angle), and 20ms (buzzer) respectively. _joy_valid() is used to uniformly determine whether the gamepad is online (0.5s timeout) and the enable switch is on.

4.2 Program Execution Flow

  1. Handle event handling (_joy_callback): After receiving a /joy message, it first uses EdgeDetector to detect the SELECT button edge, toggles the enable state and triggers a beep of the corresponding duration; when enabled, it then detects the L1/L2/R1/R2 edges for G1–G5 gear shifting — a single beep for normal shifting, and a double beep when reaching the limit.
  2. Chassis velocity computation (_compute_target_velocity): Uses "stick priority, D-pad fallback" arbitration — when the LY axis exceeds the 0.15 deadzone, it is mapped to linear velocity through a square curve; otherwise the D-pad up/down is used. When the RX axis exceeds the deadzone, it is mapped to angular velocity through a cubic curve; otherwise the D-pad left/right is used. Returns the (target_linear, target_angular, stop) tuple.
  3. Chassis velocity publishing (_cmd_timer_callback): When enabled normally and stop=False, it follows the target velocity instantly; otherwise it enters soft-stop, linearly decaying the current velocity at the deceleration rate, and forces a hard stop after soft_stop_max_time. Finally it clamps to the maximum linear/angular velocity and publishes a Twist to /cmd_vel.
  4. Gimbal control (_compute_servo_direction + _servo_timer_callback): X/B control the S1 axis forward/reverse, Y/A control the S2 axis forward/reverse; when both buttons of a pair are pressed, they cancel to 0. _update_servo_axis updates the angle through acceleration/deceleration interpolation toward the target velocity, and zeroes the velocity when reaching the limits (S1: ±90°, S2: -90°~+20°); finally it packs the result into a Vector3 and publishes it to /cmd_ptz_angle.
​x
    def _joy_callback(self, msg: Joy) -> None:
        self._latest_joy = msg
        self._last_joy_time = self.get_clock().now()
        self._has_joy = True
​
        # SELECT toggle works regardless of enable state
        if self._select_edge.update(self._button(msg, BTN_SELECT)):
            self._joy_control_enabled = not self._joy_control_enabled
            self.get_logger().info(f"joystick control enabled -> {self._joy_control_enabled}")
            if self._joy_control_enabled:
                self._joy_toggle_beep_ticks = 12   # enable:  12 x 20ms ≈  250ms
            else:
                self._joy_toggle_beep_ticks = 50   # disable: 50 x 20ms = 1000ms
​
        if not self._joy_control_enabled:
            return
​
        # --- Speed gear adjustment (edge-triggered, 5 fixed gears) ---
        if self._linear_up_edge.update(self._button(msg, BTN_L1)):
            if self._linear_gear_index < 4:
                self._linear_gear_index += 1
                self.get_logger().info(
                    f"linear gear -> G{self._linear_gear_index+1} "
                    f"({LINEAR_GEAR_TABLE[self._linear_gear_index]:.2f} m/s)"
                )
                self._speed_beep.trigger_single()
            else:
                self.get_logger().info(
                    f"linear gear at max G5 ({LINEAR_GEAR_TABLE[4]:.2f} m/s)"
                )
                self._speed_beep.trigger_double()
​
        if self._linear_down_edge.update(self._button(msg, BTN_L2)):
            if self._linear_gear_index > 0:
                self._linear_gear_index -= 1
                self.get_logger().info(
                    f"linear gear -> G{self._linear_gear_index+1} "
                    f"({LINEAR_GEAR_TABLE[self._linear_gear_index]:.2f} m/s)"
                )
                self._speed_beep.trigger_single()
            else:
                self.get_logger().info(
                    f"linear gear at min G1 ({LINEAR_GEAR_TABLE[0]:.2f} m/s)"
                )
                self._speed_beep.trigger_double()
​
        if self._angular_up_edge.update(self._button(msg, BTN_R1)):
            if self._angular_gear_index < 4:
                self._angular_gear_index += 1
                self.get_logger().info(
                    f"angular gear -> G{self._angular_gear_index+1} "
                    f"({ANGULAR_GEAR_TABLE[self._angular_gear_index]:.2f} rad/s)"
                )
                self._speed_beep.trigger_single()
            else:
                self.get_logger().info(
                    f"angular gear at max G5 ({ANGULAR_GEAR_TABLE[4]:.2f} rad/s)"
                )
                self._speed_beep.trigger_double()
​
        if self._angular_down_edge.update(self._button(msg, BTN_R2)):
            if self._angular_gear_index > 0:
                self._angular_gear_index -= 1
                self.get_logger().info(
                    f"angular gear -> G{self._angular_gear_index+1} "
                    f"({ANGULAR_GEAR_TABLE[self._angular_gear_index]:.2f} rad/s)"
                )
                self._speed_beep.trigger_single()
            else:
                self.get_logger().info(
                    f"angular gear at min G1 ({ANGULAR_GEAR_TABLE[0]:.2f} rad/s)"
                )
                self._speed_beep.trigger_double()
​
    # ------------------------------------------------------------------
    # Validity check — /joy freshness + enable state
    # ------------------------------------------------------------------
​
    def _joy_valid(self) -> bool:
        age_s = (self.get_clock().now() - self._last_joy_time).nanoseconds / 1e9
        return self._has_joy and age_s <= self.control_timeout_s and self._joy_control_enabled
​
    # ------------------------------------------------------------------
    # Motion — stick (analog curve) with D-Pad digital fallback
    # ------------------------------------------------------------------
​
    def _compute_target_velocity(self, joy: Joy) -> tuple[float, float, bool]:
        """Returns (target_linear, target_angular, stop).
​
        Car convention: linear.x < 0 → FORWARD, angular.z < 0 → LEFT TURN.
        Joy convention: LY up=-1, RX left=-1 → signs pass through directly.
        """
        linear_speed = LINEAR_GEAR_TABLE[self._linear_gear_index]
        angular_speed = ANGULAR_GEAR_TABLE[self._angular_gear_index]
​
        # Linear: Left Stick LY, D-Pad V fallback
        ly_raw = self._axis(joy, AXIS_LY)
        if abs(ly_raw) > STICK_DEADZONE:
            ly = self._apply_deadzone(ly_raw, STICK_DEADZONE)
            target_linear = self._curve(ly, LINEAR_CURVE_POWER) * linear_speed
        else:
            dpad_v = self._axis(joy, AXIS_DPAD_V)
            if dpad_v < -0.5:      # D-Pad up → forward (linear.x < 0)
                target_linear = -linear_speed
            elif dpad_v > 0.5:     # D-Pad down → backward
                target_linear = linear_speed
            else:
                target_linear = 0.0
​
        # Angular: Right Stick RX, D-Pad H fallback
        rx_raw = self._axis(joy, AXIS_RX)
        if abs(rx_raw) > STICK_DEADZONE:
            rx = self._apply_deadzone(rx_raw, STICK_DEADZONE)
            target_angular = self._curve(rx, ANGULAR_CURVE_POWER) * angular_speed
        else:
            dpad_h = self._axis(joy, AXIS_DPAD_H)
            if dpad_h < -0.5:      # D-Pad left → left turn (angular.z < 0)
                target_angular = -angular_speed
            elif dpad_h > 0.5:     # D-Pad right → right turn
                target_angular = angular_speed
            else:
                target_angular = 0.0
​
        stop = target_linear == 0.0 and target_angular == 0.0
        return target_linear, target_angular, stop
​
    # ------------------------------------------------------------------
    # CmdVel timer — target velocity + soft-stop
    # ------------------------------------------------------------------
​
    def _cmd_timer_callback(self) -> None:
        if not self._joy_control_enabled:
            return
​
        dt = self.cmd_publish_period_s
        valid = self._joy_valid()
​
        if valid:
            target_linear, target_angular, stop = self._compute_target_velocity(self._latest_joy)
        else:
            target_linear, target_angular, stop = 0.0, 0.0, True
​
        if valid and not stop:
            # --- Motion active: snap to target (instant response) ---
            self._stop_elapsed = 0.0
            self._current_linear_vel = target_linear
            self._current_angular_vel = target_angular
        else:
            # --- Soft-stop ---
            self._stop_elapsed += dt
            if self._stop_elapsed > self.soft_stop_max_time:
                # Exceeded max stop time → hard stop
                self._current_linear_vel = 0.0
                self._current_angular_vel = 0.0
            else:
                self._current_linear_vel = self._move_toward(
                    self._current_linear_vel, 0.0, self.soft_stop_linear * dt
                )
                self._current_angular_vel = self._move_toward(
                    self._current_angular_vel, 0.0, self.soft_stop_angular * dt
                )
​
        twist = Twist()
        twist.linear.x = self._clamp(self._current_linear_vel, -MAX_LINEAR_SPEED, MAX_LINEAR_SPEED)
        twist.linear.y = 0.0
        twist.angular.z = self._clamp(self._current_angular_vel, -MAX_ANGULAR_SPEED, MAX_ANGULAR_SPEED)
        self._cmd_vel_pub.publish(twist)
​
    # ------------------------------------------------------------------
    # Servo timer — face buttons + acceleration-limited interpolation
    # ------------------------------------------------------------------
​
    def _compute_servo_direction(self, joy: Joy) -> tuple[int, int]:
        """X → S1 +1, B → S1 -1; Y → S2 -1, A → S2 +1; opposite pair cancels."""
        x_on = self._button(joy, BTN_X) == 1
        b_on = self._button(joy, BTN_B) == 1
        y_on = self._button(joy, BTN_Y) == 1
        a_on = self._button(joy, BTN_A) == 1
​
        s1 = 1 if (x_on and not b_on) else (-1 if (b_on and not x_on) else 0)
        s2 = -1 if (y_on and not a_on) else (1 if (a_on and not y_on) else 0)
        return s1, s2
​
    def _update_servo_axis(
        self, axis: ServoAxisState, direction: int,
        direction_sign: float, min_angle: float, max_angle: float, dt: float,
    ) -> None:
        if direction == 0:
            axis.velocity_dps = 0.0
            return
​
        target_velocity = float(direction) * direction_sign * self.servo_speed_dps
        velocity_delta = self.servo_accel_dps2 * dt
        axis.velocity_dps = self._move_toward(axis.velocity_dps, target_velocity, velocity_delta)
        axis.angle += axis.velocity_dps * dt
        axis.angle = self._clamp(axis.angle, min_angle, max_angle)
​
        if axis.angle <= min_angle or axis.angle >= max_angle:
            axis.velocity_dps = 0.0
​
    def _servo_timer_callback(self) -> None:
        if not self._joy_control_enabled:
            return
​
        if self._joy_valid():
            s1_dir, s2_dir = self._compute_servo_direction(self._latest_joy)
        else:
            s1_dir, s2_dir = 0, 0
​
        dt = self.servo_publish_period_s
        self._update_servo_axis(
            self._servo_s1, s1_dir, SERVO_S1_DIR_SIGN, SERVO_S1_MIN, SERVO_S1_MAX, dt,
        )
        self._update_servo_axis(
            self._servo_s2, s2_dir, SERVO_S2_DIR_SIGN, SERVO_S2_MIN, SERVO_S2_MAX, dt,
        )
​
        servo_msg = Vector3()
        servo_msg.x = float(self._servo_s1.angle)
        servo_msg.y = float(self._servo_s2.angle)
        servo_msg.z = 0.0
        self._servo_angle_pub.publish(servo_msg)
​
    # ------------------------------------------------------------------
    # Beeper timer
    # ------------------------------------------------------------------
​
    def _beep_timer_callback(self) -> None:
        beep_msg = UInt16()
​
        # SELECT toggle beep is independent of joystick enable state,
        # so we process it before the enabled guard.
        if self._joy_toggle_beep_ticks > 0:
            beep_msg.data = 50  # 50 units x 10ms = 500ms pulses
            self._joy_toggle_beep_ticks -= 1
            self._beep_pub.publish(beep_msg)
            if self._joy_toggle_beep_ticks == 0:
                # Send explicit stop after last tick to cut off firmware beep cleanly
                self._beep_pub.publish(UInt16(data=0))
            return
​
        if not self._joy_control_enabled:
            return
​
        # Priority: START continuous beep > speed-adjust feedback beep
        start_beep = (
            START_BEEP_UNITS
            if self._joy_valid() and self._button(self._latest_joy, BTN_START) == 1
            else 0
        )
        if start_beep > 0:
            beep_msg.data = start_beep
            self._speed_beep.reset()  # suppress pending speed beeps
        elif self._speed_beep.active:
            self._speed_beep.tick()
            beep_msg.data = self._speed_beep.value()
        else:
            beep_msg.data = 0
​
        self._beep_pub.publish(beep_msg)
Robot Keyboard Control
Robot State Estimation

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

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文