2018-04-04 02:42:16 +08:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
|
|
|
/*
|
|
|
|
How to run
|
2018-04-04 19:37:44 +08:00
|
|
|
Pass the UDP port to use for the ground station to receive responses from the drone as first param:
|
2018-04-04 02:42:16 +08:00
|
|
|
|
2018-04-04 19:37:44 +08:00
|
|
|
go run examples/tello.go "8888"
|
2018-04-04 02:42:16 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
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() {
|
|
|
|
drone := tello.NewDriver(os.Args[1])
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|