yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MicroROS Self-balancing Robot Car📖
01.Introduction
  • 0.Unboxing and Reviewing
  • 1. Must read before use - learning route
  • 2. Introduction to LiDAR
  • 3. Balance car interface description
  • 4. Analysis of common problems
  • 5. Robot charging and battery precautions
02.Assembly tutorial
  • Robot assembly steps
03.Preparation
  • 0.Quick Start (Must Read)
  • 1.Write firmware
  • 2.How to install and use VM
  • 3.ESP32 communication board configuration parameters
  • 4.Connect to microROS agent
04.ROS-WiFi module configuration
  • 0.Serial port configuration WiFi instructions
  • 1.Use ROS-WiFi cam module(must read)
  • 2.Connect to ROS-WiFi cam module agent
  • 3.Camera image correction (optional)
05.Quick start control
  • 1.Keyboard remote control
  • 2.Handle remote control
06.ROS+OpenCV course
  • 1.OpenCV Getting started
  • 2.Geometric transformation
  • 3.Image processing and drawing text line segments
  • 4.Image beautification
07.Mediapipe course
  • 1. Hand detection
  • 2. Posture detection
  • 3. Overall inspection
  • 4. Face detection
  • 5. Face recognition
  • 6. Facial effects
  • 7. 3D object recognition
  • 8. Brush
  • 9. Finger control
  • 10. Gesture recognition
08.Robot basic course
  • 1.Robot information release
  • 2.Robot keyboard control
  • 3.Robot handle control
  • 4.Robot state estimation
  • 5.Line speed calibration
  • 6.Angular velocity calibration
  • 7.Robot URDF model
09.Lidar course
  • 1.Lidar avoid
  • 2.Lidar following
  • 3.Lidar guard
  • 5.Gmapping mapping
  • 6.Cartographer mapping
  • 7.Navigation2 navigation avoid
  • 8.Navigation2 fast relocation navigation
  • 9.ROS Robot APP mapping
  • 10.ROS Robot APP navigation
10.Robot visual interaction
  • 1.Color tracking
  • 2.Object recognition and tracking
  • 3.Face recognition tracking
  • 4.Autonomous driving line patrol
  • 5.QR code motion control
  • 6.Gesture control car movement
  • 7.Palm control car movement
  • 8.Gesture control car action group
  • 9.Palm recognition and tracking
  • 10.Human body posture recognition and tracking
11.Multi-machine course
  • 1.Multi-machine handle control
  • 2.Multi-machine keyboard control
  • 3.Multi-machine navigation
  • 4.Multi-machine rapid relocation navigation
12.STM32 balancing case
01.Environment construction and development
  • 13.Window Watchdog (WWDG)
  • 01.MDK-ARM installation
  • 02.STM32CubeIDE installation
  • 03.Common driver installation
  • 04.Download the program
  • 05.MDK-ARM project usage
  • 06.Program simulation
02.STM32 getting started course
  • 01.Project creation
  • 02.LED Control(GPIO)
  • 03.Buzzer control(GPIO)
  • 04.Button control(EXTI)
  • 05.Serial communication(USART)
  • 06.Voltage detection(ADC)
  • 07.Basic timer(TIM)
  • 08.Universal timer(TIM)
  • 09.Advanced Timer(TIM)
  • 10.I2C Communication(I2C)-OLED
  • 11.SPI communication(SPI)-2.4G handle
  • 12.Independent Watchdog (IWDG)
  • 14.DMA-USART
  • 15.DMA-I2C
03.STM32 expansion course
  • 01.Battery voltage detection (ADC)
  • 02.Ultrasonic module-measuring distance (TIM)
  • 03.Motor drive+encoder (TIM)
  • 04.OLED Data-Display(I2C)
  • 05.MPU6050-Data Read (I2C)
