anki-vector-nodejs

0.3.0 • Public • Published

Anki Vector - Node.js API

Vector

Learn more about Vector: https://www.anki.com/vector

gRPC calls this library has access to: https://developer.anki.com/vector/docs/generated/anki_vector.messaging.client.html

Python SDK documentation: http://developer.anki.com/vector/docs/

Forums: https://forums.anki.com/

Getting Started

You can follow steps here to set up your Vector robot with the SDK. After you've got the Python SDK setup and working you can proceed to setup the Node.js API:

  1. Install from NPM npm install anki-vector-nodejs --save
  2. Copy node_modules/anki-vector-nodejs/config.sample.js to node_modules/anki-vector-nodejs/config.js
  3. Fill in values in config.js you can obtain from %home%/.anki_vector/sdk_config.ini

OR

Pass values obtained from %home%/.anki_vector/sdk_config.ini directly into the constructor

Then intialize the API and use it!

    var VectorAPI = require("anki-vector-nodejs");
    var vector = new VectorAPI({
        VECTOR_SN: "01234567",
        VECTOR_NAME: "Vector-R2D2",
        VECTOR_IP: "192.168.2.42",
        VECTOR_BEARER_TOKEN: "abcdefghijkl1234567890==",
        VECTOR_CRT: "/home/user/.anki_vector/Vector-R2D2-01234567.cert",
        DEBUG_LEVEL: "info" // Not found in the sdk_config.ini. Available options: "trace", "debug", "info", "error", "fatal"
    });
    
    // List out all available methods
    // Should be the same (or mostly the same) as: https://developer.anki.com/vector/docs/generated/anki_vector.messaging.client.html
    var routes = vector.listMethods();
    routes.forEach((route) => {
        console.log(`Route ${route.name} : `);
        console.log(`         req fields: ${JSON.stringify(route.requestFields)}`);
        console.log(`         res fields: ${JSON.stringify(route.requestFields)}`);
    });
    
    // Actually call a method
    console.log("Asking Vector about his protocol version...");
    vector.client.ProtocolVersion({"client_version": vector.VECTOR_CLIENT_VERSION, "min_host_version": vector.VECTOR_MIN_HOST_VERSION}, (err, result) => {
        if (err){
            console.log("Error", err);
        }
        console.log(result);
    });

Logging

Built in logger uses Bunyan. Totally optionally, you can get the logger instance by calling getLogger() like this:

    var VectorAPI = require("anki-vector-nodejs");
    var vector = new VectorAPI({
        VECTOR_SN: "01234567",
        VECTOR_NAME: "Vector-R2D2",
        VECTOR_IP: "192.168.2.42",
        VECTOR_BEARER_TOKEN: "abcdefghijkl1234567890==",
        VECTOR_CRT: "/home/user/.anki_vector/Vector-R2D2-01234567.cert",
        DEBUG_LEVEL: "info" // Not found in the sdk_config.ini. Available options: "trace", "debug", "info", "error", "fatal"
    });
    const log = vector.getLogger();
    log.trace("I'm a trace");
    log.debug("I'm a debug");
    log.info("I'm an info");
    log.warn("I'm an warn");
    log.error("I'm an error");
    log.fatal("I'm an fatal");

Then you can use the Bunyan tool (npm intall bunyan -g) to view a pretty output by piping your output: node my-vector-app.js | bunyan

Privacy Policy and Terms and Conditions

This Node.js library is a personal project and IS NOT affilated with Anki Inc. Please post issues in the Github issue tracker rather than to Anki support.

Readme

Keywords

Package Sidebar

Install

npm i anki-vector-nodejs

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

77.9 kB

Total Files

17

Last publish

Collaborators

  • kishcom