2014-04-26 18:11:51 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-04-29 02:23:12 +08:00
|
|
|
"github.com/hybridgroup/gobot/ardrone"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-29 02:23:12 +08:00
|
|
|
ardroneAdaptor := ardrone.NewArdroneAdaptor()
|
2014-04-26 18:11:51 +08:00
|
|
|
ardroneAdaptor.Name = "Drone"
|
|
|
|
|
2014-04-29 02:23:12 +08:00
|
|
|
drone := ardrone.NewArdroneDriver(ardroneAdaptor)
|
2014-04-26 18:11:51 +08:00
|
|
|
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()
|
|
|
|
}
|