These docs are public and open source.Edit on GitHub
API REFERENCE / PYTHON
RC.LIDAR.
The module is your 360° sense of distance. One call hands you a flat array of 720 distances in centimetres, and the library gives you the exact same array in the Playground sim and on the car, so a wall-follower you write in the browser runs unchanged on the NeoRacer.
Sim ↔ car identical720 samples0.5° apartindex 0 = forward
METHODS
THE LIDAR METHODS.
HELPERS · RACECAR_UTILS
LIDAR HELPERS.
Reading a direction by hand means converting an angle to an index and averaging a window. The racecar_utils module (imported as rc_utils) already does it, so most programs use these two instead of indexing the raw array.
TYPICAL USE
A WALL-STOP EXAMPLE.
pythonimport racecar_core import racecar_utils as rc_utils rc = racecar_core.create_racecar() def start(): rc.drive.set_max_speed(0.4) def update(): scan = rc.lidar.get_samples() # 720 distances, cm # average distance in a 10-degree window straight ahead front = rc_utils.get_lidar_average_distance(scan, 0, 10) rc.drive.set_speed_angle(0.0 if front < 50 else 0.3, 0) rc.set_start_update(start, update) rc.go()
