Skip to content

API Reference

PascalRombach edited this page Aug 12, 2022 · 2 revisions

API Reference

Controller

  • timeout

  • vehicles

  • map

  • map_types

Attributes

Controller.timeout

read-write float attribute

Controls the timeout for connection attempts using Controller.connectOne, Controller.connectSpecific, and Controller.connectMany

Controller.vehicles

read-write set of Vehicle attribute

A set of the vehicles currently connected to the controller.

Controller.map

Optional read-write list of TrackPiece attribute

Ordered list of all track pieces as it is returned by Controller.scan. Is None if

Properties

Controller.map_types

read-only tuple of TrackPieceType property

Ordered tuple containing the types of the pieces in Controller.map in-order.

Methods

Controller.connectOne

Connect to one undetermined non-charging Supercar and return the Vehicle instance

Parameters
  • Optional vehicle_id: The id given to the Vehicle instance on connection
Returns

A Vehicle object representing the connected supercar

Raises

Controller.connectSpecific

Connect to a supercar with a specified MAC address

Parameters
  • address: A string representing the MAC-address of the vehicle to connect to. This needs to be uppercase seperated by colons
  • Optional vehicle_id: An integer id given to the vehicle on connection.
Returns

A Vehicle object representing the connected supercar

Raises

Controller.connectMany

Connect to non-charging Supercars

Parameters
  • amount: An integer amount representing the number of vehicles to connect to
  • Optional vehicled_ids: An iterable with the ids the vehicles will get on connection. Any number of these entries may be None
Returns

A tuple of connected Vehicle instances.

Raises

Controller.scan

Assembles a digital copy of the map and adds it to every connected vehicle.

Parameters
  • Optional scan_vehicle: When passed a Vehicle object, this vehicle will be used as a scanner. Otherwise a scanner will be selected automatically.
  • Optional align_pre_scan: When set to True, the supercars can start from any position on the map and align automatically before scanning. Disabling this means your supercars need to start between START and FINISH
Returns

A list of TrackPiece representing the scanned in map.

Raises

Controller.disconnectAll

Disconnects from all the connected supercars

Raises

Controller.handleShutdown

Handles a shutdown neatly and disconnects the vehicles

Raises

Vehicle

  • on_track_piece_change

  • wait_for_track_change

  • connect

  • disconnect

  • setSpeed

  • stop

  • changeLane

  • changePosition

  • turn

  • getLane

  • align

  • trackPieceChange

  • removeTrackPieceWatcher

  • ping

  • pong

  • is_connected

  • current_track_piece

  • map

  • map_position

  • road_offset

  • speed

  • current_lane3

  • current_lane4

  • id