04.Robot car PID control course
  • 01.PID basic concept
  • 02.PID example analysis
  • 03.P, PI, PD controller theory
  • 04.Position PID
  • 05.Incremental PID
  • 06.Cascade PID
  • 07.Balance principle of car
  • 08.Car upright control (PD)
  • 09.Car speed ​​control (PI)
  • 10.Car steering control (PD)
  • 11.Got angle and angular velocity (DMP algorithm)
  • 12.Got angle and angular velocity (Kalman filter algorithm)
  • 13.Got angle and angular velocity(Complementary filter algorithm)
05.Robot car basic course
  • 01.Car parameter adjustment
  • 02.Ultrasonic obstacle avoidance
  • 03.Ultrasonic follow
  • 04.Bluetooth remote control
  • 05.Load balance
  • 06.Radar obstacle avoidance
  • 07.Radar guard
  • 08.Radar follow
  • 09.Radar patrol
  • 10.Radar wall following go in a straight line
  • 11.Radar tracking wall multiple walls
06.Robot car LQR control
  • Balance car LQR high-level control
07.Circuit design
  • 01.Overall circuit design
  • 02.STM32 minimum system
  • 03.Serial port circuit design
  • 04.Power circuit design
  • 05.MPU6050 Circuit Design
  • 06.Motor drive circuit design
08.Mathematical model
  • Balance car mathematical model
13.Linux basic 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
14.Docker course
  • 1. Overview and installation
  • 2. Common commands
  • 3. Docker images deeply understand and publish images
  • 4. Docker hardware interaction and data processing
  • 5. Enter the bot's docker container
15.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
  • RemoteCtrl_APP(Android)
  • Mapping_APP(iOS_Android)
  • Code
  • Hardware Information
  • software tools
  • 3D model file
  • Instruction manual
  • VM image file
  • ROS2_Basic_VM
Download ZIP

Welcome to MicroROS Self-balancing Robot Car repository

4.Multi-machine rapid relocation navigation

Multi-car Navigation2 fast relocation navigation

Note: The virtual machine needs to be in the same LAN as the car, and the ROS_DOMAIN_ID needs to be consistent. You can check [Must-read before use] to set the IP and ROS_DOMAIN_ID on the board.

1. Program function description

After the program is started, you can give the target points of the two cars in rviz. After receiving the command, the two cars will calculate the path based on their own posture and move to their destinations.

xxxxxxxxxx
Note: Before running the program, the car needs to be restarted in a standing position to ensure that all sensors are reset

2. Basic settings for multi-machine functions

Take two cars as an example. It is recommended to use two computers with matching virtual machines, change the config_robot.py files respectively, set robot.set_ros_namespace() to robot1 and robot2 respectively; set robot.set_udp_config() to the IP addresses of the two virtual machines respectively, and the ROS_DOMAIN_ID of the two cars and the ROS_DOMAIN_ID of the virtual machine need to be set to the same. Then open the terminal in the /home/yahboom directory, enter sudo python3 config_Balance_Car.py to run this program (the rest of the programs other than running multiple cars need to be changed back and re-run this program).

image-20250108211224464

3. Start and connect the agent

Take the matching virtual machine as an example. In the two virtual machines, enter the following command to start the agent of each car.

xxxxxxxxxx
sudo docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:humble udp4 --port 8899 -v4

image-20241226101427280

Then, turn on the switches of the two cars and wait for the two cars to connect to their respective agents. If the connection is successful, the terminal display is as shown in the figure below.

image-20241226101559446

Check the currently started node. In the two virtual machines, randomly select one and open the terminal to enter,

xxxxxxxxxx
ros2 node list

image-20250108211845321

As shown in the figure above, the nodes of both cars have been started. Query the current topic information, input in the terminal,

xxxxxxxxxx
ros2 topic list

image-20250108211908765

4. Load the map program

Select one of the two virtual machines at random, open the terminal and input,

xxxxxxxxxx
ros2 launch yahboomcar_multi map_server_launch.py ••map:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.yaml

Parameter description

xxxxxxxxxx
#Load map parameters: (target map can be replaced)
maps:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.yaml
#.pgm file must also be in the same path as .yaml

