iRobot Create Open Interface (OI) library
npm install create-oicreate-oi: iRobot Create® driver for node
========================================
An API for interacting with an iRobot Create. Because robots are fun.
---
The iRobot Create provides a low-level serial protocol called the "Open Interface" (OI) documented here.
What this library attempts to do is implement a simple and intuitive API on top of OI in node.js using the great serialport library.
Prerequisites
-------------
* iRobot Create (version 1 or 2)
* Installed usb-serial drivers and connected laptop, Raspberry Pi, Gumstix or similarly node-capable machine to your Create
* see: Windows installation instructions if using a windows laptop (linux comes with drivers, macs will need FTDI drivers)
* node and npm are installed (on above machine)
Installation
------------
``sh`
npm install --save create-oi
Getting Started
-----
After plugging in your Create USB cable you'll need to find
out what serial port your operating system has assigned your Create.
On linux:
`sh`
$ dmesg | grep tty`
On a mac:sh`
$ ls /dev/tty.*`
On a windows box, open device manager and look under "Ports":bat`
C:\> mmc devmgmt.msc
In your code you'll probably want to start with these two lines:
`javascript
var robot = require("create-oi");
robot.init({ serialport: "/dev/tty.usbserial-A2001nf6", version: 1 }); // use version: 2 if using a Create2
`serialport
Make sure to set your to the device name you found earlier. "/dev/tty.usbserial-A2001nf6"
On my mac for me this is . Yours _will_ be different.
The API is event-based, meaning all the important stuff happens in event callbacks.
The first event you'll need to deal with is the ready event which gets fired whenthis
the module sucessfully connects to the Create over the serial port. Note that the context for all your callback handlers will be set to the create-oi module drive
itself, so you can easily call , rotate or any other module method within a bump
callback. Several events such as or wheeldrop will contain information about
which specific sensor was triggered inside the event parameter passed into your
callback function.
`javascript
robot.on('ready', function() {
// twirl towards freedom
this.rotate(100);
});
robot.on('bump', function(bumpEvent) {
console.log(bumpEvent.direction);
...
});
``
Examples
--------
Working examples (provided you change the serial port) can be found in the examples directory.
API Docs
--------
See the API Reference on the wiki.