npm install anki-overdrive-api --save
Changes in the API are tracked in a Changelog.
The current documentation of the API can be found here
The API implements the current specification of the official Anki Overdrive Drive SDK. The API can be used to find and control vehicles in the BLE network.
Use the VehicleScanner
class to search for vehicles in the BLE network.
import {Bluetooth, VehicleScanner} from "anki-overdrive-api"
const bluetooth = new Bluetooth()
const scanner = new VehicleScanner(bluetooth)
scanner.findAll().then(vehicles => {
// Do something with vehicles...
}).catch(/* Handle Errors */)
Vehicles can also be found by using the device address or id.
scanner.findByAddress("42:e2:b6:q7").then(vehicle => {
// Do something with vehicle...
})
scanner.findById("df6as5fda").then(vehicle => {
// Do something with vehicle...
})
After connecting the vehicles they can execute several commands like changing the speed or lane. See the documentation to see all commands.
// First the vehicle has to be connected
vehicle.connect().then(() => {
vehicle.setSpeed(500)
// Vehicles are using offset for positioning.
vehicle.changeLane(-68.0)
})
The vehicles can also send messages if they changes their position. Therefore a listener has to be registered on the vehicle.
vehicle.addListener((message:LocalizationPositionUpdate) => {
console.log("drove over piece: " + message.roadPieceId)
console.log("drove over location: " + message.locationId)
console.log("current speed: " + message.speedMmPerSec)
// Do something else with the message...
})
The API can be tested with unit tests or end-to-end (e2e) tests. Code coverage is also supported.
npm t
or with code coverage
npm run test:coverage
npm run test:e2e
Note: You need to specify at least one vehicle in the settings.json in test/e2e/resources
.
The vehicle has to be online and full charged placed on the track.
Clone the repo and install the dependencies, please follow the instructions from the prerequisites section to avoid problems concerning the BLE adapter.
git clone https://github.com/Aspern/anki-overdrive-api.git
cd anki-overdrive-api
npm i