Note: Here, yahboom_map.yaml and yahboom_map.pbstream must be built at the same time, that is, the same map, refer to cartograph mapping algorithm to save the map

image-20250109093220837

Note: Lifecycle error may occur here, which is caused by the map not being built.

Take the virtual machine as an example, the map loaded here is,

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.yaml

If you need to modify the default loading of other maps, copy the map's yaml file and pgm file to the

/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/ directory, and then modify the map_server_launch.py ​​program, which is located in /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch, and modify the following places,

image-20250108214656797

Replace the red box with the name of your own map, save and exit, then enter the following command to compile,

xxxxxxxxxx
cd ~/yahboomcar_ws
colcon build

Then enter the following command to re-source the environment variable,

xxxxxxxxxx
source ~/.bashrc

5. Start the car's underlying data processing program

In the virtual machine terminal that starts robot1,

xxxxxxxxxx
ros2 launch yahboomcar_multi navigation_bringup_multi.launch.xml robot_name:=robot1

In the virtual machine terminal that starts robot2,

xxxxxxxxxx
ros2 launch yahboomcar_multi navigation_bringup_multi.launch.xml robot_name:=robot2

image-20250109093335957

yahboomcar_bringup_multi.launch.xml source code path (taking the matching virtual machine as an example),

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/yahboomcar_bringup_multi.launch.xml
xxxxxxxxxx
<launch>
    <arg name="robot_name" default="robot1"/>
    <group>
        <push-ros-namespace namespace="$(var robot_name)"/>
        <!--base_node-->
        <node name="base" pkg="yahboomcar_bringup" exec="cmdvel2bl" output="screen">
            <param name="mode" value="nav"/>
            <remap from="/cmd_vel" to="cmd_vel"/>
            <remap from="/cmd_vel_bl" to="cmd_vel_bl"/>
        </node>
        <!--imu_filter_node-->
        <node name="imu_filter" pkg="imu_filter_madgwick" exec="imu_filter_madgwick_node" output="screen">
            <param name="fixed_frame" value="$(var robot_name)/base_link"/>
            <param name="use_mag" value="false"/>
            <param name="publish_tf" value="false"/>
            <param name="world_frame" value="$(var robot_name)/enu"/>
            <param name="orientation_stddev" value="0.00"/>
            <remap from="imu/data_raw" to="imu"/>
        </node>
        <!--ekf_node-->
        <node name="ekf_filter_node" pkg="robot_localization" exec="ekf_node">
            <param from="$(find-pkg-share yahboomcar_multi)/param/ekf_$(var robot_name).yaml"/>
            <remap from="odometry/filtered" to="odom"/>
            <remap from="/odom_raw" to="odom_raw"/>
        </node>
        <node pkg="tf2_ros" exec="static_transform_publisher" name="base_link_to_base_imu"
          args="0 0.016325 0.080691 0 0 0  $(var robot_name)/base_link $(var robot_name)/imu_frame " />
    </group>
    <include file="$(find-pkg-share yahboomcar_description)/launch/description_multi_$(var robot_name).launch.py"/>
    
</launch>

Here, a pair of tags are used. The command space of all programs in this tag will be robot_name, which is the robot1 or robot2 we defined. Among them, there are some parameter files or topic names, which are also automatically selected and loaded through this robot_name. You can view the content in the code for details.

6. Start the fast relocation program and rviz of the car

Input in the virtual machine terminal that starts robot1, and you can choose any rviz to start.

xxxxxxxxxx
ros2 launch yahboomcar_multi robot1_localization_imu_odom.launch.py load_state_filename:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.pbstream use_rviz:=true

Parameter Description

xxxxxxxxxx
#Select whether to open rviz, true is open, false is not open
use_rviz:=true
#Replaceable target map file
load_state_filename:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.pbstream

In the terminal of the virtual machine that starts robot2, enter,

