tello

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

Tello

This package contains the Gobot driver for the Ryze Tello drone, sold by DJI.

For more information on this drone, go to: https://www.ryzerobotics.com/tello

How to Install

go get -d -u gobot.io/x/gobot/...

How to Use

Connect to the drone's Wi-Fi network from your computer. It will be named something like "TELLO-XXXXXX".

Once you are connected you can run the Gobot code on your computer to control the drone.

Here is a sample of how you initialize and use the driver:

package main

import (
	"fmt"
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/dji/tello"
)

func main() {
	drone := tello.NewDriver("8888")

	work := func() {
		drone.TakeOff()

		gobot.After(5*time.Second, func() {
			drone.Land()
		})
	}

	robot := gobot.NewRobot("tello",
		[]gobot.Connection{},
		[]gobot.Device{drone},
		work,
	)

	robot.Start()
}

References

This driver could not exist without the awesome members of the unofficial Tello forum:

https://tellopilots.com/forums/tello-development.8/

Special thanks to @Kragrathea who figured out a LOT of the packets and code as implemented in C#: https://github.com/Kragrathea/TelloPC

Also thanks to @microlinux with the Python library which served as the first example for the Tello community: https://github.com/microlinux/tello

Thank you to bluejune for the https://bitbucket.org/PingguSoft/pytello repo, especially the Wireshark Lua dissector which has proven indispensable.

Documentation

Index

Constants

View Source
const (
	// BounceEvent event
	BounceEvent = "bounce"

	// ConnectedEvent event
	ConnectedEvent = "connected"

	// FlightDataEvent event
	FlightDataEvent = "flightdata"

	// TakeoffEvent event
	TakeoffEvent = "takeoff"

	// LandingEvent event
	LandingEvent = "landing"

	// PalmLandingEvent event
	PalmLandingEvent = "palm-landing"

	// FlipEvent event
	FlipEvent = "flip"

	// TimeEvent event
	TimeEvent = "time"

	// LogEvent event
	LogEvent = "log"

	// WifiDataEvent event
	WifiDataEvent = "wifidata"

	// LightStrengthEvent event
	LightStrengthEvent = "lightstrength"

	// SetExposureEvent event
	SetExposureEvent = "setexposure"

	// VideoFrameEvent event
	VideoFrameEvent = "videoframe"

	// SetVideoEncoderRateEvent event
	SetVideoEncoderRateEvent = "setvideoencoder"
)

Variables

This section is empty.

Functions

func CalculateCRC16

func CalculateCRC16(pkt []byte) uint16

CalculateCRC16 calculates the ending CRC16 bytes for packet.

func CalculateCRC8

func CalculateCRC8(pkt []byte) byte

CalculateCRC8 calculates the starting CRC8 byte for packet.

func ValidatePitch

func ValidatePitch(data float64, offset float64) int

ValidatePitch helps validate pitch values such as those created by a joystick to values between 0-100 that are required as params to Tello stick commands.

Types

type Driver

type Driver struct {
	gobot.Eventer
	// contains filtered or unexported fields
}

Driver represents the DJI Tello drone

func NewDriver

func NewDriver(port string) *Driver

NewDriver creates a driver for the Tello drone. Pass in the UDP port to use for the responses from the drone.

func (*Driver) AddVector added in v1.13.0

func (d *Driver) AddVector(x, y, z, psi float32) error

AddVector adds to the current motion vector. Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) BackFlip

func (d *Driver) BackFlip() (err error)

BackFlip tells the drone to perform a back flip.

func (*Driver) Backward

func (d *Driver) Backward(val int) error

Backward tells drone to go in reverse. Pass in an int from 0-100.

func (*Driver) Bounce

func (d *Driver) Bounce() (err error)

Bounce tells drone to start/stop performing the bouncing action

func (*Driver) CeaseRotation

func (d *Driver) CeaseRotation()

CeaseRotation stops any rotational motion

func (*Driver) Clockwise

func (d *Driver) Clockwise(val int) error

Clockwise tells drone to rotate in a clockwise direction. Pass in an int from 0-100.

