SkillAgentSearch skills...

Lidarbot

A differential drive robot is controlled using ROS2 Humble running on a Raspberry Pi 4 (running Ubuntu server 22.04). The vehicle is equipped with a raspberry pi camera for visual feedback and an RPlidar A1 sensor used for Simultaneous Localization and Mapping (SLAM), autonomous navigation and obstacle avoidance.

Install / Use

/learn @TheNoobInventor/Lidarbot

README

Lidarbot

<!-- ![ROS2 CI](https://github.com/TheNoobInventor/lidarbot/actions/workflows/.github/workflows/lidarbot_ci_action.yml/badge.svg) -->

A differential drive robot is controlled using ROS2 Humble running on a Raspberry Pi 4 (running Ubuntu server 22.04). The vehicle is equipped with a Raspberry Pi camera for visual feedback and an RPlidar A1 sensor used for Simultaneous Localization and Mapping (SLAM), autonomous navigation using the Nav2 stack. Additionally, an MPU6050 inertial measurement unit (IMU) is employed by the robot_localization package on the robot, to fuse IMU sensor data and the wheel encoders data, using an Extended Kalman Filter (EKF) node, to provide more accurate robot odometry estimates.

Hardware components are written for the Waveshare Motor Driver HAT and MPU6050 sensor to be accessed by the ros2_control differential drive controller and IMU sensor broadcaster respectively, via the ros2_control resource manager.

<p align='center'> <img src=docs/images/real_mapping.gif width="600"> </p>

A preprint of this work is available here.

🗃️ Package Overview

  • lidarbot_aruco : Contains configuration, launch and node files to use ArUco markers with lidarbot.
  • lidarbot_base : Contains the ROS2 control hardware component for the lidarbot with low-level code for the Waveshare Motor Driver HAT.
  • lidarbot_bringup : Contains hardware component for the MPU6050 module, launch files to bring up the camera, lidar and the real lidarbot.
  • lidarbot_description : Contains the URDF description files for lidarbot, sensors and ros2 control.
  • lidarbot_gazebo : Contains configuration, launch and world files needed to simulate lidarbot in Gazebo Classic.
  • lidarbot_gz : Contains urdf, launch and world files needed to simulate lidarbot in Gazebo Fortress.
  • lidarbot_navigation : Contains launch, configuration and map files used for lidarbot navigation.
  • lidarbot_slam : Contains configuration files for the slam toolbox and RViz, launch file to generate maps using SLAM.
  • lidarbot_teleop : Contains configuration and launch files used to enable joystick control of the lidarbot in simulation and physically.

🧰 Hardware

Part list

The following components were used in this project:

| | Part | | --| --| |1| Raspberry Pi 4 (4 GB)| |2| SanDisk 32 GB SD Card (minimum)| |3| Two wheel drive robot chassis kit| |4| Waveshare Motor Driver HAT| |5| 2 x Motors with encoders and wire harness| |6| MPU6050 board| |7| RPlidar A1| |8| Raspberry Pi camera v1.3| |9| 3D printed stands for RPlidar A1 and RPi 4| |10| Mount for Raspberry Pi camera| |11| Powerbank for RPi 4 (minimum output: 5V 3A)| |12| Gamepad| |13| Mini Travel Router (optional)| |14| 3 Slot 18650 battery holder| |15| 3 x 18650 batteries to power Motor Driver HAT| |16| Female to Female Dupont jumper cables| |17| Spare wires| |18| Logitech C270 webcam (optional)|

Some other tools or parts used in the project are as follows:

| | Tool/Part | | --| --| |1| Soldering iron| |2| 3D printer| |3| Screwdriver set| |4| Double-sided tape|

Additionally, some nylon stand-offs were used in between the Raspberry Pi 4 and its 3D printed stand to make it easier to plug in the USB power cable from the powerbank.

Project Wiring and Assembly

The electronic components of the lidarbot are connected as shown below.

<p align="center"> <img title='Wiring diagram' src=docs/images/lidarbot_wiring.png width="800"> </p>

The MPU6050 board pins were connected to the Raspberry Pi 4 GPIO pins as follows for use with the I2C communication protocol:

| MPU6050 board | GPIO.BOARD| GPIO.BCM| | ----------- | ------------| ------ | | VCC | 3.3V | 3.3V | | GND | GND | GND | | SCL | 05 | GPIO03 | | SDA | 03 | GPIO02 |

In a previous hardware version of lidarbot, photo interrupters were used with encoder disks with 20 slots (included in the robot chassis kit). However, this setup proved restrictive in yielding satisfactory results in navigation due to the low number of encoder ticks, which was only 20 for a 360 degree turn of the motor. Therefore, the robot chassis kit motors were replaced with the ones below with built-in encoders --- which have encoder ticks of approximately 1084, calculated using this guide from Automatic Addison.

These are the new motors used for lidarbot:

<p align="center"> <img title='Motors' src=docs/images/motors.jpg width="400"> <img title='Motor pins' src=docs/images/motor_pins.jpg width="400"> </p>

The pins on right and left motors are connected to the GPIO pins as follows:

| Right motor pins | GPIO.BOARD | GPIO.BCM| | ----------- | ------------| ------ | | C1 (or Encoder A) | 22 | GPIO25 | | C2 (or Encoder B) | 16 | GPIO23 | | VCC | 5V | 5V | | GND | GND | GND |

| Left motor pins| GPIO.BOARD | GPIO.BCM| | ----------- | ------------| ------ | | C1 (or Encoder A) | 18 | GPIO24 | | C2 (or Encoder B) | 15 | GPIO22 | | VCC | 5V | 5V | | GND | GND | GND |

Where,

C1 - counts the respective motor pulses and

C2 - checks the direction of motion of the respective motor, that is, forward or reverse.

<p align="center"> <img title='MPU6050' src=docs/images/mpu6050.jpg width="400"> <img title='Encoders' src=docs/images/encoders.jpg width="400"> </p>

The screw terminal blocks on the Motor Driver HAT (shown below) are connected to the motor pins, M+ and M-, and battery holder cables as follows:

| Motor Driver HAT pin | Connected to| | -- | -- | | MA1 | Red wire (Left motor)| | MA2 | Black wire (Left motor)| | GND | Black wire (battery holder) | | VIN | Red wire (battery holder) | | MB1 | Red wire(Right motor)| | MB2 | Black wire (Right motor)|

<p align="center"> <img title='Motor Driver HAT' src=docs/images/Motor_Driver_HAT.png width="400"> </p>

Solder the cables (provided) to the motors. Spare wires might be needed if the provided ones are too short to reach the Motor Driver Hat. Should the wheel(s) move in the direction opposite of what is expected, exchange the respective motor cables screwed into the terminal blocks.

Finally, the Raspberry Pi camera is connected to the ribbon slot on the Raspberry Pi 4 and the RPlidar A1 sensor is plugged into one of the RPi 4's USB ports.

<p align='center'> <img title='Top View' src=docs/images/top_view.jpg width="600"> </p> <p align="center"> <img title='Side View' src=docs/images/side_view.jpg width="600"> </p>

🔌 Installation

Development Machine setup

A development machine or PC (laptop or desktop) is used to run more computationally intensive applications like Gazebo and Rviz. Additionally, the PC can be used to remotely control lidarbot.

Ubuntu 22.04 LTS is required for this project to work with ROS2 Humble. Ubuntu 22.04 LTS can be installed on a PC by following this guide. The ROS2 Humble installation procedure is available here. The Desktop version is installed on the PC (which includes RViz):

sudo apt install ros-humble-desktop

Then install the ROS development tools:

sudo apt install ros-dev-tools

After the ROS2 Humble installation, crea

View on GitHub
GitHub Stars201
CategoryDevelopment
Updated7d ago
Forks38

Languages

Python

Security Score

100/100

Audited on Mar 16, 2026

No findings