oseiskar / js-car

2D JavaScript car dynamics simulation

Home Page:https://oseiskar.github.io/js-car/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript 2D car dynamics simulation

Physics model features:

  • auto-generated track
  • collisions with the 4 walls
  • basic static and dynamic friction
  • air drag applied to the center of mass
  • "arrow-key steering aids": velocity-based limitations to steering angle and its change rate

The physics model is "as simple as possible": Frictional forces are applied to two points: the center of the front and rear axle instead of the four wheels separately. The car is therefore actually modeled more like a "motorcycle that does not bank". This is the same as assuming a lot of symmetry between the forces to the left and right wheel on each axle, i.e.,

  • no tire slip due to deformations
  • no suspension
  • no roll
  • equal coefficients of friction

TODO:

  • brakes
  • non-constant torque from engine
  • noise

AI drivers

  • PID control with a few tricks
  • Route planning with an ad-hoc "rubber band model" (uses a web worker)

TODO

  • Physics-based controller (non-PID)

About

2D JavaScript car dynamics simulation

https://oseiskar.github.io/js-car/

License:MIT License


Languages

Language:JavaScript 94.2%Language:HTML 5.8%