xxxxxxxxxx
ros2 launch yahboomcar_multi robot2_localization_imu_odom.launch.py load_state_filename:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.pbstream use_rviz:=false

Parameter description

xxxxxxxxxx
#Select whether to open rviz, true is open, false is not open
use_rviz:=false
#Replaceable target map file
load_state_filename:=/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/testaa.pbstream

Note: The testaa.pbstream map of robot1 and robot2 must be the same map

image-20250109101707884

When it prints (pulsed at 101.80% real time)...etc., it proves that the startup is normal

You can see that the map is loaded, but the positioning of the car is not accurate, then we click [2D Pose Estimate】, give the two cars an initial pose respectively. According to the approximate position of the car in the actual environment, click and drag with the mouse in rviz, and the car can be quickly positioned on the map.

image-20250109093755086

Red represents robot1 and blue represents robot2.

The functions of the symbols in Figures 1-4 above are as follows:

[1]: robot1 calibrates the initial pose

[2]: robot1 gives the target point

[3]: robot2 calibrates the initial pose

[4]: robot2 gives the target point

Note: If positioning is still not possible, it may be that the car is in an obstacle area. Please place it in a place with no obstacles around and start again. You can also keep the terminal open, restart the car directly, and wait for the automatic data recovery to re-position it. It may also be that there are too few map feature points when building the map, and the map construction must be more detailed.

As shown in the figure below, if the area scanned by the radar roughly coincides with the actual obstacle, it means that the posture is accurate.

image-20250109094715062

Take the virtual machine as an example, the source code location: /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch

robot1_localization_imu_odom.launch.py

xxxxxxxxxx
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, LogInfo,Shutdown
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, TextSubstitution
from launch_ros.actions import Node, PushRosNamespace
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
    robot_name = 'robot1'

    load_state_filename_arg = DeclareLaunchArgument(
        'load_state_filename',
        default_value='/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.pbstream'
    )

    use_rviz_arg = DeclareLaunchArgument(
        'use_rviz',
        default_value='true',
    )

    rviz_node = Node(
        package='rviz2',
        executable='rviz2',
        on_exit=Shutdown(),
        arguments=['-d', FindPackageShare('yahboomcar_nav').find('yahboomcar_nav') + '/rviz/multi_cartonav.rviz'],
        parameters=[{'use_sim_time': False}],
        condition=IfCondition(LaunchConfiguration('use_rviz'))
    )
    base_link_to_laser_tf_node = Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        name='base_link_to_base_laser',
        namespace = 'robot1',
        arguments=['0', '0' , '0.138','0','0','0','robot1/base_link','robot1/laser_frame']
    )
    group = GroupAction([
        PushRosNamespace(namespace=robot_name),

        Node(
            package='cartographer_ros',
            executable='cartographer_node',
            parameters=[{'use_sim_time': False}],
            arguments=[
                '-configuration_directory', FindPackageShare('cartographer_ros').find('cartographer_ros') + '/configuration_files',
                '-configuration_basename', f'ros1_backpack_2d_localization_imu_odom_{robot_name}.lua',
                '-load_state_filename', LaunchConfiguration('load_state_filename')],
            remappings=[
                ('imu', 'imu/data'),
                ('scan', 'scan')],
            output='screen'
        ),

        Node(
            package='cartographer_ros',
            executable='cartographer_occupancy_grid_node',
            parameters=[
                {'use_sim_time': False},
                {'resolution': 0.05}],
            remappings=[
                ('map', 'map')]
        ),

        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            name='base_link_to_base_laser',
            arguments=['0', '0' , '0.138','0','0','0','robot1/base_link','robot1/laser_frame']
        ),

        rviz_node,

    ])

    return LaunchDescription([
        # Launch arguments
        load_state_filename_arg,
        use_rviz_arg,
        # Group for robot1
        base_link_to_laser_tf_node,
        group
    ])

