Skip to content

Adilnasceng/rosardunio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

ROSArduinoBridge – Autonomous Mobile Robot Firmware

This repository contains the Low-Level Control Unit firmware developed for differential drive autonomous mobile robots.
Designed to run on the Arduino Mega 2560, this firmware acts as a bridge between the robot hardware and the ROS 2 (Robot Operating System) navigation stack via serial communication.

This project was developed as part of an autonomous vehicle platform that achieved
🥈 2nd Place in Turkey – TEKNOFEST 2025 Industrial Digital Technologies Competition.


📌 Project Overview

The firmware manages the robot’s actuators (DC motors, servo motors) and sensors (quadrature encoders, battery voltage monitoring, emergency stop).
It communicates with a high-level computer (Raspberry Pi 4) running ROS 2 and provides:

  • Real-time PID speed control
  • Encoder-based odometry data streaming
  • Peripheral and safety management

✨ Key Features

  • ROS 2 Integration
    Optimized serial communication protocol compatible with ros2_control and hardware_interface architectures.

  • Advanced PID Control
    Closed-loop speed control customized for 1000 RPM DC motors.

  • Modular Driver Architecture
    Isolated driver layers for:

    • BTS7960 high-current motor drivers
    • Quadrature encoders
  • Safety Protocols

    • Hardware Emergency Stop (E-Stop)
    • Automatic motor stop on communication loss
  • Peripheral Management

    • DFPlayer Mini–based audio feedback
    • Servo motor control
    • Battery voltage and percentage monitoring

🧩 Hardware Architecture

Component Description
Microcontroller Arduino Mega 2560
Host Computer (SBC) Raspberry Pi 4 (ROS 2 Host)
Motor Driver BTS7960 High Power Motor Driver
Motors 1000 RPM DC Motors with Quadrature Encoders
Audio System DFPlayer Mini (UART)
Power Management Voltage divider for 3S–4S LiPo/Li-ion monitoring

🔌 Pin Configuration

Default pin assignments defined in ROSArduinoBridge.ino and related headers:

Component Function Pin (Mega 2560) Notes
Left Motor PWM Fwd (LPWM) 9 BTS7960
PWM Rev (RPWM) 6 BTS7960
Right Motor PWM Fwd (LPWM) 11 BTS7960
PWM Rev (RPWM) 10 BTS7960
Left Encoder Channel A 2 Interrupt
Channel B 3 Interrupt
Right Encoder Channel A 18 Interrupt
Channel B 19 Interrupt
Audio (DFPlayer) RX (SoftSerial) 12 To DFPlayer TX
TX (SoftSerial) 13 To DFPlayer RX
Servo PWM Signal 4 Mechanism control
Safety Emergency Stop 14 Pull-up input
Signal Buzzer 8 Audio warning
Battery Voltage Read A0 Voltage divider

⚙️ Installation & Setup

Prerequisites

  • Arduino IDE 1.8.x or newer
  • DFRobotDFPlayerMini library
    (Install via Arduino Library Manager)

Configuration

  1. Open ROSArduinoBridge.ino
  2. Ensure the BAUDRATE matches your ROS 2 configuration
    • Default: 57600
  3. Tune PID coefficients in diff_controller.h:
    Kp, Ki, Kd

according to your mechanical system.

Upload

  • Select Arduino Mega 2560 as the target board

  • Compile and upload the firmware


🧪 System Testing & Verification

Before launching ROS 2 nodes, it is strongly recommended to verify hardware and firmware via a direct serial connection.

Step 1: Connection

Connect the Arduino to the Raspberry Pi via USB. Ensure the device is available at:

/dev/ttyACM0 

Step 2: Launch Serial Terminal

python3 -m serial.tools.miniterm /dev/ttyACM0 57600

Step 3: Command Testing

Press Enter after each command.

▶ Motor Test

m 120 120

Expected: Both wheels rotate forward.

⏹ Stop Motors

m 0 0

🔄 Read Encoders

e

Expected Output Example:

1250 1250

🔁 Serial Communication Protocol

A lightweight, single-character command structure is used to minimize communication overhead.

Command Description
m <L> <R> Set motor speeds (ticks/loop)
e Read encoder values
r Reset encoders and PID state
u <Kp>:<Kd>:<Ki>:<Ko> Update PID coefficients
`b <1 0>`
s <index> Play audio file
v <index> Trigger servo (90° → wait 5s → return)
f Read battery voltage and percentage

📄 License

This project is licensed under the MIT License.

🏁 Notes

This firmware was developed for TEKNOFEST 2025 and represents ongoing R&D work in autonomous systems and industrial robotics.

Developed and maintained by Adil NAS with Yigido Team

About

Low-level control firmware for differential drive autonomous mobile robots, providing reliable motor control, sensor management, and ROS 2–compatible serial communication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors