First programNEORACER DOCS
NEORACER DOCS
These docs are public and open source.Edit on GitHub
STEP 05 / GETTING STARTED · THE FINAL ONE

HELLO, RACECAR.

Twenty lines of Python that drive a one-metre square. The exact same script runs in the NeoRacer Playground simulator and on the car, your choice where to try it first.

0 minutesBeginnerSim ↔ Car parity
FIG. A / WHAT YOUR PROGRAM WILL DO
DRIVING PATH · ~1 m PER SIDESTART / END1 s forwardturn 90°1 s forwardturn 90°
Forward one second, turn 90°, repeat four times. The simplest possible closed-loop program, open-loop in this case, since we don't check sensors yet.
//Pick your launch pad
  • Playground (recommended for the first run): zero install. Open playground.neobotics.org in your browser, paste the code, and you're one click from Run.
  • Car: into the Jetson (covered in Networking) and run the script over ros2 run with the racecar-neo-library installed.
01 / THE PROGRAM

THE PROGRAM.

python
import racecar_core rc = racecar_core.create_racecar() SIDE_TIME = 1.0 # seconds per straight leg TURN_TIME = 0.7 # seconds per 90-degree turn SPEED = 0.25 # 25% throttle TURN = 1.0 # full lock timer = 0.0 leg = 0 # 8 legs: even legs drive straight, odd legs turn def start(): global timer, leg timer, leg = 0.0, 0 rc.drive.stop() def update(): global timer, leg if leg >= 8: # four straights + four turns rc.drive.stop() return timer += rc.get_delta_time() # seconds since the last frame if leg % 2 == 0: # straight leg rc.drive.set_speed_angle(SPEED, 0) if timer > SIDE_TIME: leg, timer = leg + 1, 0.0 else: # turn leg rc.drive.set_speed_angle(SPEED, TURN) if timer > TURN_TIME: leg, timer = leg + 1, 0.0 rc.set_start_update(start, update) rc.go()
02 / WHAT TO EXPECT

WHAT TO EXPECT.

The car traces something roughly square and lands near, but not exactly on, its start. That gap is the whole reason sensors exist, and feeling it for yourself here makes that click into place.

Sim run
Path looks geometric. Corners are sharp. Final position drifts about 10 cm.
Car run (carpet)
Path skews. Final position can drift 50 cm or more. Carpet wheel slip is the dominant error.
Car run (hardwood)
Closer to the sim. Drift comes from un-trimmed servo and motor torque ripple.