How It Works
Mecanum wheels are very unique
looking. Each wheel has rollers offset
by 45 degrees from the wheel and
the drive train. This causes the motors
to introduce force at 45 degree
angles. Different combinations of
force vectors can combine/cancel to
produce movement in all directions.
This means that running all
wheels in the same direction will
result in a forward or backwards
direction; running one side in the
opposite direction of the other will
result in rotation; and running the
wheels on one diagonal in the
opposite direction of the other
diagonal will result in sideways
Rotation of a single mecanum wheel
provides a "force vector" perpendicular
to the rollers. This is the direction that the
wheel would want to move.
Mecanum wheels are mounted
on a 4WD robot as shown. Note
the orientation of the rollers.
Two of the wheels are mounted
with the rollers at +45 degrees
and two with rollers oriented
at -45 degrees.
When putting on mecanum wheels, the rollers of the
wheel should create an X when viewed from the top.
Meanwhile, on the bottom the rollers should create a
diamond. This is an important rule to follow or else the
behavior of the robot will not act as expected.
Another important item to consider when using a
mecanum drive system is weight distribution and build
quality. The mecanum works on the principle of combining
and canceling vectors. If the motors cannot match each
other, the motion of the robot will not be as expected.
int Y1, X1; // Vertical, Horizontal Joystick Values
int rotation; // Rotation Joystick Values
int deadband = 20; // Threshold value for deadzone
// Get value of three joysticks used for speed and
// Other platforms may have different code for this.
Y1 = vexRT[Ch3]; // Vertical axis
X1 = vexRT[Ch4]; // Horizontal axis
The source code to control the
robot is amazingly simple. The
complete program is barely 20 lines of
code. Since joysticks do not always
return exactly to the center value of
zero, a small dead zone is used to treat
all values close to zero as zero.
// Implement dead zones to compensate for joystick values
// not always returning to zero
The actual power applied to each
of the four motors is a simple formula
of the three joystick axes.
if (abs(Y1) < deadband)
Y1 = 0;
if (abs(X1) < deadband)
X1 = 0;
if (abs(rotation) < deadband)
rotation = 0;
The software was written in
ROBOTC – a dialect of the popular C
programming language optimized for
use with robots.
// Convert joystick values to motor speeds
motor[frontRight] = Y1 - X1 - rotation;
motor[backRight] = Y1 + X1 - rotation;
motor[frontLeft] = Y1 + X1 + rotation;
motor[backLeft] = Y1 - X1 + rotation;
If you’re building your own robot,
you may find that one or more motors
move in the opposite direction than
intended. You can change this by
reversing the two wires to the motor.
Or, with ROBOTC, there’s a command
(not shown) to have software
implement a motor direction reversal.
SERVO 09.2013 45