npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

roboticscape

v0.0.8

Published

Node.js bindings for libroboticscape for BeagleBoard.org BeagleBone Blue or Robotics Cape

Downloads

56

Readme

node-roboticscape

Node.js bindings for libroboticscape for BeagleBoard.org BeagleBone Blue or Robotics Cape

libroboticscape documentation

http://www.strawsondesign.com/#!manual-init-cleanup

Installation

From npm

$ sudo npm install --global roboticscape

From source

$ git clone https://github.com/jadonk/node-roboticscape
$ cd node-roboticscape
$ sudo npm install --global

Usage

var rc = require('roboticscape');

/* Allocate the userspace usage of the robotics cape features */
rc.initialize();

/* Set the state to RUNNING */
rc.state("RUNNING");

/* Exercise the robotics cape hardware */
rc.led("GREEN", true);
rc.on("PAUSE_PRESSED", function() { 
    console.log("PAUSE pressed");
    
    /* Set the state to EXITING */
    rc.state("EXITING");
});
rc.motor("ENABLE");
rc.motor(0.3);

/* Read encoder every second until PAUSE button pressed */
setInterval(function() {
    if(rc.state() == "RUNNING") {
        var enc1 = rc.encoder(1);
        console.log("encoder 1 = " + enc1);
    } else {
        /* The robotics cape userspace interface is automatically freed on exit */
        process.exit();
    }
}, 1000);

API

Table of Contents

initialize

Allocate the userspace usage of the robotics cape features and initialize the hardware functions.

See the Init and Cleanup libroboticscape documentation.

Examples

var init = rc.initialize();

Returns Number where

  • -2 : invalid contents in PID_FILE
  • -1 : existing project failed to close cleanly and had to be killed
  • 0 : No existing program is running
  • 1 : An existing program was running but it shut down cleanly.

state

Set or read the libroboticscape program state.

See the Program Flow State libroboticscape documentation.

Examples

rc.state("RUNNING");
var state = rc.state();

Parameters

  • state String state to enter must be one of "UNINITIALIZED", "RUNNING", "PAUSED" or "EXITING". If undefined, the current state will be returned instead of entering a new state.

Returns String when no arguments are provided with one of the following values

  • "UNINITIALIZED"
  • "RUNNING"
  • "PAUSED"
  • "EXITING"

led

Set the red and green user LEDs.

See the LEDs libroboticscape documentation.

Examples

rc.led("GREEN", true);

Parameters

  • led String led name to set state should be either "RED" or "GREEN".
  • state Boolean true for on and false for off.

on

Register event callbacks. Currently, only the button press events have been implemented.

See the Buttons libroboticscape documentation.

Examples

rc.on("MODE_RELEASED", function() { console.log("MODE button released."); });

Parameters

  • event String name of event should be one of "PAUSE_PRESSED", "PAUSE_RELEASED", "MODE_PRESSED" or "MODE_RELEASED".
  • callback Function function doesn't take any arguments.

motor

Control the DC motor outputs.

See the DC Motors libroboticscape documentation.

Examples

rc.motor("ENABLE");
rc.motor(1, 0.3);

Parameters

  • motor Number the motor to target. (Optional, defaults to setting the value for all motors. Remove if not used; do not just set to undefined.)
  • value String | Number value or mode to set motor or motors. Can be one of "ENABLE", "DISABLE", "FREE_SPIN", "BRAKE" or a number from -1 to 1. The "ENABLE" and "DISABLE" arguments can currently only be applied when no motor is specified.

encoder

Read and set the count on the quadrature encoder input counters.

See the Quadrature Encoder Counting libroboticscape documentation.

Examples

var enc1 = rc.encoder(1);
rc.encoder(1, 0);

Parameters

  • encoder Number the index of the encoder to read or set.
  • value Number value to which to set the encoder count. (Optional, defaults to reading only.)

Returns Number current encoder count.

adc

Read a channel of the analog-to-digital converter.

See the Analog to Digital Converter libroboticscape documentation.

Examples

var value = rc.adc(1);

Parameters

  • channel Number | String the channel to read. Possible values are "BATTERY", "DC_JACK", 0, 1, 2 or 3.

Returns Number voltage measured by the ADC on the specified channel.

imu

Read the inertial measurement unit sensor (IMU).

See the Inertial Measurment Unit libroboticscape documentation.

Examples

var state = rc.imu();

Parameters

Returns Object IMU state

  • state.accel Array<Number> accelerometer state in meters per second squared
  • state.gyro Array<Number> gyroscope state in degrees per second
  • state.mag Array<Number> magnetometer state in microteslas
  • state.temp Number thermometer state in degrees Celcius