2016-07-04 23:00:36 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-09-01 19:32:40 +08:00
|
|
|
"os"
|
2016-07-05 02:31:15 +08:00
|
|
|
"time"
|
2016-07-04 23:00:36 +08:00
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/ble"
|
|
|
|
"gobot.io/x/gobot/platforms/parrot/minidrone"
|
2016-07-04 23:00:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 22:58:43 +08:00
|
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
2016-12-07 01:51:14 +08:00
|
|
|
drone := minidrone.NewDriver(bleAdaptor)
|
2016-07-04 23:00:36 +08:00
|
|
|
|
|
|
|
work := func() {
|
2016-12-28 01:30:56 +08:00
|
|
|
drone.TakeOff()
|
2016-12-27 22:53:49 +08:00
|
|
|
|
2016-12-28 01:30:56 +08:00
|
|
|
gobot.After(5*time.Second, func() {
|
|
|
|
drone.Land()
|
2016-07-05 02:31:15 +08:00
|
|
|
})
|
2016-07-04 23:00:36 +08:00
|
|
|
}
|
|
|
|
|
2016-12-07 01:51:14 +08:00
|
|
|
robot := gobot.NewRobot("minidrone",
|
2016-07-04 23:00:36 +08:00
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:08:25 +08:00
|
|
|
robot.Start()
|
2016-07-04 23:00:36 +08:00
|
|
|
}
|