hybridgroup.gobot/examples/ardrone.go

32 lines
584 B
Go
Raw Normal View History

package main
import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/ardrone"
"time"
)
func main() {
gbot := gobot.NewGobot()
ardroneAdaptor := ardrone.NewArdroneAdaptor("Drone")
drone := ardrone.NewArdroneDriver(ardroneAdaptor, "Drone")
work := func() {
drone.TakeOff()
2014-07-09 09:36:14 +08:00
gobot.On(drone.Event("Flying"), func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
}
2014-07-09 09:36:14 +08:00
robot := gobot.NewRobot("drone",
[]gobot.Connection{ardroneAdaptor},
[]gobot.Device{drone},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}