Robotic Segway for Ball Tracking
After accumulating enough tools and electronic kits, I wanted to build an interdisciplinary project that combines mechanical, electrical, and software skills. A robotic segway that incorporates inverse pendulum and computer vision seemed to be a great hobby project so I scavenged an old iRobot Braava for chassis, Arduino for controls, and Raspberry Pi for camera tracking.
This is currently an on-going project that I've received much pointers from open-source libraries and resources. Purpose of the project is to familiarize myself with RPi, I2C communication (IMU data and RPi to Arduino), and controls. The inverse pendulum integration still remains incomplete.
With Jeff Rowberg's IMU library, I could use Processing software to graphically display the pitch data from the sensor.
openCV and python used to track orange pingpong ball and return X,Y coordinate via I2C. Code sequence: raw input > resize resolution > HSV threshold > de-noise > max contour > get circle > get centroid, overlay circle to raw input
2 separate power supplies were used for better isolation and power efficiency. Arduino Uno handled the optical encoders on each wheel with interrupts, and used that input to match motor speed with PID control. The Raspberry pi solely handled the vision aspect and returned the coordinates to the Arduino via I2C.
The block diagram on the left illustrates how the system breaks down.
The main frame of the segway was derived from an old iRobot Braava model, which I scavenged for the chassis and optical encoders. I then added a motor shield and Arduino to customize the drive. For fun, I added an nRF bluetooth module that allowed me to control the drive directions with my smartphone. After verifying correct motor control, I 3D printed the segway body to create an upright platform (blue PLA material). The circuit on the breadboard is a simple comparator with op-amp to floor/ramp analog inputs for the encoders. I then added the USB camera and Raspberry Pi model B+ with openCV to handle ball tracking.