2015-10-23 07:56:03 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2016-12-07 21:22:12 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/parrot/bebop"
|
2015-10-23 07:56:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 22:58:43 +08:00
|
|
|
bebopAdaptor := bebop.NewAdaptor()
|
|
|
|
drone := bebop.NewDriver(bebopAdaptor)
|
2015-10-23 07:56:03 +08:00
|
|
|
|
|
|
|
work := func() {
|
2016-09-01 18:17:43 +08:00
|
|
|
drone.On(bebop.Flying, func(data interface{}) {
|
2016-04-13 05:32:53 +08:00
|
|
|
gobot.After(10*time.Second, func() {
|
2015-10-23 07:56:03 +08:00
|
|
|
drone.Land()
|
|
|
|
})
|
|
|
|
})
|
2015-10-25 06:50:44 +08:00
|
|
|
|
2016-09-01 19:32:40 +08:00
|
|
|
drone.HullProtection(true)
|
2015-10-25 06:50:44 +08:00
|
|
|
drone.TakeOff()
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("drone",
|
|
|
|
[]gobot.Connection{bebopAdaptor},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:08:25 +08:00
|
|
|
robot.Start()
|
2015-10-23 07:56:03 +08:00
|
|
|
}
|