Coder Social home page Coder Social logo

jacopotagliabue / anki-drive-python-sdk Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 8.0 810 KB

Python+node wrapper to read/send message from/to Anki Overdrive bluetooth vehicles.

JavaScript 21.51% Python 78.49%
anki-drive anki python3 overdrive noble bluetooth

anki-drive-python-sdk's Introduction

anki-drive-python-sdk

This is a Python wrapper to read/send message from/to Anki Overdrive bluetooth vehicles.

The project was designed for the A.I. blog series Self-driving (very small) cars: please refer to the Medium post for a full explanation on the code structure and the philosophy behind it.

TL;DR

We share a cross-platform Python+node setup that allows for quick experimentation and prototyping of interesting ideas in the toy universe of bluetooth cars.

overview

In particular:

  • a node server leverages noble to establish communication with Anki cars;
  • a Python app leverages sockets to reliably read/send messages from/to the node gateway, which abstracts away all the complexity of the bluetooth channel.

Setup

To use py-overdrive-sdk you'll need:

We run our code from a 2017 MacBook Pro and a Rasp Pi 3B+. We did not test with other hardware setups but in theory the wrapper should be pretty flexible.

Deployment

After cloning the repo, proceed to install node and python dependencies (we suggest using virtualenv but it's not necessary of course) as usual:

npm install
pip install -r requirements.txt

Prepare the bluetooth id for the car you want to drive (if you don't know it, you can just start-up the node server with a fake id and write down the id that gets printed to the console in the format SCAN|{BLUETOOTH-CAR-ID}|{BLUETOOTH-CAR-ADDRESS}).

Start-up the node gateway:

node node_server.js {YOUR-SERVER-PORT} {YOUR-BLUETOOTH-CAR-ID}

and wait for the console to notify that SCAN has been completed (you should see the id of the Anki cars as they are discovered by noble).

Finally run your python script. To start with a simple example, run:

python constant_speed_example.py --car={YOUR-BLUETOOTH-CAR-ID} --port={GATEWAY-PORT}

and see your car moving around (make sure to specify the same port for both node and Python). This is a one-minute video going from git to a running car: please refer to the Medium post for more details.

Current release and next steps

Please note that the current master (as of Sep. 2018) is released as alpha as it just contains the bare minimum the get things going: no unit tests, no fancy stuff, almost no protections from errors, etc. We'll hope to make several improvements to the code base as we progress with our experiments: feedback and contributions are most welcomed! Even without considering A.I. stuff (i.e. making the car learning how to optimally drive), there are several engineering improvements to be considered, such as for example (non-exhaustive list in no particular order):

  • set up unit and integration tests;
  • re-use node gateway for multiple cars at the same time;
  • a better abstraction for "driving policies", so that it becomes easier to instantiate custom policies while keeping the rest of the code (i.e. communication layer) pretty much intact and re-usable;
  • a "car-level" abstraction on top of the current Overdrive class, so that we could easily simulate different hardware abilities and constrain car learning in dynamic ways;
  • data ingestion/persisting mechanism, so that we can log in a reliable and consistent way everything that happens within a run

Some experimental code will be published in the develop branch and hopefully merged later on into a beta release.

Acknowledgments

It would have been a month project, not a weekend one, without Internet and the fantastic people on it sharing their code and ideas: as far as copy+paste-ing goes, this project is indeed second to none. In particular:

License

All the code in this repo is provided "AS IS" and it is freely available under the Apache License Version 2.0.

anki-drive-python-sdk's People

Contributors

jacopotagliabue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.