Skip to content
/ minibot Public
generated from joshnewans/my_bot

ROS2 Jazzy diffferential drive robot with teleoperation, SLAM and NAV2

License

Notifications You must be signed in to change notification settings

YJ0528/minibot

Repository files navigation

License

This project is licensed under MIT License. For previous licensing history, see LICENSE.previous.md



Differential Drive Robot using ROS 2 Jazzy Jalisco



Hi everyone! Today I would like to share my project implementing a fundamental differential drive robot using ROS2 Jazzy Jalisco and Raspberry Pi 5, with features including Gazebo simulation, ros2_control, teleoperation, SLAM, and Navigation2.

This project also represents my learning journey following tutorials from Articulated Robotics:

You can see the demo here


Getting Started

Before we start, make sure you are using Ubuntu 24.04 and have ROS 2 Jazzy Jalisco installed in your server machine (which is your desktop or laptop).

Make sure to install git:

sudo apt install git ros-dev-tools -y

Make sure VScode is installed, it can be found in Ubuntu App Center. Some extensions that I have installed are listed below:

  • C/C++ Extension Pack (Microsoft)
  • Python (Microsoft)
  • ROS (Microsoft)
  • YAML (Red Hat)
  • Remote - SSH (Microsoft)

Additionally, consider to install Terminator, which is a useful tool to use with ROS 2.


Setting Up ROS 2 Workspace and Installed Requied Packages

Before we start, see ROS 2 Packages: A Brief Introduction for the differences between the binary installation and build from source

Creating a Workspace ros_ws

  1. Open a terminal using ctrl + alt + t, create a workspace named ros_ws with a folder named src:

    mkdir -p ~/ros_ws/src
    
    • Replace ros_ws with the name you want to put as your workspace name.
  2. Follow to the insturction at Install ROS 2 Packages to install all the necessary packages.

    • Although only the listed items under For simulation only are required for simulation, it is recommanded to install all of them.

Launch Simulation

  1. Once Everything is set, go to your_workspace and source the workspace:

    cd ros_ws/
    . install/setup.bash
    
    • When a new terminal is opened, ensure that terminal sourced the workspace also:
  2. Launch the simulation:

    ros2 launch minibot sim.launch.py
    
    • This will launch the robot description, gazebo, rviz2, ros2_control etc.
  3. Launch Simulation Control and SLAM

    The sim_control_station.launch.py will launch all control features for the simulation, inclduing teleop, slam_toolbox, nav2 stack.

    • To run the control with online_async_slam from slam_toolbox, open a new terminal, source the local workspace and enter:

      ros2 launch minibot sim_control_station.launch.py use_slam_option:=online_async_slam
      
    • For mapper_params_localization from slam_toolbox:

      ros2 launch minibot sim_control_station.launch.py use_slam_option:=mapper_params_localization
      
    • For AMCL from nav2:

      ros2 launch minibot sim_control_station.launch.py use_slam_option:=amcl map:=./src/minibot/maps/sample_map.yaml
      
      • To change the map to load, replace the default value corresponding to map with the desired directory.
  4. Alternatively, we can just run the teleoperation only using:

    ros2 launch minibot joystick_teleop.launch.py
    

Additional Notes:

Refer to:



Setting Up the Robot

Robot Hardware and Circuit Connection Setup

*IMPORTANT: Please exercise the proper safety for lipo battery, I have included some precautions at Lipo Battery Safety Precautions.

Lisf of Hardwares:

  • Raspberry Pi 5
  • RPLIDAR C1
  • ESP32-vroom-32 development board
  • ESP32 expansion board (be award whether the pinout match the ESP32 dev board)
  • Cytron MDD3A motor driver
  • 3S lipo battery
  • Step down converter (DFRobot DRF0205 for example)

I only listed down the main electronics that I used, for more information, refer to Build a Mobile Robot with ROS: Bill of Materials by Articulated Robotics

see also: Recommanded Components for Wiring and Robot Chasis (Optional).


Configuring the Raspberry Pi:

Make sure you are using Ubuntu 24.04 and have ROS 2 Jazzy Jalisco installed in the Raspberry Pi.

