hybridgroup.gobot/examples/ardrone.go

28 lines
582 B
Go

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()
gobot.On(drone.Events["Flying"], func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
}
gbot.Robots = append(gbot.Robots,
gobot.NewRobot("drone", []gobot.Connection{ardroneAdaptor}, []gobot.Device{drone}, work))
gbot.Start()
}