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

ev3-api

v0.1.35

Published

A realtime API for use on ev3 robots with rtm-server

Downloads

69

Readme

rtm-api

Build status Git tag NPM version Code style

A realtime API for use on ev3 robots with rtm-server and ev3-client

Installation

npm install ev3-api

Usage

var server = require('rtm-server')
var API = require('ev3-api')

server(API, 5000)

API

messages

Emitter for communication with the server.

sensor_mode(data, [cb])

Set the mode of one of the sensors.

data

Type: object

Object with options for the sensor mode.

command

Type: string

The ev3dev sensor mode to set.

port

Type: string, number

The number of the port the sensor is connected to.

cb

Type: function

Callback function that is called when the sensor mode change is completed. Function should have an error argument.

sensor_subscribe(data, [cb])

Subscribe to read the values from the sensors and the state of the motors. The first time this is called it begins the polling process. The messages are then emitted via messages as an object.

data

Type: object

Object that contains the socket id for the emitter to transmit on.

socketId

Type: number

reading channel ID for emitting the sensor object.

Example sensors object:

{
  'a': {
    'type': 'motor',
    'value': 'running'
  },
  '1': {
    'type': 'sonic',
    'value': 50
  }
}

cb

Type: function

Callback function that is called when the sensor polling has been started.

sensor_unsubscribe(data, [cb])

Stop receiving information from the sensors. If this is the last connection to the robot, the sensor polling will be stopped.

data

Type: object

socketId

Type: number

The ID of which reading channel to close.

cb

Type: function

Callback function that is called when the sensor polling has been canceled.

motor_write(data, [cb])

Start a single motor move.

data

Type: object

Object with information to start motor moves.

command

Type: string

Type of ev3dev motor command to run.

port

Type: string

Letter of the port the motor is attached to.

opts

Type: object

Options to set for the move command. Check out the ev3dev tacho-motor tutorial for more information on these options. The three most common ones are explained below.

speed_sp

Type: string

Set the speed of the motors. The tutorial above has a more in depth explanation but the number should stay below 800 for the ev3 motors.

time_sp

Type: string

Set the time the motor should run for in milliseconds. Should only be used for a run-timed command.

position_sp

Type: string

The degrees the tacho-motor should spin. This is used for the run-to-rel-pos and run-to-abs-pos commands.

motors_write(data, [cb])

Moves two motors at the same time. Should be used to handle driving the robot.

data

Type: object

Object with information to start motor moves.

command

Type: string

Type of ev3dev motor command to run.

port

Type: array

Array of strings that indicate the two drive motors.

Example:

['b', 'c']
left

Type: object

motor_write opts object to use for the left motor (first in the ports array). See above for details.

right

Type: object

motor_write opts object to use in the right motor (second in the ports array). See above for details.

cb

Type: function

Callback function is called either on error or when both motors have successfully written their commands. First argument is err.

ping(data, [cb])

A ping to check the connection to the client.

cb

Type: function

Function gets passed (err, true).

setPaths(paths)

Change the default paths to the motors and sensors. Useful for testing purposes.

paths

Type: object

motor

Type: string

Path to motor. Default path is '/sys/class/tacho-motor/'.

sensor

type: string

Path to sensor. Default path is '/sys/class/lego-sensor/'.

reading()

Check to see if the sensors are currently reading. Only used for testing.

Returns a boolean