The following nodes are started here:

  • rviz_node: Start rviz2 to visualize the robot status.

  • cartographer_node: Start cartographer_node for SLAM positioning and mapping.

  • cartographer_occupancy_grid_node: Start cartographer_occupancy_grid_node to generate occupancy grid map.

  • base_link_to_laser_tf_node: Publish the static transformation from chassis to radar.

7. Start the car navigation program

In the virtual machine terminal that starts robot1, enter,

xxxxxxxxxx
ros2 launch yahboomcar_multi robot1_navigation_dwb_launch.py

In the virtual machine terminal that starts robot2, enter,

xxxxxxxxxx
ros2 launch yahboomcar_multi robot2_navigation_dwb_launch.py

image-20240102204838255

As shown in the figure above, the "Creating bond timer..." appears, indicating that the program is loaded. Then, the corresponding [2D Goal Pose] on riviz can be used to give the target points of the two cars. The cars will generate a path based on their respective postures and surrounding obstacles, and autonomously navigate to their respective destinations.

image-20240102205740408

The yellow route is the route planned by robot1, and the green line is the route planned by robot2.

image-20250109095155649

8. Multi-car navigation expansion

The tutorial takes two cars as an example. If you want to add other cars, you need to make the following modifications.

8.1. Add a URDF model of the car and add a urdf model loader

Note: The path is,

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_description/launch/description_multi_robot1.launch.py
/home/yahboom/yahboomcar_ws/src/yahboomcar_description/urdf/STM32-V2-V1_robot1.urdf
  • Add a car model

For reference, /home/yahboom/yahboomcar_ws/src/yahboomcar_description/urdf/STM32-V2-V1_robot1.urdf

Change the name and robot1 in the urdf file to other car names, such as robot3.

  • Added urdf model loader

For reference, /home/yahboom/yahboomcar_ws/src/yahboomcar_description/launch/description_multi_robot1.launch.py Change the name and robot1 in the launch file to other car names. The name needs to be consistent with the newly added urdf.

8.2, Added car ekf parameter table

Note: The path is,

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/ekf_robot1.yaml

You can refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/ekf_robot1.yaml, change the name and robot1 in the file to other car names, and the name needs to be consistent with the newly added urdf.

8.3, Added launch file for starting positioning

Note: The path is:

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_localization_imu_odom.launch.py
  • Added launch file for positioning

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_localization_imu_odom.launch.py, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

8.4, Added car nav2 parameter table and launch file for starting nav2

Note: The path is:

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/robot1_nav_params.yaml
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_navigation_dwb_launch.py
  • Added car nav2 parameter table

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/robot1_nav_params.yaml, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

  • Added launch file for nav2

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_navigation_dwb_launch.py, change the name and robot1 in the file to the name of other cars, and the name needs to be consistent with the newly added urdf.

8.5, Added [2D Pose Estimate] and [2D Goal Pose] in the rviz toolbar

Note: The path is:

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/rviz

Modify the multi_nav.rviz file, the directory of the file is /home/yahboom/yahboomcar_ws/src/yahboomcar_nav/rviz/multi_nav.rviz, find the following part,

xxxxxxxxxx
- Class: rviz_default_plugins/SetInitialPose
  Covariance x: 0.25
  Covariance y: 0.25
  Covariance yaw: 0.06853891909122467
  Topic:
    Depth: 5
    Durability Policy: Volatile
    History Policy: Keep Last
    Reliability Policy: Reliable
    Value: /robot1/initialpose
- Class: rviz_default_plugins/SetGoal
  Topic:
    Depth: 5
    Durability Policy: Volatile
    History Policy: Keep Last
    Reliability Policy: Reliable
    Value: /robot1/goal_pose
...

The above are two tools for robot1. You can copy one and put it behind. Change the robot1 that appears to the name of other cars. The name needs to be consistent with the newly added urdf.

After completing the above 5 steps, return to the yahboomcar_ws workspace, compile it using colcon build, and then run the test according to the tutorial. After successful operation, you can add the car model and radar data to display in rviz.

Multi-machine navigation
Window Watchdog (WWDG)

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/中文