A complete autonomous docking system for mobile robots using ROS2 Humble and Gazebo simulation. This project demonstrates advanced robotics concepts including state machine control, battery management, autonomous navigation, and precision docking maneuversโall essential skills for modern autonomous mobile robots (AMRs) and service robotics.
Key Achievement: Successfully implemented a fully autonomous docking system where a TurtleBot3 robot detects low battery conditions, navigates to a charging station, performs precision alignment, and docks autonomouslyโall without human intervention.
Long-term autonomy is one of the greatest challenges in mobile robotics. Robots must be able to:
- Monitor their own battery levels
- Autonomously return to charging stations when needed
- Perform precise docking maneuvers for reliable charging contact
- Resume operations after recharging
This project addresses these challenges by implementing an industry-standard autonomous docking solution used in:
- Warehouse robots (Amazon, FedEx fulfillment centers)
- Service robots (hotel delivery, hospital logistics)
- Cleaning robots (commercial floor cleaners)
- Security robots (autonomous patrol systems)
- ROS2 Humble - Robot Operating System 2 (LTS version)
- Gazebo 11 - Physics-based 3D robot simulator
- Python 3.10 - Core programming language
- TurtleBot3 - Industry-standard mobile robot platform
- State Machine Architecture - Robust control system design
- Sensor Integration - Odometry, laser scanning, battery monitoring
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Battery Monitor โโโโโโถโ Low Battery Signal โ
โ (Discharge Model) โ โ (/low_battery) โ
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Docking Controller โ
โ (State Machine) โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Odometry โ โ Laser Scanner โ โ Velocity Cmd โ
โ (/odom) โ โ (/scan) โ โ (/cmd_vel) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Real-time battery state monitoring with discharge simulation
- Configurable low-battery threshold triggering
- Battery state publishing (voltage, current, percentage, health)
- IDLE - Waiting for low battery signal
- NAVIGATING_TO_DOCK - Long-range navigation to dock area
- APPROACHING_DOCK - Controlled approach with obstacle awareness
- FINE_ALIGNMENT - Precision angular and positional alignment
- DOCKING - Final docking maneuver
- DOCKED - Charging mode with status monitoring
- Distance and angle calculations to target dock
- Adaptive velocity control based on distance to target
- Smooth transitions between docking phases
- Collision-aware approach strategies
- Custom world with enclosed room and obstacles
- Visually distinct charging dock (green platform with yellow marker)
- Full TurtleBot3 simulation with sensors and actuators
- Real-time physics and sensor simulation
automated_docking_ws/
โโโ src/
โ โโโ automated_docking_project/
โ โโโ automated_docking_project/
โ โ โโโ __init__.py
โ โ โโโ battery_monitor.py # Battery simulation & monitoring
โ โ โโโ docking_controller.py # State machine controller
โ โโโ launch/
โ โ โโโ automated_docking_launch.py # Main launch file
โ โโโ worlds/
โ โ โโโ docking_world.world # Gazebo world file
โ โโโ config/
โ โโโ package.xml
โ โโโ setup.py
โโโ build/
โโโ install/
โโโ log/
- Operating System: Ubuntu 22.04 LTS
- ROS2: Humble Hawksbill
- Python: 3.10 or higher
- Gazebo: 11.x
1. Install ROS2 Dependencies
sudo apt update
sudo apt install ros-humble-turtlebot3-gazebo
sudo apt install ros-humble-turtlebot3-navigation2
sudo apt install ros-humble-turtlebot3-msgs
sudo apt install ros-humble-gazebo-ros-pkgs2. Clone the Repository
cd ~
git clone https://github.com/samshoni/ros2-autonomous-docking.git
cd ros2-autonomous-docking3. Set Environment Variables
export TURTLEBOT3_MODEL=waffle_pi
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/humble/share/turtlebot3_gazebo/models4. Build the Workspace
colcon build
source install/setup.bashsource install/setup.bash
export TURTLEBOT3_MODEL=waffle_pi
ros2 launch automated_docking_project automated_docking_launch.pyThis launches:
- Gazebo simulator with custom world and docking station
- TurtleBot3 robot at origin position
- Battery monitoring node
- Docking controller node
- RViz2 for visualization
Option 1: Automatic Trigger (Recommended for Demo)
Wait for battery to drain from 100% to 20% (~3 minutes). The system will automatically initiate docking.
Option 2: Manual Trigger (For Testing)
Open a new terminal and publish low battery signal:
source install/setup.bash
ros2 topic pub /low_battery_signal std_msgs/msg/Bool "data: true" --onceCheck Active Topics:
ros2 topic listMonitor Battery Status:
ros2 topic echo /battery_stateView Robot Odometry:
ros2 topic echo /odomMonitor Velocity Commands:
ros2 topic echo /cmd_vel| State | Trigger | Actions | Next State |
|---|---|---|---|
| IDLE | Low battery signal | None | NAVIGATING_TO_DOCK |
| NAVIGATING_TO_DOCK | Distance < 1.0m | Navigate with obstacle avoidance | APPROACHING_DOCK |
| APPROACHING_DOCK | Distance < 0.5m | Slow controlled approach | FINE_ALIGNMENT |
| FINE_ALIGNMENT | Aligned & Close | Precision angular correction | DOCKING |
| DOCKING | Distance < 0.3m | Final straight approach | DOCKED |
| DOCKED | Charging complete | Stop all motion | IDLE (manual) |
# Docking Configuration
dock_position = [2.0, 2.0] # Target dock coordinates
approach_distance = 1.0 # Distance to start approach phase
dock_distance = 0.3 # Final docking distance threshold
alignment_tolerance = 0.1 # Angular alignment tolerance (rad)
# Velocity Limits
max_linear_speed = 0.3 # Maximum forward velocity (m/s)
max_angular_speed = 0.5 # Maximum turning velocity (rad/s)
# Battery Parameters
low_battery_threshold = 20.0 # Trigger docking at 20%
discharge_rate = 0.5 # Battery drain rate (%/second)Published Topics:
/cmd_vel[geometry_msgs/Twist] - Velocity commands to robot/battery_state[sensor_msgs/BatteryState] - Battery status/low_battery_signal[std_msgs/Bool] - Low battery trigger
Subscribed Topics:
/odom[nav_msgs/Odometry] - Robot odometry/scan[sensor_msgs/LaserScan] - Laser scanner data/low_battery_signal[std_msgs/Bool] - Battery status trigger
โ
Successful autonomous docking from arbitrary starting positions
โ
Precision alignment within 0.3m of dock center
โ
Smooth state transitions with no oscillations
โ
Robust battery monitoring with realistic discharge simulation
โ
Real-time control at 10Hz update rate
โ
100% success rate in controlled simulation environment
Custom simulation environment with TurtleBot3 and charging dock
Robot autonomously navigating toward the charging station
Precision alignment and final docking maneuver
Real-time visualization of robot pose, TF frames, and sensor data
System logs showing state transitions during autonomous docking
Battery state monitoring with discharge simulation
Through this project, I gained practical experience with:
- State Machine Design - Implementing robust finite state machines for complex behaviors
- Autonomous Navigation - Distance/angle calculations and path planning
- Sensor Integration - Fusing odometry and laser data for localization
- ROS2 Architecture - Publisher/subscriber patterns, message types, launch systems
- Battery Management - Realistic power modeling and autonomous charging logic
- Simulation Development - Creating custom Gazebo worlds and robot environments
- Control Systems - Velocity control, PID concepts, and adaptive behaviors
- Add AprilTag/ArUco marker-based visual docking for higher precision
- Implement Nav2 integration for advanced path planning with costmaps
- Add dynamic obstacle avoidance during docking approach
- Integrate camera-based dock detection and recognition
- Implement charging simulation with battery recharge logic
- Add multi-robot coordination for shared charging stations
- Deploy on physical TurtleBot3 hardware
- Add ROS2 bag recording for performance analysis
- Implement emergency undocking procedures
This project is licensed under the MIT License - see the LICENSE file for details.
Sam Shoni
- GitHub: @samshoni
- LinkedIn: https://www.linkedin.com/in/sam-shoni-7b2b94301/
- Email: samshoni10@gmail.com
- ROS2 and Open Robotics community
- TurtleBot3 platform developers (ROBOTIS)
- Gazebo simulation team
- Open-source robotics contributors
- ROS2 Humble Documentation
- TurtleBot3 Documentation
- Gazebo Simulation Documentation
- Autonomous Mobile Robots: Fundamentals and Applications
- State Machines in Robotics Control Systems
โญ If you find this project useful for your robotics learning journey, please consider giving it a star!