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

RC.DRIVE.

The Drive module is how your code moves the car: one call sets the rear-wheel speed and the front-wheel steering angle. It is the only part of the car your program writes to, and the same three methods run unchanged in the Playground sim and on the physical NeoRacer.

Sim ↔ car identical3 methodsspeed, angle in [-1, 1]
METHODS

THE METHODS.

rc.drive.set_speed_angle(speed, angle)returns None

The one write you have. Sets the rear-wheel speed and the front-wheel steering angle for this frame.

speed: floatThrottle in [-1.0, 1.0]. 1.0 is full forward, -1.0 full reverse, 0 is stopped.
angle: floatSteering in [-1.0, 1.0]. -1.0 is full left, 1.0 full right, 0 is straight.
rc.drive.stop()returns None

Halts the car and returns the front wheels to centre. The same as set_speed_angle(0, 0).

rc.drive.set_max_speed(max_speed=0.25)returns None

Scales every speed you send afterward. A safety cap, set once in start(). The default is 0.25, so a student set_speed_angle(1.0, 0) only drives at a quarter of the hardware top speed until you raise it.

max_speed: floatThrottle scale in [0.0, 1.0]. Defaults to 0.25.
TYPICAL USE

EXAMPLE USAGE.

python
import racecar_core rc = racecar_core.create_racecar() def start(): # Raise the throttle cap once. The library defaults it to 0.25. rc.drive.set_max_speed(0.4) rc.drive.stop() def update(): # Hold the A button to creep forward, steer with the left stick x-axis. x, _ = rc.controller.get_joystick(rc.controller.Joystick.LEFT) speed = 0.3 if rc.controller.is_down(rc.controller.Button.A) else 0.0 rc.drive.set_speed_angle(speed, x) rc.set_start_update(start, update) rc.go()