func (*Driver) Connection

func (d *Driver) Connection() gobot.Connection

Connection returns the Connection of the device.

func (*Driver) CounterClockwise

func (d *Driver) CounterClockwise(val int) error

CounterClockwise tells drone to rotate in a counter-clockwise direction. Pass in an int from 0-100.

func (*Driver) Down

func (d *Driver) Down(val int) error

Down tells the drone to descend. Pass in an int from 0-100.

func (*Driver) Flip

func (d *Driver) Flip(direction FlipType) (err error)

Flip tells drone to flip

func (*Driver) Forward

func (d *Driver) Forward(val int) error

Forward tells the drone to go forward. Pass in an int from 0-100.

func (*Driver) FrontFlip

func (d *Driver) FrontFlip() (err error)

FrontFlip tells the drone to perform a front flip.

func (*Driver) Halt

func (d *Driver) Halt() (err error)

Halt stops the driver.

func (*Driver) Hover

func (d *Driver) Hover()

Hover tells the drone to stop moving on the X, Y, and Z axes and stay in place

func (*Driver) Land

func (d *Driver) Land() (err error)

Land tells drone to come in for landing.

func (*Driver) Left

func (d *Driver) Left(val int) error

Left tells drone to go left. Pass in an int from 0-100.

func (*Driver) LeftFlip

func (d *Driver) LeftFlip() (err error)

LeftFlip tells the drone to perform a flip to the left.

func (*Driver) Name

func (d *Driver) Name() string

Name returns the name of the device.

func (*Driver) PalmLand

func (d *Driver) PalmLand() (err error)

PalmLand tells drone to come in for a hand landing.

func (*Driver) ParseFlightData

func (d *Driver) ParseFlightData(b []byte) (fd *FlightData, err error)

ParseFlightData from drone

func (*Driver) Rate

func (d *Driver) Rate() (err error)

Rate queries the current video bit rate.

func (*Driver) Right

func (d *Driver) Right(val int) error

Right tells drone to go right. Pass in an int from 0-100.

func (*Driver) RightFlip

func (d *Driver) RightFlip() (err error)

RightFlip tells the drone to perform a flip to the right.

func (*Driver) SendCommand

func (d *Driver) SendCommand(cmd string) (err error)

SendCommand is used to send a text command such as the initial connection request to the drone.

func (*Driver) SendDateTime

func (d *Driver) SendDateTime() (err error)

SendDateTime sends the current date/time to the drone.

func (*Driver) SendStickCommand

func (d *Driver) SendStickCommand() (err error)

SendStickCommand sends the joystick command packet to the drone.

func (*Driver) SetExposure

func (d *Driver) SetExposure(level int) (err error)

SetExposure sets the drone camera exposure level. Valid levels are 0, 1, and 2.

func (*Driver) SetFastMode

func (d *Driver) SetFastMode() error

SetFastMode sets the drone throttle to 1.

func (*Driver) SetName

func (d *Driver) SetName(n string)

SetName sets the name of the device.

func (*Driver) SetPsi added in v1.13.0

func (d *Driver) SetPsi(psi float32) error

SetPsi sets the psi component (yaw) of the current motion vector Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) SetSlowMode

func (d *Driver) SetSlowMode() error

SetSlowMode sets the drone throttle to 0.

func (*Driver) SetVector added in v1.13.0

func (d *Driver) SetVector(x, y, z, psi float32) error

SetVector sets the current motion vector. Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) SetVideoEncoderRate

func (d *Driver) SetVideoEncoderRate(rate VideoBitRate) (err error)

SetVideoEncoderRate sets the drone video encoder rate.

func (*Driver) SetX added in v1.13.0

func (d *Driver) SetX(x float32) error

SetX sets the x component of the current motion vector Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) SetY added in v1.13.0

func (d *Driver) SetY(y float32) error

SetY sets the y component of the current motion vector Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) SetZ added in v1.13.0

func (d *Driver) SetZ(z float32) error

SetZ sets the z component of the current motion vector Pass values from 0 to 1. See Vector() for the frame of reference.

func (*Driver) Start

