Hello, Node Bebop Drone
We love drones, and we've had our brand new Parrot Bebop for a little while. However, we did not have any way to control Parrot's new "high-end" consumer drone using JavaScript.
Without further ado, introducing node-bebop, a node module to control the Parrot Bebop quadcopter.
There are already so many wonderful JavaScript code examples out there for the ARDrone, thanks to the fine efforts of the NodeCopter crew.
Our objective was to be able to use the Parrot Bebop with code compatible with NodeCopter. And we wanted to do this, despite the Bebop having an entirely new API, one which is incompatible with the ARDrone, despite both of them being WiFi devices.
So we created node-bebop
using a very similar outward-facing API as that pioneered by the NodeCopter team, but calling the new Bebop API within our implementation.
Here is an example of using node-bebop
:
var bebop = require('node-bebop'); var drone = bebop.createClient(); drone.connect(function() { drone.takeOff(); setTimeout(function() { drone.land(); }, 5000); });
This code should look very familiar to any of the thousands of people who attended a NodeCopter event.
Most of the flight commands have already been implemented. In addition, node-bebop
can receive basic navigation data, and streaming video data.
In parallel to all of our efforts, @voodootikigod aka Chris Williams has been rallying the forks of node-rolling-spider, a JavaScript module for Parrot's OTHER new drone, the $99 Rolling Spider, into a 1.0 release. The API of the node-rolling-spider
project is also "NodeCopter-compatible", and has its own rapidly growing community. Much of their example code will likely work with node-bebop
as well.
We have cylon-bebop too
We have also created cylon-bebop as a wrapper around node-bebop
, so you can control the Bebop using Cylon.js if you so prefer.
Here is an example that uses cylon-bebop
along with cylon-joystick, to control a Bebop using a Dualshock 3 controller:
var cylon = require("cylon"); cylon.robot({ connections: { joystick: { adaptor: "joystick" }, bebop: { adaptor: 'bebop' } }, devices: { controller: { driver: "dualshock-3", connection: "joystick" }, drone: { driver: "bebop", connection: "bebop" } }, work: function() { var that = this, rightStick = { x: 0.0, y: 0.0 }, leftStick = { x: 0.0, y: 0.0 }; that.controller.on("square:press", function() { that.drone.takeOff(); }); that.controller.on("triangle:press", function() { that.drone.stop(); }); that.controller.on("x:press", function() { that.drone.land(); }); that.controller.on("right_x:move", function(data) { rightStick.x = data; }); that.controller.on("right_y:move", function(data) { rightStick.y = data; }); that.controller.on("left_x:move", function(data) { leftStick.x = data; }); that.controller.on("left_y:move", function(data) { leftStick.y = data; }); setInterval(function() { var pair = leftStick; if (pair.y < 0) { that.drone.forward(validatePitch(pair.y)); } else if (pair.y > 0) { that.drone.backward(validatePitch(pair.y)); } if (pair.x > 0) { that.drone.right(validatePitch(pair.x)); } else if (pair.x < 0) { that.drone.left(validatePitch(pair.x)); } }, 0); setInterval(function() { var pair = rightStick; if (pair.y < 0) { that.drone.up(validatePitch(pair.y)); } else if (pair.y > 0) { that.drone.down(validatePitch(pair.y)); } if (pair.x > 0) { that.drone.clockwise(validatePitch(pair.x)); } else if (pair.x < 0) { that.drone.counterClockwise(validatePitch(pair.x)); } }, 0); setInterval(function() { that.drone.stop(); }, 10); } }).start(); function validatePitch(data) { var value = Math.abs(data); if (value >= 0.1) { if (value <= 1.0) { return Math.round(value * 100); } else { return 100; } } else { return 0; } }
Conclusion
The Parrot Bebop is a very cool new drone, and we're happy to offer up node-bebop
and cylon-bebop
so you can take flight using JavaScript at the controls.
Please follow us on Twitter at @CylonJS to receive updates as we continue to work on JavaScript-powered drones, robots, and connected devices.
Posts
- Cylon.js Off And Rolling In 2016
- Cylon.js 1.2.0 - Logging and Timing and BLE! Oh my!
- Cylon.js 1.1.0 - The Big Cleanup
- Hello, Node Bebop Drone
- Cylon.js featured in Wired
- Cylon.js 1.0.0 is here!
- Using Socket.io With The Cylon.js API
- Cylon 0.22.0 - A New Year's Release
- Cylon 0.21.0 is out!
- Creating Multiplatform Precompiled Binaries for Node.js Modules
- Cylon 0.20.0 is out!
- Running Robots From Your Browser With Cylon.js
- Winning the Dreamforce 500 With Cylon.js
- With The New Cylon.js 0.19.0, You Can Be Fluent Too
- Cylon.js on Intel Edison
- Cylon Takes Off on NodeBots Day
- Cylon.js Fun With The Arduino Yun
- Control Robots From Your Pebble
- Making Moves With Intel Galileo
- The Cylon Nest
- Announcing Full Tessel Support!
- Cylon 0.15.0 is Out!
- Cylon.js in Make Magazine!
- Cylon.js At JSConf 2014
- Cylon.js Takes The Stage At MakerFaire
- Cylon.js In Scotland
- Robots Are The New Normal At NextBerlin
- Thingscon - Ich Bin Ein Cylon
- National Robotics Week at the Robotics Society of Southern California
- Functional Robots With Wisp
- Release 0.12 Is For RobotOps
- Making Waves At Makerland
- This One Goes To 0.11 Of Pure JavaScript
- Tipping SCaLE12X
- Intro Robeaux- A Universal User Interface To Robotic Devices
- ng-robots! A Fun Robot Hackathon At The First ng-conf
- Number 9! The Release In Which We Add A Web UX, More Platforms, and Tools
- Release 0.8.0 Makes 10 Platforms
- RobotsConf Was Remarkable
- Dreamforce Means Connected Devices Are A Thing
- Dreamforce Is Coming!
- Welcome, Cylon.js