An Mecanum robot is a platform that combines four wheels with diagonal rollers to translate and rotate without first orienting the chassis.
Mecanum wheels (invented by Bengt Ilon in 1973) are an engineering marvel. Unlike conventional Omni wheels, their rollers are mounted at 45 degrees to the main axis.
This changes the game. While in the triangular Omni robot the forces canceled out in an obvious way, here we have a much more stable rectangular configuration capable of carrying weight, but requiring a very specific vector combination to move sideways.
This is the system used by professional logistics platforms like those from Kuka or Amazon warehouse robots to move in tight spaces without maneuvering.
The Theory: The Force in X
The secret of Mecanum wheels lies not only in the wheel itself, but in how they are mounted. Not all wheels are the same; there are “Left Wheels” and “Right Wheels” (mirrored).
For the system to work, we must mount them so that, viewed from above, the rollers form an X pointing towards the center of the robot.
- The front wheels push the ground inward.
- The rear wheels also push inward.
Vector Decomposition
When rotating, a Mecanum wheel generates a diagonal force at 45º.
- If we rotate all of them forward, the lateral components cancel out and the robot moves forward.
- If we rotate the wheels on one side inward and the wheels on the other side outward, the longitudinal components cancel out and the robot slides sideways.
The kinematics to calculate the speed of each wheel (
Where:
: Front Left : Front Right : Rear Left : Rear Right
Be careful with the signs! These formulas assume a standard motor orientation. If a motor is mounted backward, you will need to invert its sign in the code.
Components
- [1x|blue] Arduino Uno | Or Mega (more pins and memory)
- [4x|green] Continuous Rotation Servos | FS90R or MG996R
- [4x|orange] Mecanum Wheels | 2 Right + 2 Left
- [1x|gray] Rectangular Chassis | 3D printing or laser cutting
- [1x|red] Regulated Power Supply | Voltage rating for servos and sufficient current for all four
Watch out for this. 4 servos starting up at the same time can reset any small battery.
Connection Diagram
The wiring is similar to the previous project, but adds one motor. Servo.h can use normal digital pins; it doesn’t need them to have hardware PWM.
Servo Signals
Each wheel has its own control signal.
[ { “from”: “Front Left Servo (FL) signal”, “to”: “Pin 6”, “color”: “green” }, { “from”: “Front Right Servo (FR) signal”, “to”: “Pin 9”, “color”: “green” }, { “from”: “Rear Left Servo (RL) signal”, “to”: “Pin 10”, “color”: “green” }, { “from”: “Rear Right Servo (RR) signal”, “to”: “Pin 11”, “color”: “green” } ]
Servo Power Supply
Four servos starting up at the same time draw significant current. Power them from an external battery or source, with a common GND.
[ { “from”: “Servos VCC (all, +)”, “to”: “Battery (+)”, “color”: “red”, “note”: “NOT to Arduino” }, { “from”: “Servos GND (all, -)”, “to”: “Battery (-) + Arduino GND”, “color”: “black”, “note”: “Mandatory common ground” } ]
The Code
We will create a “Mixer” that receives our commands (go forward, go sideways, rotate) and calculates what each individual wheel must do.
A critical point that many tutorials overlook is normalization. If you ask the robot to go 100% forward (
Definitions and setup
#include <Servo.h>
// Define the 4 servos
Servo servoFL; // Front Left
Servo servoFR; // Front Right
Servo servoRL; // Rear Left
Servo servoRR; // Rear Right
// Pins
const int PIN_FL = 6;
const int PIN_FR = 9;
const int PIN_RL = 10;
const int PIN_RR = 11;
void setup() {
Serial.begin(9600);
servoFL.attach(PIN_FL);
servoFR.attach(PIN_FR);
servoRL.attach(PIN_RL);
servoRR.attach(PIN_RR);
stopRobot();
delay(1000);
}
Kinematic Mixer
void moverMecanum(float x, float y, float w) {
// x: Lateral movement (-1.0 to 1.0)
// y: Forward movement (-1.0 to 1.0)
// w: Rotation (-1.0 to 1.0)
// 1. Apply the vector formulas
// Note: Depending on your wiring, you may need to invert (+/-) some term
float fl = y + x + w;
float fr = y - x - w;
float rl = y - x + w;
float rr = y + x - w;
// 2. Normalization (Maintains correct direction if motors saturate)
// Find the highest absolute value
float maxVal = max(abs(fl), max(abs(fr), max(abs(rl), abs(rr))));
// If any exceeds 1.0, divide all by that maximum
if (maxVal > 1.0) {
fl /= maxVal;
fr /= maxVal;
rl /= maxVal;
rr /= maxVal;
}
// 3. Send to servos
escribirServo(servoFL, fl);
escribirServo(servoFR, fr);
escribirServo(servoRL, rl);
escribirServo(servoRR, rr);
}
void escribirServo(Servo &s, float val) {
// Map -1.0 to 1000us and 1.0 to 2000us
// 1500us is the neutral point (stop)
// Sometimes you need to invert (val * -500) if the wheel spins backwards
int pwm = 1500 + (val * 500);
s.writeMicroseconds(pwm);
}
void stopRobot() {
moverMecanum(0, 0, 0);
}
Demonstration loop
Let’s perform the signature Mecanum maneuver: The square without turning. The robot will draw a square on the floor while always keeping its “front” facing the same direction.
void loop() {
// 1. Forward
moverMecanum(0, 1.0, 0);
delay(1000);
// 2. Strafe Right
moverMecanum(1.0, 0, 0);
delay(1000);
// 3. Backward
moverMecanum(0, -1.0, 0);
delay(1000);
// 4. Strafe Left
moverMecanum(-1.0, 0, 0);
delay(1000);
// 5. Spin
moverMecanum(0, 0, 1.0);
delay(2000);
stopRobot();
delay(2000);
}
Troubleshooting Common Issues
In this project, 99% of failures are physical.
- The robot doesn’t move sideways, turns weird: You mounted the wheels incorrectly. Remember the X rule. The rollers must point to the center of the chassis. If they form an “O” (diamond), the robot won’t work properly.
- A wheel doesn’t spin or the Arduino resets: Lack of current. 4 servos draw a lot. Check your batteries and the thickness of your power cables.
- The robot drifts sideways when I want to go straight: Continuous rotation servos are not precise. One likely spins slightly faster than another. You will need to adjust the values in the code (multiplying by a correction factor, e.g.,
fr * 0.95).
Next Steps
You can add encoders to close the speed loop, a joystick to generate x, y, and w, or distance sensors to avoid obstacles. Lateral mobility provides maneuvering options, although autonomous navigation still requires position estimation and path control.