Angular velocity versus linear velocity
Why a gyroscope gives the body's angular velocity directly (the same at every point of a rigid body) while linear velocity depends on where you look (v = v_c + ω × r) and is not measured by an IMU at all.
What it demonstrates
Why a gyroscope gives the body's angular velocity directly (the same at every point of a rigid body) while linear velocity depends on where you look (v = v_c + ω × r) and is not measured by an IMU at all.
How it works
A planar rigid body (a robot base seen from above) is driven with a commanded turn rate and forward speed, each following its command with a 0.25 s first-order lag so accelerations stay finite. The body pose is integrated at 240 Hz.
For the base centre and for an IMU mounted at offset r along the body x axis, the code computes the world-frame velocity v = v_c + ω × r and acceleration a = a_c + α × r − ω² r. The accelerometer reading is that acceleration rotated into the body frame (gravity is vertical and does not appear in this horizontal view). The gyro reading is ω.
Adjustable parameters
- Motion: spin in place, straight, circle
- Turn rate ω (−3 to 3 rad/s)
- Forward speed (0–1 m/s)
- IMU offset r (0–0.4 m)
Known limitations
- Planar (2-D) motion only; gravity and the vertical axis are left out.
- The IMU is ideal: no noise, bias or latency.
Equations
Core update rule
// lib/sim/ch04-imu.ts — point P at body offset r
const vx = b.vx - b.omega * ry; // v = v_c + ω × r
const vy = b.vy + b.omega * rx;
const ax = b.ax - b.alpha * ry - b.omega ** 2 * rx; // centripetal + tangential
const ay = b.ay + b.alpha * rx - b.omega ** 2 * ry;
gyro = b.omega; // identical at every pointExplained in Chapter 4: Sensors & Data