Dual Self-Balancing Robot System
A two-wheel self-balancing robot platform using Teensy 4.1, ODrive CAN motor drivers, and IMU-based sensor fusion to achieve stable balance and responsive motion.
Overview
This project explores the design and implementation of a two-wheel self-balancing robot system. The goal was to build a platform that can maintain an upright pose while responding to disturbances and motion commands, using closed-loop control and real-time sensor feedback.
The robot uses a Teensy 4.1 microcontroller communicating with ODrive motor drivers over CAN, combined with IMU measurements for tilt estimation and control. The platform is designed as a testbed for experimenting with different control strategies, sensor fusion approaches, and motion behaviors.
Problem & objectives
Self-balancing robots are inherently unstable and require continuous feedback control. The main objectives were to:
- Estimate the robotβs tilt angle and angular velocity in real time.
- Design a controller that maintains balance around an upright position.
- Integrate the control loop with ODrive motor drivers over CAN.
- Develop a platform that can be extended for future behaviors (e.g., driving, turning).
System design & architecture
The system is built around a Teensy 4.1 board, which reads IMU data, runs the control loop, and sends torque/velocity commands to an ODrive motor driver over CAN. Encoder feedback from the motors is handled by the ODrive, which closes the inner motor control loop.
High-level architecture:
- IMU β tilt angle & angular rate estimation
- Control loop (on Teensy) β motor torque/velocity setpoints
- Teensy β ODrive (CAN) β motor currents/velocity
- Mechanical structure β two in-line wheels and battery pack
Later we can drop in a clean block diagram image here once you export it from MATLAB/Simulink or your notes.
Control & algorithms
The controller is based on a classic inverted pendulum formulation. IMU data is filtered to estimate the tilt angle, and a feedback controller (e.g., PID or LQR-style) computes motor setpoints to counteract deviations from upright.
Key elements:
- IMU filtering (e.g., complementary filter using accelerometer + gyro).
- Feedback controller tuned to reject disturbances (pushes, small external forces) while avoiding oscillation.
- CAN messaging to send motor commands with low latency.
Results
The robot is able to maintain balance around the upright position and recover from small pushes. With tuning, it can remain stable for extended periods and respond to changes in the setpoint.
This platform sets the stage for future work including:
- Commanded forward/backward motion while maintaining balance.
- Trajectory following and path planning.
- Integration with higher-level perception or remote control.
What I learned
This project pulled together multiple layers of robotics: embedded firmware, motor control, CAN communication, sensor fusion, and control theory. It reinforced the importance of:
- Careful bring-up and testing of each hardware subsystem.
- Good debugging tools (serial logs, plotting, step testing).
- Iterative tuning instead of expecting perfect behavior on the first try.