Project D: Rover with mechanum wheels - matthew-mizielinski/BroadclystCodeClub GitHub Wiki
Project D
, just D
hereafter, is the fourth rover I've built after
- Audrey (Raspberry pi zero + camera & 2 wheels, dismantled),
- Bessie (microbit + 2 wheels)
- Charlie (Raspberry Pi Zero + caterpilar tracks + servos & camera)
D
will be given a name later in the year via a naming competition
D
is controlled via a microbit and has 4 motors driving a set of mechanum
wheels.
Mechanum wheels are interesting in that they
consist of a set of rollers on the face of each wheel set at 45 degrees to the edge of the
wheel, and when rotated the overall effect is a force pushing perpendicular to the rollers,
i.e. at 45 degrees.
A set of mechanum wheels consists of two pairs of slightly different wheels one set being a mirror image of the other, with opposite corners having the same orientation.
There is a really nice set of diagrams of this here (Team Jelly Fish blog)
So by controlling each motor independently a host of different motions can be obtained.
To control all four motors would require 8 output pins on the microbit, which is more than it can comfortably provide. I've used an I2C IO expander, essentially an 8-bit register than can be written to or read from using the I2C protocol, which is run of a dedicated pair of pins from the microbit.
This protocol is really simple; send a number in a particular form to a particular address. The I2C io expander has a default address of
0x20
for writing (32
in decimal) so sending an 8 bit unsigned integer to it is sufficient to set the state of all four motors.
The motors are connected up in the following order (from most to least significant bits); front left, rear left, rear, right, front right
with two bits for each.
As noted above the wheels provide driving force at 45 degrees, so when all wheels are driven forward the front left and rear right
push NE and the front right and rear left push NW from their respective corners (where North is forward), with a net force northward.
The required bits are
Wheel | Front left | Rear left | Rear right | Front right | Net result |
---|---|---|---|---|---|
Control bits | 1 0 |
1 0 |
1 0 |
1 0 |
10101010 = 170 |
Wheel drive direction | NE | NW | NE | NW | N |
The more interesting behaviour comes if the transverse, i.e. E-W, components of the drive from each wheel are aligned;
Wheel | Front left | Rear left | Rear right | Front right | Net result |
---|---|---|---|---|---|
Control bits | 0 1 |
1 0 |
0 1 |
1 0 |
01100110 = 102 |
Wheel drive direction | SW | NW | SW | NW | W |
A useful diagram from Shao et al gives various different configurations, each of which can be represented as a single control number;
An example simple make code program that can run a sequence of different movements is available here
The rover also has a piezo buzzer attached to pin 0 (part of the sensor:bit used to attach the microbit) allowing annoying music to be played, and a sonar:bit attached to pin 1 giving a fairly crude distance sensor facing forward (Example code ).
Further extensions are planned to include a set of neopixels and a servo mounted VL53L1X Time of Flight distance sensor.