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() {
|
|
|
|
gobot.On(drone.Event("flying"), func(data interface{}) {
|
|
|
|
gobot.After(3*time.Second, func() {
|
|
|
|
drone.Land()
|
|
|
|
})
|
|
|
|
})
|
2015-10-25 06:50:44 +08:00
|
|
|
|
|
|
|
drone.HullProtection(true)
|
|
|
|
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()
|
|
|
|
}
|