Mecanum Wheel Robot Simulator

Configure your physical motor wiring, test drive behavior, and auto-generate corrected PlatformIO C++ calibration code for your Arduino Uno R4 WiFi + Duinotech Shield.

Manual Drive Pad

Command the simulator's target directions. Observe wheel movements.

Simulated Environment
Virtual Physics Sandbox

💡 Interactivity: Drag the red target circle to move the physical ultrasonic obstacle!

Hardware Wiring Map ?
If your physical wires are hooked up randomly to terminal blocks M1, M2, M3, M4, adjust the assignments below to match.
Chassis Position Shield Port Direction
Left Front (LF)
Right Front (RF)
Left Rear (LR)
Right Rear (RR)
Telemetry
Distance (Ultrasonic): 150 cm
Microphone Feed: Quiet
Chassis Motion: Stopped
Effective Motor Outputs: M1: 0, M2: 0, M3: 0, M4: 0
Live Arduino Code Output (PlatformIO Compatible)

This sketch dynamically uses your current wiring matrix parameters. When Software Calibration is enabled above, it handles the port redirection logic inside software, allowing you to copy, paste, and compile without swapping physical jumper wires.

Loading custom code matrix...

Overview

Mecanum wheels allow omnidirectional locomotion through specialized configurations of diagonal rollers integrated along their circumferences. By carefully controlling the relative speed and direction of the individual motors driving each corner, a vehicle can move forward, backward, slide laterally (strafe), drive diagonally, or rotate in place.

This application simulates the physics and kinematics of a 4-wheel mecanum chassis, specifically mirroring a custom physical hardware setup using an Arduino Uno R4 WiFi and a **Duinotech Motor Shield (XC4472)**. A major bottleneck of robotic assembly is random motor wiring. Swapping polarity or wiring the left-rear motor into a front driver terminal is easy to do by accident. This simulator behaves as a visual sandbox, demonstrating exactly what occurs when your motors are incorrectly assigned, and provides a direct, zero-effort software solution by rendering custom-tailored correction code ready for deployment on PlatformIO.

How to Use

  1. Select Target Commands: Use the Manual Drive Pad to command the robot to move in various direction vectors. Note how the wheels rotate (represented by green speed arrows on each wheel corner).
  2. Introduce Wiring Anomalies: Go to the Hardware Wiring Map. Try swapping port selections (e.g., mapping Right Front to M3) or inverting the polarities. Drive the robot again. You will observe that a simple "Forward" command now forces the robot to rotate or drift irregularly.
  3. Implement Software Calibration: Toggle the Enable Software Calibration checkbox. This forces the microcontroller's control program to dynamically route motor speed outputs to their corrected channels before writing commands to the shield's physical registers, resolving the random assembly layout.
  4. Export to Hardware: View the auto-updating code panel. Your custom ports and inversions are embedded into clean C++ functions utilizing the classic AFMotor.h library compatible with the Duinotech XC4472 module. Click **Copy Code** and compile directly within VSCode via PlatformIO.
  5. Interact with Sensors: Click and drag the red obstacle target on the canvas. Place it in the path of the robot's front ultrasonic sensor cone to view distance measurements. Use the microphone "Sound Trigger" to simulate noise alerts.

Technical Details

The Mecanum wheel kinematic engine maps the input movement vector $(V_x, V_y, \omega)$ (representing lateral strafe, forward travel, and rotational velocity) to individual wheel angular velocities using standard structural equations:

When standard uncalibrated firmware drives the shield, it commands ports $M_1 \rightarrow LF$, $M_2 \rightarrow RF$, $M_3 \rightarrow LR$, and $M_4 \rightarrow RR$. If physical connections mismatch, the simulator remaps the visual wheel outputs directly based on the user's calibration configuration:

physicalLF_Speed = ports[config.lf_port].val * config.lf_polarity_multiplier;
physicalRF_Speed = ports[config.rf_port].val * config.rf_polarity_multiplier;
//...and so on for rear wheels

Audio Capabilities: An integrated sound synthesis loop leverages the Web Audio API. It remains suspended until user activation via the Sound Toggle. Once unlocked, it generates a real-time dynamic pitch representing DC motor frequency loads, combined with periodic ultrasonic pings that shift in frequency as the obstacle approaches.

Future Directions

BioniChaos Modality & Simulators Directory

Explore our external collection of interactive biological, signal processing, and medical simulators hosted across the BioniChaos network: