This project is an implementation of an Autonomous Mobile Robot (AMR) using an ESP32 microcontroller. The robot is equipped with motor control, PID management, encoder feedback, and micro-ROS communication.
Before getting started, install the following libraries in Arduino IDE:
| Library | Version |
|---|---|
| PID | 1.2.0 |
| ArduinoJson | 7.3.0 |
| ESP32Servo | 3.0.6 |
| ESP32Encoder | 0.11.7 |
| EspSoftwareSerial | 8.1.0 |
| Adafruit PWM Servo Driver Library | 3.0.2 |
Follow these steps to manually install Micro ROS Arduino Library (Humble):
-
Download the Library
- Visit the Micro ROS Arduino Repository.
- Download the latest Humble ZIP package.
-
Add Library to Arduino IDE
- Open Arduino IDE.
- Navigate to Sketch → Include Library → Add .ZIP Library.
- Select the downloaded
micro_ros_arduino.zipand click Open.
-
Done! 🎉
- Micro ROS is now installed and ready to use in your Arduino projects.
- Define the required GPIO pins in
params.hppbased on your hardware setup.
- If you need reverse mode, uncomment the following line in
params.hpp:#define REVERSE_PINS
-
Serial Communication:
- The serial communication is handled by CarSerial.cpp and CarSerial.h. It supports both software and hardware serial communication.
-
PID Management:
- The PID control for the motors is managed by PIDManager.h.
-
Encoder Management:
- The encoder feedback is managed by EncoderManager.cpp and EncoderManager.h.
-
Micro-ROS Communication:
-
Visit the Micro ROS Arduino release page and download the ZIP file corresponding to your ROS2 version.
-
The micro-ROS communication is implemented in micro_ros.cpp and micro_ros.hpp.
-
-
Tasks:
- The main tasks are defined in
AMR_car_esp32.ino:- TaskSerialRead
- TaskSerialWrite
- TaskTestPID
- TaskServo
- TaskPID
- The main tasks are defined in
In params.hpp, there is the following definition:
#define REVERSE_PINSTo enable reverse mode, declare this variable. Otherwise, comment out this variable.