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
Stable. Minor configuration settings have yet to be done, but otherwise this module is stablized and can perform great flight control.
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 (Bluetooth UUID) or the Published Name (something like RS_XXXXXX) of the drone. Defaults to finding first announced.
Event that is emitted on battery change activity. Caution, battery drains pretty fast on this so this may create a high velocity of events.
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.
Options
speed
at which the drive should occur. 0-100 values.steps
the length of steps (time) the drive should happen. 0-100 values.
Makes the drone gain or reduce altitude.
client.clockwise([options]) / client.counterClockwise([options]) or client.turnRight([options]) / client.turnLeft([options])
Options
speed
at which the rotation should occursteps
the length of steps (time) the turning should happen. 0-100 values.
Causes the drone to spin.
speed
at which the drive should occur. 0-100 values.steps
the length of steps (time) the drive should happen. 0-100 values.
Controls the pitch.
client.left([options]) / client.right([options]) or client.tiltLeft([options]) / client.tiltRight([options])
speed
at which the drive should occur. 0-100 values.steps
the length of steps (time) the drive should happen. 0-100 values.
Controls the roll, which is a horizontal movement.
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.
Obtains the signal strength as an RSSI value returned as the second parameter of the callback.
Disconnects from the drone if it is connected.
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)