racecar_core Library

The racecar_core library exposes the intended interface for programming the RACECAR-MN. The Main module handles program execution, and several submodules encapsulate different aspects of the hardware.

Racecar Module

class racecar_core.Racecar

The top level racecar module containing several submodules which interface with and control the different pieces of the RACECAR hardware.

abstract get_delta_time()

Returns the number of seconds elapsed in the previous frame.

Return type

float

Returns

The number of seconds between the start of the previous frame and the start of the current frame.

Example:

# Increases counter by the number of seconds elapsed in the previous frame
counter += rc.get_delta_time()
abstract go()

Starts the RACECAR, beginning in default drive mode.

Note

go idles blocks execution until the program is exited when START + END are pressed simultaneously.

Return type

None

abstract set_start_update(start, update, update_slow=None)

Sets the start and update functions used in user program mode.

Parameters
  • start (Callable[[], None]) – A function called once when the car enters user program mode.

  • update (Callable[[], None]) – A function called every frame in user program mode. Approximately 60 frames occur per second.

  • update_slow (Optional[Callable[[], None]]) – A function called once per fixed time interval in user program mode (by default once per second).

Note

The provided functions should not take any parameters.

Example:

# Create a racecar object
rc = Racecar()

# Define a start function
def start():
    print("This function is called once")

# Define an update function
def update():
    print("This function is called every frame")

# Provide the racecar with the start and update functions
rc.set_start_update(start, update)

# Tell the racecar to run until the program is exited
rc.go()
Return type

None

abstract set_update_slow_time(time=1.0)

Changes the time between calls to update_slow.

Parameters

time (float) – The time in seconds between calls to update_slow.

Example:

# Sets the time between calls to update_slow to 2 seconds
rc.set_update_slow_time(2)
Return type

None