A comprehensive control system for a six-legged robot (hexapod) using BeagleBone AI (or Black), featuring both kernel-space drivers and user-space applications with reinforcement learning capabilities.
This project implements a complete software stack for controlling a 6-legged robot with 18 servo motors (3 per leg), including:
-
Kernel-Space Components:
- Linux kernel driver for servo control (PCA9685 PWM controllers)
- IMU sensor driver (MPU6050) for orientation sensing
- Hardware abstraction layer for unified device access
-
User-Space Components:
- Kinematics library for precise leg positioning
- Gait generation for various walking patterns
- Calibration system for mechanical offset compensation
- Interactive control interface
-
Reinforcement Learning:
- TD3 (Twin Delayed Deep Deterministic Policy Gradient) implementation
- Hardware acceleration via TIDL and OpenCL
- Simulation-to-real transfer capabilities
- On-robot inference engine
The system follows a layered architecture with hardware abstraction. For visual reference, see the architecture diagrams in the /docs/diagrams/out
directory:
- Deployment Diagram: Hardware and software deployment
- Component Diagram: Hardware component interactions
- Sequence Diagram: Runtime interactions
- State Diagram: Hardware state transitions
- Class Diagram: Software class structure
- Building Process: Build and deployment process
.
├── driver/ # Linux kernel device drivers
├── app/ # User applications and libraries
├── docs/ # Documentation
└── scripts/ # Build and utility scripts
- Multiple gait patterns (tripod, wave, ripple)
- Real-time IMU feedback
- Inverse kinematics for precise leg control
- Hardware abstraction layer
- Comprehensive test suite
- Interactive debugging tools
- BeagleBone AI (or Black) running Linux 4.14+
- I2C enabled (bus 3)
- 18x servo motors (MG996R recommended)
- MPU6050 IMU sensor
- 2x PCA9685 PWM controllers
-
Build the kernel module:
cd driver make
-
Install the kernel module:
sudo insmod hexapod_driver.ko
-
Build user-space applications:
cd app make
-
Run the test utility:
sudo ./test_servo
See individual README files in subdirectories for detailed development guides:
Run the test suite:
cd app
make
Individual tests:
./test_servo # Test servo control
./test_mpu6050 # Test IMU sensor
./test_movement # Test movements like tripod, ripple, ...
./test_calibration # Test servos offset for each leg
- Zero IMU readings: The MPU6050 enters sleep mode to save power. The driver now automatically wakes it before readings.
- Erratic IMU behavior: Check I2C connections and ensure proper power supply voltage.
- Servos not moving: Check power supply and ensure driver is properly loaded
- Erratic movement: Verify calibration settings and check for loose connections
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the GPL License - see the LICENSE file for details.
- StrongFood - I mean "TrongPhuc"
- BeagleBoard.org
- Linux Kernel Community