Giter Club home page Giter Club logo

node-drone-server's Introduction

node-drone-server-base

TCP server to control a drone.

Also, drone video stream.

This is some base code. Feel free to change or extend.

Install

Download this repo:

$ git clone https://github.com/pgte/node-drone-server-base.git
$ cd node-drone-server-base

Install dependencies:

$ npm install

Also, you need to have ffmgep installed to run the video server.

https://www.ffmpeg.org/

Run

$ npm start

Environment variables:

  • DRONE: IP Address for the drone. Defaults to "192.168.1.1".
  • COMMAND_PORT: TCP command server port. Defaults to 3001.
  • VIDEO_PORT: HTTP video server port. Defaults to 3002.
  • NOVIDEO: Launch without the video server

TCP Command Server

Besides an HTTP server running on port 3000, this also launches a TCP server running on port 3001.

You can accesss it from the command line by using, for instance telnet or (preferably) netcat:

$ nc localhost 3000

Now you can issue commands.

Protocol

Each command is a JSON-encoded array terminated by a new-line character.

Each command has the following structure:

[<command>, <arguments>, <id>]

The command is a string identifying the command ("takeoff", "land", "stop", "up", "down", "left", "right", etc..).

arguments is an array of arguments. Can be empty ([]), or contain the arguments required for that specific command (see the available commands and arguments in the ar-drone API docs).

id is a mandatory number that identifies the command

The response

To each command, the server responds with a new-line terminated and JSON-encoded string like this:

[<result>, <id>]

result is an array. The first position of that array is the error (null if no error, and the second is the result, if any).

Example interaction

$ nc localhost 3001
["takeoff",[],1]
[[null],1]
["left",[0.1],2]
[[null],2]

Video Server

There is a video server running on port 3002.

Go to http://localhost:3002/nodecopter.mjpeg to check it out.

(if you want to launch without a video server, set the NOVIDEO environment variable to true).

If you need to change the server output format, change the ffserver.conf file.

node-drone-server

node-drone-server's People

Contributors

corzzo avatar

Watchers

James Cloos avatar  avatar

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.