2015-10-23 07:56:03 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/bebop"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
bebopAdaptor := bebop.NewBebopAdaptor("Drone")
|
|
|
|
drone := bebop.NewBebopDriver(bebopAdaptor, "Drone")
|
|
|
|
|
|
|
|
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,
|
|
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|