asticode / go-astitello

Golang implementation of DJI Tello SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoReportCard GoDoc Test Coveralls

This is a Golang implementation of the DJI Tello SDK.

Up-to-date SDK documentation can be downloaded here.

Right now this library is compatible with v1.3.0.0 of SDK (documentation)

Disclaimer

Tello is a registered trademark of Ryze Tech. The author of this package is in no way affiliated with Ryze, DJI, or Intel.

Use this package at your own risk. The author(s) is/are in no way responsible for any damage caused either to or by the drone when using this software.

Install the project

Run the following command:

$ go get -u github.com/asticode/go-astitello/...

Run the example

IMPORTANT: the drone will make a flip to its right during this example, make sure you have enough space around the drone!

  1. Switch on your drone

  2. Connect to its Wifi

  3. If this is the first time you're using it, you may have to activate it using the official app

  4. If you want to test the video, install ffmpeg on your machine

  5. Run the following command:

$ go run example/main.go
  1. Watch your drone take off, make a flip to its right and land! Make sure to look at the terminal output too, some valuable information were printed there!

  2. If you've installed ffmpeg you should also see a new file called example.ts. Check it out!

Use it in your code

WARNING1: the code below doesn't handle errors for readibility purposes. However you SHOULD!

WARNING2: the code below doesn't list all available methods, be sure to check out the doc!

Set up the drone

// Create logger
l := log.New(os.StdErr, "", 0)

// Create the drone
d := astitello.New(l)

// Start the drone
d.Start()

// Make sure to close the drone once everything is over
defer d.Close()

Basic commands

// Handle take off event
d.On(astitello.TakeOffEvent, func(interface{}) { l.Println("drone has took off!") })

// Take off
d.TakeOff()

// Flip
d.Flip(astitello.FlipRight)

// Log state
l.Printf("state is: %+v\n", d.State())

// In case you're using controllers, you can use set sticks positions directly
d.SetSticks(-20, 10, -30, 40)

// Land
d.Land()

Video

// Handle new video packet
d.On(astitello.VideoPacketEvent, astitello.VideoPacketEventHandler(func(p []byte) {
    l.Printf("video packet length: %d\n", len(p))
}))

// Start video
d.StartVideo()

// Make sure to stop video
defer d.StopVideo()

Why this library?

First off, I'd like to say there are very nice DJI Tello libraries out there such as:

Unfortunately they seem to rely on reverse-engineering the official app which is undocumented.

If you'd rather use a library that is based on an official documentation, you've come to the right place!

Known problems with the SDK

  • sometimes a cmd doesn't get any response back from the SDK. In that case the cmd will idle until its timeout is reached.

About

Golang implementation of DJI Tello SDK

License:MIT License


Languages

Language:Go 100.0%