2023-05-20 14:25:21 +02:00
|
|
|
//go:build example
|
2017-03-13 11:01:39 -04:00
|
|
|
// +build example
|
2023-05-20 14:25:21 +02:00
|
|
|
|
2017-03-13 11:01:39 -04:00
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2015-10-22 16:56:03 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-05-20 14:25:21 +02:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/parrot/bebop"
|
2015-10-22 16:56:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 16:58:43 +02:00
|
|
|
bebopAdaptor := bebop.NewAdaptor()
|
|
|
|
drone := bebop.NewDriver(bebopAdaptor)
|
2015-10-22 16:56:03 -07:00
|
|
|
|
|
|
|
work := func() {
|
2016-09-01 12:17:43 +02:00
|
|
|
drone.On(bebop.Flying, func(data interface{}) {
|
2016-04-12 14:32:53 -07:00
|
|
|
gobot.After(10*time.Second, func() {
|
2015-10-22 16:56:03 -07:00
|
|
|
drone.Land()
|
|
|
|
})
|
|
|
|
})
|
2015-10-24 15:50:44 -07:00
|
|
|
|
2016-09-01 13:32:40 +02:00
|
|
|
drone.HullProtection(true)
|
2015-10-24 15:50:44 -07:00
|
|
|
drone.TakeOff()
|
2015-10-22 16:56:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("drone",
|
|
|
|
[]gobot.Connection{bebopAdaptor},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-18 21:08:25 +02:00
|
|
|
robot.Start()
|
2015-10-22 16:56:03 -07:00
|
|
|
}
|