npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dronejs

v1.9.0

Published

A Node.js based library for controlling a Parrot Rolling Spider drone

Downloads

12

Readme

DroneJS

A Node.js based library for controlling a Parrot minidrone. The library also provides the feature to take pictures from the drone, download them all at a time and delete them whenever required. The library follows Bluetooth LE networking protocol to connect to the drone.

Drones Supported

  • Parrot Rolling Spider
  • Parrot Airborne Night Maclane
  • Parrot Airborne Night Blaze
  • Parrot Airborne Night Swat
  • Parrot Airborne Cargo Mars
  • Parrot Airborne Cargo Travis

Prerequisites

Install


npm install dronejs

Usage

Connect

To connect to drone, you need to instantiate the MiniDrone class and then call its connect method.

var minidrone = require('dronejs');

minidrone.connect('RS_')
        .then()
        .catch((e) => {
            console.log('Error occurred: ' + e);
        });

Setup Navdata Stream

To listen to the navigation data from the drone, you need to call the getNavDataStream function and then subscribe to the object returned from it.

var minidrone = require('dronejs');

var navDataStream = minidrone.getNavDataStream();
navDataStream.subscribe((data) => {
        console.log(data);
    },
    err => debug(err),
    () => debug('complete'));


minidrone.connect('RS_')
    .then(() => minidrone.checkAllStates())
    .then()
    .catch((e) => {
        console.log('Error occurred: ' + e);
    });

Basic Maneuvers

var minidrone = require('dronejs');

var navDataStream = minidrone.getNavDataStream();
navDataStream.subscribe((data) => {
        console.log(data);
    },
    err => debug(err),
    () => debug('complete'));


minidrone.connect('RS_')
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.takeOff())
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.forward(50, 5))
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.land())
    .then()
    .catch((e) => {
        console.log('Error occurred: ' + e);
    });

Take Picture

var minidrone = require('dronejs');

var navDataStream = minidrone.getNavDataStream();
navDataStream.subscribe((data) => {
        console.log(data);
    },
    err => debug(err),
    () => debug('complete'));


minidrone.connect('RS_')
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.takeOff())
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.takePicture())
    .then(() => minidrone.flatTrim())
    .then(() => minidrone.land())
    .then()
    .catch((e) => {
        console.log('Error occurred: ' + e);
    });

Download Pictures

var minidrone = require('dronejs');

minidrone.connect('RS_')
    .then(() => minidrone.listAllPictures())
    .then(pictures => minidrone.downloadPicture(pictures[0], 'output'))
    .then(response => {
        if (response === 'success') {
            console.log('picture downloaded successfully...');
        }
    })
    .catch((e) => {
        console.log('Error occurred: ' + e);
    });

Delete Picture

var minidrone = require('dronejs');

minidrone.connect('RS_')
    .then(() => minidrone.listAllPictures())
    .then(pictures => minidrone.deletePicture(pictures[0]))
    .then(response => {
        if (response === 'success') {
            console.log('picture deleted successfully...');
        }
    })
    .catch((e) => {
        console.log('Error occurred: ' + e);
    });

API

  • drone.connect(droneIdentifier)

    Connect the device to the drone.

    droneIdentifier - Local name of the drone as per the advertisement through Bluetooth or UUID of the drone.

  • getNavDataStream()

    Get the stream of navigation data from the drone.

  • checkAllStates()

    Check the device state including the battery percentage.

  • flatTrim()

    Stabilize the drone.

  • takeOff()

    Do a drone take off

  • turnLeft(intensity, frequency)

    Turn the drone to left

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • turnRight(intensity, frequency)

    Turn the drone to right

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • backward(intensity, frequency)

    Move the drone backward

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • forward(intensity, frequency)

    Move the drone forward

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • left(intensity, frequency)

    Move the drone to left

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • right(intensity, frequency)

    Move the drone to right

    intensity - Intensity with which the turn should happen.

    frequency - Number of times drone should perform this action.

  • frontFlip()

    Make the drone do a front flip

  • backFlip()

    Make the drone do a back flip

  • rightFlip()

    Make the drone do a right flip

  • leftFlip()

    Make the drone do a left flip

  • takePicture()

    Take the picture from the drone during flight

  • listAllPictures()

    List all the pictures taken from the drone

  • downloadPicture(name, downloadPath)

    Download a picture

    name - Name of the picture as per the one returned while calling listAllPictures.

    downloadPath - Folder path to store the picture.

  • deletePicture(name)

    Delete a picture

    name - Name of the picture as per the one returned while calling listAllPictures.

  • land()

    Make the drone land

  • disconnect()

    Disconnect the drone

  • enableLogging([ dir ])

    Enable logging

    dir - Optional. Directory to store the logs. If not specified then logs would get printed in the console.