An implementation of the networking protocols (Bluetooth LE) used by the Parrot MiniDrone - Rolling Spider. This offers an off-the-shelf $99 USD drone that can be controlled by JS -- yay!
Install via Github to get the latest version:
npm install git://github.com/voodootikigod/node-rolling-spider.git
Or, if you're fine with missing some cutting edge stuff, go for npm:
npm install rolling-spider
This module is still under heavy development, so please don't be surprised if you find some functionality missing or undocumented.
However, the documented parts are tested and should work well for most parts.
This is meant to work with hardware. If you use this you agree that by using it you assume all responsibility. If you use it and your drone smashes into your ceiling fan, that's your fault. By using this code you assume all responsibility for your usage of it. I'm not liable for anything you do with this code.
There is a few steps you should take when getting started with this. We're going to learn how to get there by building out a simple script that will take off, move forward a little, then land.
To connect you need to create a new Drone
instance.
var RollingSpider = require("rolling-spider");
var yourDrone = new RollingSpider();
After you've created an instance you now have access to all the functionality of the drone, but there is some stuff you need to do first, namely connecting, running the setup, and starting the ping to keep it connected.
var RollingSpider = require("rolling-spider");
var yourDrone = new RollingSpider();
// NEW CODE BELOW HERE
yourDrone.connect(function() {
yourDrone.setup(function() {
yourDrone.startPing();
});
});
We're now going to create a function that takes a drone and then by using a sequence of temporal
tasks creates a timed sequence of calls to actions on the drone.
We recommend using temporal
over a series of setTimeout
chained calls for your sanity. Please abide by this when playing with the drone and ESPECIALLY if filing a ticket.
var RollingSpider = require("rolling-spider");
var temporal = require("temporal");
var yourDrone = new RollingSpider();
yourDrone.connect(function() {
yourDrone.setup(function() {
// NEW CODE
temporal.queue([
{
delay: 0,
task: function () {
yourDrone.flatTrim();
yourDrone.startPing();
yourDrone.takeOff();
}
},
{
delay: 3000,
task: function () {
yourDrone.forward();
}
},
{
delay: 500,
task: function () {
yourDrone.land();
}
}]);
});
});
And there you have it, you can now control your drone.
Previous versions of the rolling-spider
library required you to specify the UUID for your drone through a discover process. This has been removed in favor of just using the first BLE device that broadcasts with "RS_" as its localname. If you are flying multiple minidrones or in a very populated BLE area, you will want to use the discovery process in order to identify specifically the drone(s) you want to control. Use the Discovery Tool to get the UUID of all nearby BLE devices.
Returns a new Client
object. options
include:
uuid
: The uuid of the drone. Defaults to finding first announced.
Sets the internal fly
state to true
, callback
is invoked after the drone
reports that it is hovering.
Sets the internal fly
state to false
, callback
is invoked after the drone
reports it has landed.
Makes the drone gain or reduce altitude. speed
can be a value from 0
to 1
.
client.clockwise(speed) / client.counterClockwise(speed) or client.turnRight(speed) / client.turnLeft(speed)
Causes the drone to spin. speed
can be a value from 0
to 1
.
Controls the pitch, which a horizontal movement using the camera
as a reference point. speed
can be a value from 0
to 1
.
Controls the roll, which is a horizontal movement using the camera
as a reference point. speed
can be a value from 0
to 1
.
Causes the drone to do an amazing front flip.
Causes the drone to do an amazing back flip.
Causes the drone to do an amazing left flip. DO NOT USE WITH WHEELS ON!!!
Causes the drone to do an amazing right flip. DO NOT USE WITH WHEELS ON!!!
Resets the trim so that your drone's flight is stable. It should always be called before taking off.
Causes the drone to shut off the motors "instantly" (sometimes has to wait for other commands ahead of it to complete... not fully safe yet)