func (d *Driver) Start() error

Start starts the driver.

func (*Driver) StartVideo

func (d *Driver) StartVideo() (err error)

StartVideo tells Tello to send start info (SPS/PPS) for video stream.

func (*Driver) StopLanding

func (d *Driver) StopLanding() (err error)

StopLanding tells drone to stop landing.

func (*Driver) TakeOff

func (d *Driver) TakeOff() (err error)

TakeOff tells drones to liftoff and start flying.

func (*Driver) ThrowTakeOff

func (d *Driver) ThrowTakeOff() (err error)

Throw & Go support

func (*Driver) Up

func (d *Driver) Up(val int) error

Up tells the drone to ascend. Pass in an int from 0-100.

func (*Driver) Vector added in v1.13.0

func (d *Driver) Vector() (x, y, z, psi float32)

Vector returns the current motion vector. Values are from 0 to 1. x, y, z denote forward, side and vertical translation, and psi yaw (rotation around the z-axis).

type FlightData

type FlightData struct {
	BatteryLow               bool
	BatteryLower             bool
	BatteryPercentage        int8
	BatteryState             bool
	CameraState              int8
	DownVisualState          bool
	DroneBatteryLeft         int16
	DroneFlyTimeLeft         int16
	DroneHover               bool
	EmOpen                   bool
	Flying                   bool
	OnGround                 bool
	EastSpeed                int16
	ElectricalMachineryState int16
	FactoryMode              bool
	FlyMode                  int8
	FlyTime                  int16
	FrontIn                  bool
	FrontLSC                 bool
	FrontOut                 bool
	GravityState             bool
	VerticalSpeed            int16
	Height                   int16
	ImuCalibrationState      int8
	ImuState                 bool
	LightStrength            int8
	NorthSpeed               int16
	OutageRecording          bool
	PowerState               bool
	PressureState            bool
	SmartVideoExitMode       int16
	TemperatureHigh          bool
	ThrowFlyTimer            int8
	WindState                bool
}

FlightData packet returned by the Tello

func (*FlightData) AirSpeed added in v1.13.0

func (f *FlightData) AirSpeed() float64

func (*FlightData) GroundSpeed

func (f *FlightData) GroundSpeed() float64

type FlipType

type FlipType int

FlipType is used for the various flips supported by the Tello.

const (
	// FlipFront flips forward.
	FlipFront FlipType = 0

	// FlipLeft flips left.
	FlipLeft FlipType = 1

	// FlipBack flips backwards.
	FlipBack FlipType = 2

	// FlipRight flips to the right.
	FlipRight FlipType = 3

	// FlipForwardLeft flips forwards and to the left.
	FlipForwardLeft FlipType = 4

	// FlipBackLeft flips backwards and to the left.
	FlipBackLeft FlipType = 5

	// FlipBackRight flips backwards and to the right.
	FlipBackRight FlipType = 6

	// FlipForwardRight flips forewards and to the right.
	FlipForwardRight FlipType = 7
)

type VideoBitRate

type VideoBitRate int

VideoBitRate is used to set the bit rate for the streaming video returned by the Tello.

const (
	// VideoBitRateAuto sets the bitrate for streaming video to auto-adjust.
	VideoBitRateAuto VideoBitRate = 0

	// VideoBitRate1M sets the bitrate for streaming video to 1 Mb/s.
	VideoBitRate1M VideoBitRate = 1

	// VideoBitRate15M sets the bitrate for streaming video to 1.5 Mb/s
	VideoBitRate15M VideoBitRate = 2

	// VideoBitRate2M sets the bitrate for streaming video to 2 Mb/s.
	VideoBitRate2M VideoBitRate = 3

	// VideoBitRate3M sets the bitrate for streaming video to 3 Mb/s.
	VideoBitRate3M VideoBitRate = 4

	// VideoBitRate4M sets the bitrate for streaming video to 4 Mb/s.
	VideoBitRate4M VideoBitRate = 5
)

type WifiData

type WifiData struct {
	Disturb  int8
	Strength int8
}

WifiData packet returned by the Tello

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL