2018-04-04 02:42:16 +08:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
|
|
|
/*
|
2018-04-19 15:50:40 +08:00
|
|
|
How to run:
|
|
|
|
Connect to the drone's Wi-Fi network from your computer. It will be named something like "TELLO-XXXXXX".
|
2018-04-04 02:42:16 +08:00
|
|
|
|
2018-04-19 15:50:40 +08:00
|
|
|
Once you are connected you can run the Gobot code on your computer to control the drone.
|
|
|
|
|
|
|
|
go run examples/tello.go
|
2018-04-04 02:42:16 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-04-13 19:49:12 +08:00
|
|
|
"time"
|
2018-04-04 02:42:16 +08:00
|
|
|
|
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/dji/tello"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-04-19 15:50:40 +08:00
|
|
|
drone := tello.NewDriver("8888")
|
2018-04-04 02:42:16 +08:00
|
|
|
|
|
|
|
work := func() {
|
2018-04-13 19:49:12 +08:00
|
|
|
drone.TakeOff()
|
2018-04-04 22:13:37 +08:00
|
|
|
|
2018-04-13 19:49:12 +08:00
|
|
|
gobot.After(5*time.Second, func() {
|
|
|
|
drone.Land()
|
|
|
|
})
|
2018-04-04 02:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("tello",
|
|
|
|
[]gobot.Connection{},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|