rover-2

A node.js client for controlling the Brookstone Rover 2.0

npm install rover-2
2 downloads in the last day
7 downloads in the last week
11 downloads in the last month

rover-2

Implementation of TCP network protocols for the Brokstone Rover 2.0. Note that all rover commands require a connection to the rover wifi network, typically beginning with ROVER.

Attempts to expose all functionality of the rover with an easy to use API.

This module is still under heavy development. Pull-requests are welcome.

Installation

Install via git:

$ npm install rover-2

REPL

rover-2 exposes a repl.js file for testing. Currently the exposed locals include:

  • rover: outward facing api object
  • utils: byte utility functions
  • blow: blowfish implementation

For example:

$ ./repl.js 
rover> rover
{ connect: [Function: connect],
  disconnect: [Function: disconnect],
  forwardLeft: [Function: forwardLeft],
  forwardRight: [Function: forwardRight],
  reverseLeft: [Function: reverseLeft],
  reverseRight: [Function: reverseRight],
  forward: [Function: forward],
  reverse: [Function: reverse],
  cameraUp: [Function: cameraUp],
  cameraDown: [Function: cameraDown],
  cameraStop: [Function: cameraStop],
  spin: [Function: spin] }

Usage

Require and go:

// Require rover
var rover = require('rover-2');

// Establish connection
rover.connect(function (err) {
    // Check if there was an error establishing connection
    if (err) return console.log('Connect error: ', err);

    // Move around
    rover.forward(1000);
    rover.reverse(1500);
});

API

rover.connect([callback])

Establishes connection to rover. Requires connection to rover network.

  • callback: [Optional] function to deliver connection error

rover.disconnect()

Closes connection with rover. Any subsequent commands will throw an error, with the exception of connect.


rover.forwardLeft([duration])

Instructs the rover to move the left track forward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.forwardRight([duration])

Instructs the rover to move the right track forward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.reverseLeft([duration])

Instructs the rover to move the left track backward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.reverseRight([duration])

Instructs the rover to move the right track backward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.forward([duration])

Instructs the rover to move both tracks forward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.reverse([duration])

Instructs the rover to move both tracks backward. Seems to persist for one second with a single instruction.

  • duration: [Optional] ms to continue sending instruction

rover.cameraUp()

Instructs the rover to raise the camera. Will continue until told to stop or reaches highest point.


rover.cameraDown()

Instructs the rover to lower the camera. Will continue until told to stop or reaches lowest point.


rover.cameraStop()

Instructs the rover to stop all camera movement.


rover.spin([direction,][duration])

Instructs the rover to spin.

  • direction: [Optional] direction of spin ('clockwise' or 'counter-clockwise'), defaults to 'clockwise'
  • duration: [Optional] how long to continue spin
npm loves you