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

yatsw

v1.0.0-beta.2

Published

A Ryze Tello SDK wrapper for NodeJS

Downloads

5

Readme

TelloDrone (Yet Another Tello SDK Wrapper)

A NodeJS wrapper for the Ryze Tello SDK 1.3.

Motivation

I did not find a library I liked, so I made mine.

Features

  • Easy set up and minimal boilerplate.
  • All the SDK commands are available and return a promise.
  • Telemetry is broadcasted as a stringified object.
  • Video buffer is broadcasted too and ready to use.
  • Built in method for taking pictures (experimental).

Installation and basic use

Install with npm:

npm install --save yatsw

The library exports a single class:

const { TelloDrone } = require('yatsw')

Create a new instance:

const Tello = new TelloDrone()

Fly:

Tello.start()
Tello.takeoff()
Tello.forward(100)
Tello.yawCW(360)
Tello.land()

Fly better:

async function roll() {
  Tello.start()
  Tello.takeoff()
  Tello.forward(100)
  const height = await Tello.getHeight()
  console.log(height)
  Tello.yawCW(360)
  Tello.up(150)
  const r = await Tello.takePicture('./img.jpg')
  console.log(r)
  Tello.land()
}
roll()

Events

You can listen to the messages from the aircraft throught the MESSAGE event:

Tello.on(Tello.events.MESSAGE, data => {
	console.log(data)
})

These would be the same results you would get when the single promises of the command methods resolve.

Telemetry data can be reached in the same fashion:

Tello.on(Tello.events.STATE, data => {
	console.log(JSON.parse(data))
})

In the same way you can consume the video stream (the below example is for Linux)

const { spawn } = require('child_process')
const { TelloDrone } = require('./src/TelloDrone')
const videoPlayer = spawn('mplayer', ['-fps', '35', '-'])
const Tello = new TelloDrone('myTello')
Tello.on(Tello.events.VIDEO, data => videoPlayer.stdin.write(data))
Tello.start()
Tello.streamOn()

NOTE

Don't forget to connect to the Tello WiFi before running any related script.

The TelloDrone class

The TelloDrone class constructor accepts 3 arguments, all of them are optionals.

  1. A string used as id to idetify the class itself;
  2. An object for specifing non default values to connect to the aircraft. A partial object is ok too and the missing values will be filled by the defaults.
{
  AIRCRAFT_PORT: 8889,
  STATUS_PORT: 8890,
  VIDEO_PORT: 11111,
  HOST: '192.168.10.1',
}
  1. An array of objects describing the methods names and the commands to send to the aircraft. Please check the source code if you're interested in working with this.

List of the public methods

The public methods reflect the commands you can send to the aircraft. I've only changed a couple of them for clarity. The returned values and/or arguments are those described in the official SDK documentation. Each one of them returns a promise. The promises both resolve and reject with an object: resolve({ message }) or reject({ error: message || error }).

  • start() puts the aircraft in SDK mode, it has to be called prior to any other command
  • panic() stops all the rotors (emergency command)
  • getHeight()
  • getBattery()
  • getTime()
  • getSpeed()
  • getWiFi()
  • getTemp()
  • getAttitude()
  • getBaro()
  • getAcceleration()
  • getTOF()
  • setSpeed(value)
  • takeOff()
  • land()
  • emergencyLand() it will send the land command with higher priority and skip all those commands queued
  • up(value)
  • down(value)
  • left(value)
  • right(value)
  • forward(value)
  • back(value)
  • yawCW(value) the actual command sent is cw value
  • yawCCW(value) the actual command sent is ccw value
  • flip(value)
  • flyTo(valueX, valueY, valueZ, speed) the actual command sent is go valueX valueY valueZ speed
  • curve(valueX, valueY, valueZ, valueX2, valueY2, valueZ2, speed)
  • fourChannel(chA, chB, chC, chD) the actual command sent is rc chA chB chC chD

NOTE: the command for setting the WiFi is intentionally missing.

In addition there are 3 more commands that are different for some reasons:

  • streamOn() it starts the stream video and set up a ticker to keep the video alive
  • streamOff() stops the video and kill the ticker
  • takePicture(path = '-') it takes a picture using ffmpeg. If a path is provided the image is saved there otherwise the returned promise will resolve an object that will have a buffer field for the image data. In case you trigger the picture without starting the video stream first, the promise will still resolve, but it will return a warning. NOTE: Windows is not supported yet, but OSX might just work if you have ffmpeg installed.

Known issues

  • Taking a picture without for getting the buffer is still buggy and might not work at all.