hybridgroup.gobot/examples/ardrone.go

38 lines
690 B
Go
Raw Normal View History

package main
import (
"github.com/hybridgroup/gobot"
2014-04-29 02:23:12 +08:00
"github.com/hybridgroup/gobot/ardrone"
)
func main() {
2014-04-29 02:23:12 +08:00
ardroneAdaptor := ardrone.NewArdroneAdaptor()
ardroneAdaptor.Name = "Drone"
2014-04-29 02:23:12 +08:00
drone := ardrone.NewArdroneDriver(ardroneAdaptor)
drone.Name = "Drone"
work := func() {
drone.TakeOff()
gobot.On(drone.Events["Flying"], func(data interface{}) {
gobot.After("1s", func() {
drone.Right(0.1)
})
gobot.After("2s", func() {
drone.Left(0.1)
})
gobot.After("3s", func() {
drone.Land()
})
})
}
robot := gobot.Robot{
Connections: []gobot.Connection{ardroneAdaptor},
Devices: []gobot.Device{drone},
Work: work,
}
robot.Start()
}