In the video you can see that the robot stays at roughly the same spot on the floor and handles a lighter push without any problem. To achieve this I have two cascade PID controllers and low pass filter on both wheel speed and the robot's angle.
As an Arduino does not have a lot of processing power, I chose to use a total of 3 microprocessors:
- A standalone Arduino Uno takes pulses from the tachometer on each wheel and converts it to a speed. The speed is sent to the main micro processor.
- One more stand alone Arduino Uno to view and adjust parameters. Also drives the display. The parameters are sent to the main micro processor.
- Arduino Leonardo is the brain. It receives information from the console and the engine speed sensor via I2C.
Basic control theory
Two cascaded PID controllers. The first has speed as setpoint (always 0 in this case) and angle as output. If the robot is moving forward, the controller will have a positive input value and send a negative output value. This means that the robot will want to lean back to slow down.
PID number 2 takes care of the robot's angle relative to the floor. The setpoint is the output of the previous PID controller. Normally the set point will range from -3 till 3. Zero corresponds to the robot standing completely straight up. The output is connected to the engine management and rtos from -100 till 100. -100 corresponds to full voltage to the motors in reverse direction.
To get cleaner inputs I use FIR filters for both angle and wheel speed. Low-pass filter blocks rapid change (for example, sensor noise) from passing through.
For the angle relative to the floor, a IMU with accelerometer and gyro is used. A complementary filters combines the signals to give an useful value.
I had the objective that all code for this project should be open sourced and available for download from github. The readme contains links to libraries I have used.
Improvements that could be made
- Better parameters to the FIR filter. Much could probably be done on the wheel speed.
- On-the-fly programming over the air with Xbee. This means that you can send new code to the robot without USB cable. Will make programming more flexible.
- Radio control would be nice.
- 3 plates in carbonate.
- 2 threaded rods, nuts and washers
- Arduino Leonardo
- 2 st A standalone Arduino
- Breadboard 830 seq
- Breadboard 400 seq
- Pololu 12V, 29:1 Gear Motor w / Encoder
- Pololu Wheel 90 x 10mm Black (Pair)
- Pololu Universal Aluminum 6mm Mounting Hub (4-40)
- Pololu 37D mm Metal Gearmotor Bracket (Pair)
- 6 Degrees of Freedom ±2000° / sec ±16g IMU – ITG3200 / ADXL345
- Arduino Motor Shield rev 3
- BAT-01 Battery Pack NiMH 12V 1600mAh
- Nokia 5110 display
- + cables, Button, resistance and other bits
I am also publishing cad and drawings.