forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minidrone: adds Emergency() and TakePicture() commands
Signed-off-by: deadprogram <[email protected]>
- Loading branch information
1 parent
244b849
commit e6de2a8
Showing
3 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/platforms/ble" | ||
"gobot.io/x/gobot/platforms/parrot/minidrone" | ||
) | ||
|
||
func main() { | ||
bleAdaptor := ble.NewClientAdaptor(os.Args[1]) | ||
drone := minidrone.NewDriver(bleAdaptor) | ||
|
||
work := func() { | ||
drone.On(minidrone.Battery, func(data interface{}) { | ||
fmt.Printf("battery: %d\n", data) | ||
}) | ||
|
||
drone.On(minidrone.FlightStatus, func(data interface{}) { | ||
fmt.Printf("flight status: %d\n", data) | ||
}) | ||
|
||
drone.On(minidrone.Takeoff, func(data interface{}) { | ||
fmt.Println("taking off...") | ||
}) | ||
|
||
drone.On(minidrone.Hovering, func(data interface{}) { | ||
fmt.Println("hovering!") | ||
gobot.After(5*time.Second, func() { | ||
drone.Land() | ||
drone.Land() | ||
}) | ||
}) | ||
|
||
drone.On(minidrone.Landing, func(data interface{}) { | ||
fmt.Println("landing...") | ||
}) | ||
|
||
drone.On(minidrone.Landed, func(data interface{}) { | ||
fmt.Println("landed.") | ||
}) | ||
|
||
time.Sleep(1000 * time.Millisecond) | ||
drone.TakeOff() | ||
} | ||
|
||
robot := gobot.NewRobot("minidrone", | ||
[]gobot.Connection{bleAdaptor}, | ||
[]gobot.Device{drone}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters