GithubHelp home page GithubHelp logo

nodetello's Introduction

Ryze Tello drone Node.JS library

Based on PyTello, TelloLib and the tello Go

WARNING

Software in development and provided "as is". Use at your own risk. Safety first! Remove props before test!

How to

const NodeTello = require('./lib/nodetello.js');
const NodeTello_webclient = require('./lib/nodetello_webclient.js');

// init web client
//var webclient = new NodeTello_webclient('ffmpeg');	// in-browser video
var webclient = new NodeTello_webclient('mplayer');	// open mplayer window with low latency video

    webclient.init();

// init drone
var drone = new NodeTello();

// set video path
drone.save_video_path = "./video/";
// set callback for video feed
drone.tello_video_output = function (h264) { webclient.h264encoder_in(h264); };
// config drone telemetry (drone -> node.js -> browser)
drone.tello_telemetry_config = { 
   px: "MVO.PX",
   py: "MVO.PY",
   pz: "MVO.PZ"
};
// set callback for telemetry feed
drone.tello_telemetry_output = function (data) { webclient.telemetry(data); };

// lets go!
drone.init();

// browser -> webclient -> tello commands
webclient.tello_cmd = function (data) { drone.tello_cmd(data); }

Init

Init process is basic at that moment:

  • connect to drone
  • get some settings/values (version and altitude limit)
  • set settings (stick position)
  • init video feed
  • init log and status receive and parse
  • start video transcode (required ffmpeg!)
  • start http server and websocket

Web client

Web client must be available on http://127.0.0.1:8080 after npm start and show almost fine video from drone with 0.5 seconds lag.

Convert video

Video feeds stored to ./video/TIMESTAMP.h264 and must be redecode, e.g. ffmpeg -i TIMESTAMP.h264 -crf 20 video.mp4

Flight

Keyboard

  • Shift + Space - Takeoff
  • Space - Land
  • ArrowUp and ArrowDown - Pitch (forward/backward)
  • ArrowLeft and ArrowRight - Roll (left/right)
  • W and S - Throttle (Up/Down)
  • A and D - Yaw (Rotate)

Speed is limited = 0.5

Gamepad/Joystick

WARNING, used SHANWAN PS3/PC Gamepad (Vendor: 2563 Product: 0575) in Linux

  • Left Stick - trottle and yaw (MODE2)
  • Right Stick - pitch and roll (MODE2)
  • X, Y, A, B - land
  • start - takeoff

Speed is limited = 0.5

Flight data and log

Flight data

  • altitude
  • version
  • speed
  • fly_time
  • wifi
  • other...

Log

  • 29 - MVO (position)
  • 2048 - IMU + ANGLES (pitch, roll, yaw)
  • 16 - ULTRASONIC (basicaly duplicate IMU data)
  • 112
  • 1000
  • 1001
  • 1002
  • 1710
  • 1712
  • 2064
  • 2208
  • 10086
  • 10085
  • 32768

nodetello's People

Contributors

sovgvd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodetello's Issues

Dangerous bitwise manipulation in nodetello.js

The following code

nodetello/lib/nodetello.js

Lines 408 to 410 in 66ae74e

this.setStickData = function(fast, roll, pitch, thr, yaw){
this.stickData = (fast << 44) | (yaw << 33) | (thr << 22) | (pitch << 11) | (roll)
}

is considered potentially dangerous because:

  1. All numbers in JavaScript are represented as double1, which means you can only have integers in the range [โˆ’253, +253],
  2. (Most important) bitwise operators treat their operands as a sequence of 32 bits2 and return a signed 32-bit integer3, so the code (fast << 44) | (yaw << 33) will not work as expected. (Actually, you can try 1 << 32 and see how it goes)

Since this code is used to control the drone, IMO it's really dangerous and may hurt users. How do you think?

Refs:

  1. Number value - ECMAScript Latest Draft (ECMA-262)
  2. Bitwise operators - MDN
  3. The Left Shift Operator - ECMAScript Latest Draft (ECMA-262)

Cannot start the app.js

when I try to start the app.js with node app.js
the following error happens:

(node:25512) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
tello_control listening 0.0.0.0:51615
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open 'D:\nodetello\video\1535987841691.video.h264'
Emitted 'error' event at:
    at lazyFs.open (internal/fs/streams.js:273:12)
    at FSReqWrap.oncomplete (fs.js:139:20)

Hope to know if I am having an issue or not, any way to fix that? Thanks

Question: stick position

Hi @SovGVD

I've been combing through your repo trying to get something in JS to use the low-level packet API.

I had a question about this bit in your code:

// TODO... this string manipulation is soooo slow!
var tmp_roll     = "00000000000"+(parseInt(1024 + 660 * this.stickData.roll) & 0x07ff).toString(2); tmp_roll=tmp_roll.substr(-11);
var tmp_pitch    = "00000000000"+(parseInt(1024 + 660 * this.stickData.pitch) & 0x07ff).toString(2); tmp_pitch=tmp_pitch.substr(-11);
var tmp_throttle = "00000000000"+(parseInt(1024 + 660 * this.stickData.throttle) & 0x07ff).toString(2); tmp_throttle=tmp_throttle.substr(-11);
var tmp_yaw      = "00000000000"+(parseInt(1024 + 660 * this.stickData.yaw) & 0x07ff).toString(2); tmp_yaw=tmp_yaw.substr(-11);
//var tmp_boost    = "00000000000"+(parseInt(1024 + 660 * 0)).toString(2);

Why are you adding 11 0's and then substr'ing them right off immediately after?

I realise this is code ported from go & python and whatever else is out there, but I'm a bit confused about the stick position packets and that's the bit I need to get working :)

Cheers

Add note about installing mplayer first?

Hi, when I ran node app.js on a Mac, I got:

Error: spawn mplayer ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:19)
...

I solved this by installing mplayer (with brew install mplayer). Perhaps it might be worth mentioning this in the README in case others might come across it too?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.