Install Ubuntu in Raspberry PI using rpi-imager

  • Make sure you have a Micro SD Card with at least 32GB, but a Micro SD with 64GB or more is recommanded.
    • The system has occupied about 24GB of my SD Card, including all everything needed to run the robot.
  • If you never install Ubuntu 24.04 using rpi-imager before, see: RPI5: Flash Ubuntu to SD Card.

Install ROS 2 in Raspberry PI

  • For ROS 2 installation, you can select ROS-Base Install instead of Desktop Install.
  • If you wish to run RViz in Raspberry Pi, consider Desktop Install or binary install via bash using sudo apt install ros-jazzy-rviz2.

Installing Packages for Raspberry Pi and Flashing Code to ESP32

Creating a Workspace robot_ws in Your SBC (Raspberry Pi)

  1. Open a terminal using ctrl + alt + t, create a workspace named robot_ws with a folder named src:

    mkdir -p ~/robot_ws/src
    
    • Replace robot_ws with the name you want to put as your workspace name.
  2. Follow to the insturction at Install ROS 2 Packages to install all the necessary packages in Raspberry Pi.

    • You need to install all the packages listed except ros_gz.

Flashing Code to ESP32

In addition, you need to Flash the driver code to your ESP32, see Install and Flash Microcontroller Driver code


Operating the Robot

  1. Ensure the Raspberry Pi USB device port number matched the value declared:

  2. Connects to the Raspberry Pi from your server machine using openssh-server. Open a terminal in the server machine, enter:

    ssh <remote_username>@<remote_ip_address>
    
  3. In order to let the nodes to be discoverable between the server and the remote machine, We need to set ROS_DOMAIN_ID to the same for both of the machine:

    # The ID is 0 by default, but can be any number between 0 between 101
    export ROS_DOMAIN_ID=1
    
    • For the Raspberry Pi, we can add export ROS_DOMAIN_ID = 1 to the .bashrc file instead using:

      echo "export ROS_DOMAIN_ID=1" >> ~/.bashrc
      
    • To check the ROS_DOMAIN_ID set, enter echo ${ROS_DOMAIN_ID} in terminal.

  4. Once Everything is set, go to your_workspace and source the workspace:

    cd ros_ws/
    . install/setup.bash
    
    • When a new terminal is opened, ensure that terminal sourced the workspace also:
  5. Run the robot:

    ros2 launch minibot robot.launch.py
    
    • This will launch robot description,ros2_control, sllidar_c1_launch etc.
  6. Launch Robot Control with SLAM or Localization

    The robot_remote_station.launch.py will launch all control features for the robot, inclduing teleop, slam_toolbox, nav2 stack.

    • To run the control with online_async_slam from slam_toolbox, open a new terminal in your server machine, source the local workspace and enter:

      ros2 launch minibot robot_remote_station.launch.py use_slam_option:=online_async_slam
      
    • For mapper_params_localization from slam_toolbox:

      ros2 launch minibot robot_remote_station.launch.py use_slam_option:=mapper_params_localization
      
    • For AMCL from nav2:

      ros2 launch minibot robot_remote_station.launch.py use_slam_option:=amcl map:=./src/minibot/maps/sample_map.yaml
      
      • To change the map to load, replace the default value of map with the desired directory.
  7. Alternatively, we can just run the teleoperation only using:

    ros2 launch minibot joystick_teleop.launch.py
    

Demo:

Some visual demostration:

SLAM with Joystick Teleoperation (5x speed with defualt parameter)



Nav2 Navigation using SLAM Toolbox Localization (5x speed)

                global_costmap/global_costmap/ros__parameters/inflation_layer/cost_scaling_factor= 1.0

                global_costmap/global_costmap/ros__parameters/inflation_layer/inflation_radius= 0.05

TO DO (maybe):

  • Implement the hardware interface within this package instead.
  • Explore the slam_toolbox and nav2, or any equivalent.
  • Implement 3D slam at least in simulation using depth camera, if possible.

About

ROS2 Jazzy diffferential drive robot with teleoperation, SLAM and NAV2

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published