five-on-it / packages/ai/src/traffic-drive / pedal
Function: pedal()
pedal(
vc,v,a,reverse?):object
Defined in: packages/ai/src/traffic-drive.ts:266
The throttle (and whether the handbrake holds) that gives a car of class vc at the forward speed v the acceleration a (m/s²) over the coming tick, from what the simulation's engine and brakes do (packages/sim's vehicle.ts): the engine's force tapering with the square of the speed ratio, less the rolling brake of the wheels it does not drive and the air's damping; the brakes an impulse per wheel per tick; the handbrake below the speed at which the throttle axis would reverse instead of braking. Reversing (reverse, from a standstill too) mirrors it on the reverse gear. Inverted here, not tuned: a class's numbers changed in vehicle-classes.ts carry over.
Parameters
vc
v
number
a
number
reverse?
boolean = false
Returns
object
handbrake
handbrake:
boolean
throttle
throttle:
number