These docs are public and open source.Edit on GitHub
API REFERENCE / PYTHON
RC.CONTROLLER.
The Controller module reads the Xbox controller: buttons, the two analog triggers, and the two joysticks. It is also where your safety lives, since most programs watch a button here for a manual stop. The same calls work against the on-screen controls in the Playground sim.
Sim ↔ car identical8 buttons2 sticks · 2 triggers
METHODS
THE METHODS.
//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.
pythonimport 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()
