Mathematical foundations for the autonomous mobile robot on the /control page. Differential-drive kinematics with RK4 integration, four navigation controllers, three obstacle avoidance methods, and simulated 72-ray LiDAR. Reference: MEC781 Modules 1–5.
1. Differential-Drive Kinematics
The unicycle model relates body-frame velocities (v, ω) to world-frame pose derivatives.
Integration: 4th-Order Runge-Kutta
The state is advanced using RK4 for numerical accuracy:
2. Navigation Controllers
All four controllers share the same error computation. Given robot pose (x, y, θ) and target (xt, yt):
d = distance error, α = heading error (normalised to [−π, π]).
3. PID Controller
Independent PID loops for linear and angular channels with anti-windup clamping.
Output clamped to [−vmax, vmax]. Integral clamped to ±0.5 for anti-windup.
Output clamped to [−ωmax, ωmax]. Same integral limit for anti-windup.
4. Pure Pursuit Controller
Geometric path-following algorithm. The robot steers toward a look-ahead point at distance Ld ahead on the path.
Short Ld → tight tracking, oscillatory. Long Ld → smooth curves, cuts corners.
Speed proportional to remaining distance. Automatically slows near target.
Eq. (10) derives from the geometry of a circular arc passing through the robot and the look-ahead point. The curvature κ = 2 sin(α) / Ld gives the angular velocity ω = v · κ. For point-to-point navigation, the target itself serves as the look-ahead point. For trajectory following (figure-eight), Ld indexes ahead on the path.
5. Obstacle Avoidance
Three reactive methods that modify the controller's velocity command before it reaches the physics engine.
5.1 Potential Fields
Each obstacle generates a repulsive force inversely proportional to distance². Forces are summed. Proximity factor linearly scales speed to zero at critical zone.
5.2 Dynamic Window Approach (DWA)
Evaluates forward, left, and right sectors. If front obstacles detected, scales linear velocity by clearance ratio and steers toward the clearer side:
5.3 Vector Field Histogram (VFH)
Builds a 36-bin polar histogram of obstacle density. Finds the widest gap (lowest density) and steers toward it:
θgap = center angle of widest gap. Speed reduced to 70% during avoidance manoeuvre.
6. Simulated LiDAR
72-ray simulated laser scanner via ray-circle intersection. Feeds obstacle detection for avoidance algorithms.
Each ray is cast in the sensor frame (aligned with robot body). Cartesian conversion to world frame:
yw = yr + r cos(θray) sin(θr) + r sin(θray) cos(θr)
7. Figure-Eight Trajectory
Lemniscate of Gerono parameterisation for the /figure-eight-nav page.
Curvature κ(t) is used for speed-adaptive control — robot slows at high-curvature crossover points.
8. Control Pipeline
Equation Reference
| # | Equation | Description |
|---|---|---|
| (1)–(3) | ẋ = v cos θ, ẏ = v sin θ, θ̇ = ω | Unicycle kinematic model |
| (4)–(5) | v̇ = Kp(v_cmd − v) − β·v | First-order velocity dynamics with drag |
| (6) | q += (dt/6)(k₁ + 2k₂ + 2k₃ + k₄) | RK4 integration |
| (7)–(8) | d = ‖p_t − p‖, α = atan2(Δy,Δx) − θ | Distance and heading error |
| (9) | u = Kp·e + Ki·∫e + Kd·ė | PID control law |
| (10)–(11) | ω = 2 sin α / L_d | Pure pursuit steering |
| (12)–(13) | F_rep = −Σ(1/r²) r̂ | Potential field repulsive force |
| (14)–(15) | v = v_cmd · clearance_ratio | DWA speed scaling |
| (16)–(17) | h[k] = Σ(1/r), ω → θ_gap | VFH polar histogram |
| (18)–(19) | x = a sin t, y = b sin t cos t | Lemniscate of Gerono (figure-eight) |