Skip to content

Simulator

Before your robot stands on the floor, you can watch a virtual one do it. The simulator runs the same program you'll write: it reads an MPU6050 that gives realistic raw numbers, fuses them with the complementary filter, runs PID with the dead zone and the tilt cutoff, and adds the Class 5 outer loop on the encoder counts. The body falls the way a real one does.

Open the simulator

What you can do

  • Pick a class. Each of the six stages loads that class's settings and suggests what to try.
  • Watch the numbers. The raw registers (ax, ay, az, gx), the angles your code computes and the PWM it sends update live, next to Teleplot-style plots of the last 10 seconds.
  • Turn the knobs. α, Kp, Ki, Kd, balancePoint, the dead zone, Ks and Kpos are sliders. Switch off the gyro calibration, the filter or the dead-zone compensation and see what breaks.
  • Test it. Push it, put a water bottle on top, and drive it: hold → to roll forward and ← to roll back (Class 5 and 6). In Classes 1 and 2 the arrows tilt the robot in your hand.

Things to notice

  • Tap the table or slide the robot in Class 1: the accelerometer angle jumps even though the tilt didn't change.
  • In Class 3, P alone catches the first fall but can't hold it for long.
  • In Class 4, set Ki to 0, or nudge balancePoint by a few tenths of a degree, and watch it run off.
  • In Class 6, push it with α at 0.995, then at 0.98. When the wheels speed up hard, the accelerometer reads that as a lean.

A model, not your robot

The simulator assumes a motor, wheel size and weight close to ours, but your robot will be different. It also leaves out gear slack, wheel slip and a draining battery. Use it to understand why things happen. Find your real gains with the knobs on your robot.