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

3.Multi-machine navigation

Multi-car Navigation2 Navigation

Note: The virtual machine needs to be in the same LAN as the car, and the ROS_DOMAIN_ID needs to be the same. 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, enter in the terminal,

xxxxxxxxxx
ros2 topic list

image-20250108211908765

4. Start rviz and load the map program

4.1. Start rviz display

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

xxxxxxxxxx
ros2 launch yahboomcar_nav multi_nav_display_launch.py

image-20240102200422779

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

[1]: robot1 calibrates the initial position

[2]: robot1 gives the target point

[3]: robot2 calibrates the initial position

[4]: robot2 gives the target point

4.2. Load the map

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

xxxxxxxxxx
ros2 launch yahboomcar_multi map_server_launch.py

image-20240102200722677

Note: The map may fail to load here. If the map is not loaded, press ctrl c to close it and rerun the program.

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 directory

/home/yahboom/yahboomcar_ws/src/yahboomcar_nav/maps/, and then modify 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, and 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, enter,

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

In the virtual machine terminal that starts robot2, enter,

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

yahboomcar_bringup_multi.launch.xml source code path (take 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 within this tag will be robot_name, which is the robot1 or robot2 we defined. Among them, there are also 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 AMCL positioning program of the car

In the virtual machine terminal that starts robot1, enter,

xxxxxxxxxx
ros2 launch yahboomcar_multi robot1_amcl_launch.py

In the virtual machine terminal that starts robot2, enter,

xxxxxxxxxx
ros2 launch yahboomcar_multi robot2_amcl_launch.py

image-20240102203247099

As shown in the figure above, "Please set the initial pose..." appears, and the corresponding [2D Pose] tool can be used to give the initial poses to the two cars respectively. According to the position of the car in the actual environment, click and drag with the mouse in rviz, and the car model moves to the position we set. 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-20240102203944722

Red indicates robot1 and blue indicates robot2.

Note: If the terminal cannot print "Please set the initial pose...", it may be a problem of data timestamp asynchrony. Press the reset button of the car to let the car reconnect to the proxy to ensure that the data timestamp is correct. Repeat several times until "Please set the initial pose..." appears.

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

robot1_amcl_launch.py

xxxxxxxxxx
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
    #package_path = get_package_share_directory('yahboomcar_multi')
    #nav2_bringup_dir = get_package_share_directory('nav2_bringup')
    lifecycle_nodes = ['map_server']
    param_file = os.path.join(get_package_share_directory('yahboomcar_multi'),'param','robot1_amcl_params.yaml')
    amcl_node = Node(
        name="robot1_amcl",
        package='nav2_amcl',
        executable='amcl',
        parameters=[os.path.join(get_package_share_directory('yahboomcar_multi'),'param','robot1_amcl_params.yaml')],
        remappings=[('/initialpose', '/robot1/initialpose')],
        output = "screen"
    )
    
    life_node = Node(
        name="robot1_amcl_lifecycle_manager",
        package='nav2_lifecycle_manager',
        executable='lifecycle_manager',
        output='screen',
        parameters=[{'use_sim_time': False},{'autostart': True},{'node_names': ['robot1_amcl']}]
        )
        
    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']
    )
    
    return LaunchDescription([
        #lifecycle_nodes,
        #use_sim_time,\
        amcl_node,
        life_node,
        base_link_to_laser_tf_node
    ])

amcl_node: Start the amcl node program, used to estimate the pose and realize positioning

life_node: amcl node life cycle manager

base_link_to_laser_tf_node: static transformation of chassis and radar data

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 has been loaded, then you can use the corresponding [2D Goal Pose】Given the target points of the two cars, the cars will generate a path based on their respective positions 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-20240102205912491

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 new car URDF model 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 new 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 that appears in the file to other car names, and the name needs to be consistent with the newly added urdf.

8.3. Add a car amcl parameter table and launch file for amcl

Note: The path is:

xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/param/robot1_amcl_params.yaml
/home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_amcl_launch.py
  • Add a car amcl parameter table

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

  • Added launch file of amcl

Refer to /home/yahboom/yahboomcar_ws/src/yahboomcar_multi/launch/robot1_amcl_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,

- 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 keyboard control
Multi-machine rapid relocation navigation

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