-
Notifications
You must be signed in to change notification settings - Fork 1
Home
The following are utility functions provided by the anki_sdk.utils
module:
import anki_sdk.utils as utils
carList: list = utils.scanner(active: bool) # active: Only cars which are turned on -> returns an anki overdrive MAC-address list
carData: str = utils.getData(address: str) # active: The MAC-address of the vehicle -> returns the manufacturer_data
The scanner
function returns a list of MAC-addresses of all the cars that are currently turned on. The getData
function returns the manufacturer_data for a specific car, identified by its MAC-address.
The following are initialization functions provided by the anki_sdk.cars
and anki_sdk.controller
modules:
import anki_sdk.cars as cars
import anki_sdk.controller as controller
myCar: cars.carClass = cars.carClass("XX:XX:XX:XX")
myController: controller.controllerClass = controller.controllerClass(myCar)
The carClass
class takes a MAC-address as its argument and returns an instance of the car. The controllerClass
class takes an instance of the car as its argument and returns an instance of the controller.
The following are functions provided by the anki_sdk.controller
module:
speed, accel = 500, 1000 # Max 1000
myController.setSpeed(speed, accel)
lanes = 3 # Recommend max 3
myController.leftLane(lanes)
myController.rightLane(lanes)
rightLane = 44.5 # One lane right
leftLane = -44.5 # One lane left
myController.changeLane(rightLane)
myController.changeLane(leftLane)
The setSpeed
function takes two arguments, speed
and accel
, which are used to set the speed and acceleration of the car. The leftLane
and rightLane
functions take a single argument lanes
and move the car to the specified lane on the left or right side respectively. The changeLane
function takes a single argument which specifies the distance to move the car to the left or right.
@myCar.notifyCallback(type=cars.Receive.trackChange) # Gets triggered every new track
def newTrack(sender, data):
print("New track")
@myCar.notifyCallback(type=cars.Receive.specialTrack) # Gets triggered every special track
def specialTrack(sender, data):
print("Special track")
print(myCar.ping()) # Prints the car ping
The notifyCallback
decorator is used to register a callback function to be called when a specific event occurs. In this case, there are two callbacks registered for the myCar
instance: newTrack
which is triggered every time a new track is detected, and specialTrack
which is triggered every time a special track is detected.
The ping
function prints the ping of the car.