2017-03-13 11:01:39 -04:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2017-06-10 13:18:29 +02:00
|
|
|
/*
|
|
|
|
How to run
|
|
|
|
Pass the Bluetooth name or address as first param:
|
|
|
|
|
|
|
|
go run examples/minidrone.go "Mambo_1234"
|
|
|
|
|
|
|
|
NOTE: sudo is required to use BLE in Linux
|
|
|
|
*/
|
|
|
|
|
2016-07-04 17:00:36 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-09-01 13:32:40 +02:00
|
|
|
"os"
|
2016-07-04 20:31:15 +02:00
|
|
|
"time"
|
2016-07-04 17:00:36 +02:00
|
|
|
|
2016-12-08 13:24:03 +01:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/ble"
|
|
|
|
"gobot.io/x/gobot/platforms/parrot/minidrone"
|
2016-07-04 17:00:36 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 16:58:43 +02:00
|
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
2016-12-06 18:51:14 +01:00
|
|
|
drone := minidrone.NewDriver(bleAdaptor)
|
2016-07-04 17:00:36 +02:00
|
|
|
|
|
|
|
work := func() {
|
2016-12-27 18:30:56 +01:00
|
|
|
drone.TakeOff()
|
2016-12-27 15:53:49 +01:00
|
|
|
|
2016-12-27 18:30:56 +01:00
|
|
|
gobot.After(5*time.Second, func() {
|
|
|
|
drone.Land()
|
2016-07-04 20:31:15 +02:00
|
|
|
})
|
2016-07-04 17:00:36 +02:00
|
|
|
}
|
|
|
|
|
2016-12-06 18:51:14 +01:00
|
|
|
robot := gobot.NewRobot("minidrone",
|
2016-07-04 17:00:36 +02:00
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-18 21:08:25 +02:00
|
|
|
robot.Start()
|
2016-07-04 17:00:36 +02:00
|
|
|
}
|