rc.physicsNEORACER DOCS
NEORACER DOCS
These docs are public and open source.Edit on GitHub
API REFERENCE / PYTHON

RC.PHYSICS.

The Physics module is the : it reports how the car is accelerating and rotating. It is what you reach for when you want to turn a precise number of degrees or detect a bump, and the acceleration and angular-velocity calls behave the same in the Playground sim and on the car.

Sim ↔ car identicalaccel · m/s²gyro · rad/s
METHODS

THE METHODS.

rc.physics.get_linear_acceleration()returns NDArray[3, Float]

The car’s acceleration as an (x, y, z) vector in metres per second squared, averaged over the last frame. At rest you read roughly 9.8 on the axis pointing down, because gravity counts.

rc.physics.get_angular_velocity()returns NDArray[3, Float]

How fast the car is rotating, as an (x, y, z) vector in radians per second. The z component is your yaw rate, which is what you watch when you want to turn a known amount.

rc.physics.get_magnetic_field()returns NDArray[3, Float]

The magnetic field as an (x, y, z) vector in teslas, useful as a rough compass. Available on the physical car only, since the simulator has no magnetometer.

TYPICAL USE

A WORKED EXAMPLE.

python
import racecar_core rc = racecar_core.create_racecar() def start(): pass def update(): ax, ay, az = rc.physics.get_linear_acceleration() # m/s^2 wx, wy, wz = rc.physics.get_angular_velocity() # rad/s # wz is the yaw rate: positive one way, negative the other. print(f"down accel {az:.1f} m/s^2, yaw rate {wz:.2f} rad/s") rc.set_start_update(start, update) rc.go()