Fly Parrot MiniDrones with Node JS
This package wraps the BlueTooth low energy library Noble to expose a simple API for flying Parrot MiniDrones. That includes the Rolling Spider, Airborne Cargo, Night and Hydrofoil models. Unlike other libraries that are designed to run stepped commands, this library is designed to allow continuous control through any input device.
npm install parrot-minidrone
index.js
with the below codenode index.js
const Drone = require('parrot-minidrone');
const drone = new Drone({
autoconnect: true,
});
drone.on('connected', () => drone.takeOff());
drone.on('flightStatusChange', (status) => {
if (status === 'hovering') {
drone.land();
process.exit();
}
});
In the examples folder of this library are a few scripts using the API to fly drones with various input devices.
Follow these directions from the root of the project to fly with a PS3/4 controller
node examples/dualshock-ps3-controller/drone.js
Button | Function |
---|---|
Right Analog Stick | Altitude, yaw |
Left Analog Stick | Roll, pitch |
Square | Flat-trim |
Triangle | Toggle takeoff & land |
Circle | Emergency landing |
X | Take a picture |
L1 | Left flip |
R1 | Right Flip |
L2 | Front Flip |
R2 | Back Flip |
To fly with the keyboard follow the below instructions.
node examples/keyboard/drone.js
Key | Function |
---|---|
Arrow Up | Pitch + |
Arrow Down | Pitch - |
Left Arrow | Roll left |
Left Arrow | Roll right |
w | Altitude + |
s | Altitude + |
a | Yaw left |
d | Yaw right |
t | Toggle takeoff & land |
f | Flattrim |
Escape | Emergency land |
To run the test runner execute npm test
.