tello

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 12 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

Please refer to the main README.md

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/v2"
  "gobot.io/x/gobot/v2/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()
}

Telo Edu driver

If you are planning to connect to the edu version of the tello, please use the NewDriverWithIP driver instead

drone := tello.NewDriverWithIP("192.168.10.1", "8888")

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 NewDriverWithIP

func NewDriverWithIP(ip string, port string) *Driver

NewDriverWithIP creates a driver for the Tello EDU drone. Pass in the ip address and UDP port to use for the responses from the drone.

func (*Driver) AddVector

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() 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() 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) 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() error

FrontFlip tells the drone to perform a front flip.

func (*Driver) Halt

func (d *Driver) Halt() 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() 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() 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() error

PalmLand tells drone to come in for a hand landing.

func (*Driver) ParseFlightData

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

ParseFlightData from drone

func (*Driver) Rate

func (d *Driver) Rate() 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() error

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

func (*Driver) SendCommand

func (d *Driver) SendCommand(cmd string) 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() error

SendDateTime sends the current date/time to the drone.

func (*Driver) SendStickCommand

func (d *Driver) SendStickCommand() error

SendStickCommand sends the joystick command packet to the drone.

func (*Driver) SetExposure

func (d *Driver) SetExposure(level int) 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

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

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) error

SetVideoEncoderRate sets the drone video encoder rate.

func (*Driver) SetX

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

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

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() error

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

func (*Driver) StopLanding

func (d *Driver) StopLanding() error

StopLanding tells drone to stop landing.

func (*Driver) TakeOff

func (d *Driver) TakeOff() error

TakeOff tells drones to liftoff and start flying.

func (*Driver) ThrowTakeOff

func (d *Driver) ThrowTakeOff() 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

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 // How much battery left [in %].
	CameraState              int8
	DroneBatteryLeft         int16
	DroneFlyTimeLeft         int16
	DroneHover               bool // If the drone is in the air and not moving.
	EmOpen                   bool
	Flying                   bool  // If the drone is currently in the air.
	OnGround                 bool  // If the drone is currently on the ground.
	EastSpeed                int16 // Movement speed towards East [in cm/s]. Negative if moving west.
	ElectricalMachineryState int16
	FactoryMode              bool
	FlyMode                  int8
	FlyTime                  int16 // How long since take off [in s/10].
	FrontIn                  bool
	FrontLSC                 bool
	FrontOut                 bool
	GravityState             bool
	VerticalSpeed            int16 // Movement speed up [in cm/s].
	Height                   int16 // The height [in decimeters].
	ImuCalibrationState      int8  // The IMU calibration step (when doing IMU calibration).
	NorthSpeed               int16 // Movement speed towards North [in cm/s]. Negative if moving South.
	ThrowFlyTimer            int8

	// Warnings:
	DownVisualState bool // If the ground is visible by the down camera.
	BatteryState    bool // If there is an issue with battery.
	ImuState        bool // If drone needs IMU (Inertial Measurement Unit) calibration.
	OutageRecording bool // If there is an issue with video recording.
	PowerState      bool // If there is an issue with power supply.
	PressureState   bool // If there is an issue with air pressure.
	TemperatureHigh bool // If drone is overheating.
	WindState       bool // If the wind is too strong.
}

FlightData packet returned by the Tello.

The meaning of some fields is not documented. If you learned more, please, contribute. See https://github.com/hybridgroup/gobot/issues/798.

func (*FlightData) AirSpeed

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