hybridgroup.gobot/examples/ardrone.go

39 lines
604 B
Go
Raw Normal View History

//go:build example
// +build example
//
// Do not build by default.
package main
import (
2014-07-11 08:21:21 +08:00
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/parrot/ardrone"
)
func main() {
ardroneAdaptor := ardrone.NewAdaptor()
drone := ardrone.NewDriver(ardroneAdaptor)
work := func() {
_ = drone.On(ardrone.Flying, func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
drone.TakeOff()
}
2014-07-09 09:36:14 +08:00
robot := gobot.NewRobot("drone",
[]gobot.Connection{ardroneAdaptor},
[]gobot.Device{drone},
work,
)
if err := robot.Start(); err != nil {
panic(err)
}
}