KinetiX: Real-Time Mobility Simulation Engine Inspiration We were fascinated by how complex and data-driven modern mobility competitions like Formula E, drone races, and logistics relays had become — yet how few open, research-grade systems existed to simulate these real-time interactions. We wanted a framework that combined rigorous computational physics with low-latency systems engineering to model emergent competition dynamics at scale. What it did We built a real-time, event-driven multi-agent mobility simulator that modeled autonomous agents (cars, drones, couriers) competing on configurable tracks. Each agent executed motion control logic combining kinematics, PID control, and probabilistic decision models. The simulation produced microsecond-timestepped state updates that were streamed to a React + Three.js dashboard for 3D visualization, live telemetry, and leaderboards. Every run could be exported as a replayable "mobility event file" for offline analysis and benchmarking. How we built it The simulation core ran a discrete time-step solver implemented in WebAssembly and orchestrated from Node.js to achieve low latency and efficient worker-thread parallelism. Each tick performed state propagation, event handling, collision detection, and leaderboard updates; telemetry was buffered in Redis Streams and pushed via WebSockets to the frontend. The frontend rendered trajectories, drift effects, and real-time analytics using React + Three.js, and provided controls for injecting events (rain, obstacles, pit stops) and replaying recorded runs. Physics & Math We explicitly modeled the dynamics and safety logic used by real mobility systems. Below are the core equations and reasoning we implemented in the engine. Kinematic Update (Discrete Time Solver) We advanced agent pose using standard kinematic integrators: x(t+Δt) = x(t) + v(t)Δt + (1/2)a(t)Δt² v(t+Δt) = v(t) + a(t)Δt

Net Acceleration Decomposition Acceleration a(t) was composed of control input plus environmental forces: a(t) = a_control(t) + (F_drag(v) + F_terrain(x) + F_rep) / m

Drag & Viscous + Quadratic Aerodynamic Model We combined viscous damping and quadratic aerodynamic drag: F_drag(v) = -c_v*v - (1/2)*ρ*C_d*A*v²

Where: c_v = viscous damping coefficient ρ = air density C_d = drag coefficient A = frontal area Coulomb-Viscous Hybrid Friction (Longitudinal) To model stick-slip and braking behavior we used a Coulomb + viscous term: F_fric = -μ*N*sgn(v) - c_v*v

Where: N = normal load μ = static/kinetic friction coefficient sgn(v) = sign of velocity Lateral Dynamics & Cornering Limit Lateral centripetal force was approximated by: F_lat = m*v²/r

And compared to maximum lateral grip: F_max = μ_lat*N

When F_lat > F_max we injected a slip state and reduced effective lateral velocity (simulating drift). Collision Avoidance & Safe Gap We used a time-to-collision (TTC) based safety check and an artificial potential field repulsive force. Time-to-Collision (scalar approximation along a 1-D gap): TTC = (d_rel - d_safe) / (v_rel + ε)

Where: d_rel = inter-agent distance v_rel = relative closing speed d_safe = minimum safe gap ε = small epsilon to avoid division by zero Braking Distance (kinetic energy approach): d_brake = v² / (2*μ*g)

Combined with reaction distance: d_safe = v*t_react + d_brake

Artificial Potential Field (repulsion to avoid collision): U(d) = { (1/2)k(1/d - 1/d_0)², for d < d_0 0, for d ≥ d_0 }

F_rep = -∇U(d) = -k*(1/d - 1/d_0)*(1/d²)*r̂

Where: d = inter-agent distance d_0 = threshold distance k = gain coefficient r̂ = unit separation vector Control Law (PID for Speed & Heading) Agent controllers used PID laws: u(t) = K_p*e(t) + K_i*∫₀ᵗ e(τ)dτ + K_d*(de/dt)

Where: e(t) = error to desired speed or trajectory heading K_p = proportional gain K_i = integral gain K_d = derivative gain PID output was saturated by traction and power limits. Predictive Scoring (Leaderboard Projection) We calculated a projected finish score using short-window linear extrapolation of velocity and stochastic variance: ŝi(t+τ) = s_i(t) + v̄(i,Δ)τ - (1/2)ā_(i,Δ)*τ²

And ranked agents by expected arrival time using Monte Carlo sampling to capture uncertainty. These equations were evaluated at each tick and used for telemetry, analytics, and safety decision making. Challenges we ran into The main technical hurdles were latency and accuracy tradeoffs: ensuring a physics-rich model while keeping per-tick compute cheap enough to stream at high frequency. We had to tune worker thread partitioning in WebAssembly and tune control gains (PID) to prevent oscillatory behavior under Monte Carlo noise. Accomplishments that we're proud of We produced a robust real-time engine that handled hundreds of agents, implemented traction-aware cornering, time-to-collision safety gating, and a predictive leaderboard based on stochastic projections. The exported mobility event files enabled replay and offline ML analysis, and our live dashboard visualized vector fields, slip angles, and energy telemetry in real time. What we learned We gained hands-on experience integrating applied dynamics (drag, slip, Coulomb damping) into a scalable event pipeline, and learned practical techniques for trading fidelity for performance (approximate integrators, capped PID gains, adaptive tick rates). What's next for KinetiX We planned to add reinforcement learning agents that used the exported event files to learn energy-efficient overtaking policies, incorporate more accurate tyre models (Pacejka-style slip curves), and expose a plugin API so external controllers could be benchmarked against the built-in agents.

Built With

Share this project:

Updates

Submission history