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

RC.CONTROLLER.

The Controller module reads the manual controls through an Xbox-style mapping: buttons, triggers, and joysticks. On the car the physical remote is the FlySky transmitter, whose sticks and switches feed those same axes and buttons, so code written against this API runs unchanged against the on-screen controls in the Playground sim.

Same API, sim and carFlySky on the carXbox-style mapping
METHODS

THE METHODS.

rc.controller.is_down(button)returns bool

True for every frame the button is held. Use it for "while I hold A, drive".

button: ButtonOne of the Button values below.
rc.controller.was_pressed(button)returns bool

True only on the single frame the button goes down. Use it for "each time A is tapped, toggle something".

button: ButtonOne of the Button values below.
rc.controller.was_released(button)returns bool

True only on the frame the button comes back up. The mirror of was_pressed.

button: ButtonOne of the Button values below.
rc.controller.get_trigger(trigger)returns float

How far a trigger is pulled, from 0.0 (released) to 1.0 (fully pressed). Analog, so it makes a smooth throttle.

trigger: TriggerTrigger.LEFT or Trigger.RIGHT.
rc.controller.get_joystick(joystick)returns tuple[float, float]

The (x, y) position of a stick, each from -1.0 to 1.0. x is left-right, y is down-up. Centre is (0, 0).

joystick: JoystickJoystick.LEFT or Joystick.RIGHT.
//Enums you pass in
rc.controller.Button
A · B · X · Y · LB · RB · LJOY · RJOY
rc.controller.Joystick
LEFT · RIGHT
rc.controller.Trigger
LEFT · RIGHT
TYPICAL USE

A TYPICAL LOOP.

python
import racecar_core rc = racecar_core.create_racecar() def start(): rc.drive.stop() def update(): # B is a manual stop. was_pressed fires once, on the tap. if rc.controller.was_pressed(rc.controller.Button.B): rc.drive.stop() return # Left stick x steers; hold A to creep forward. 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()