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.
Support for more commands in ollie_driver
- Set Stabilization - Set Rotation Rate - Boost - Set Raw Motor Values - Set Back LED Output
- Loading branch information
1 parent
30b0eb9
commit 9e56ea5
Showing
4 changed files
with
158 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/platforms/ble" | ||
"gobot.io/x/gobot/platforms/sphero/ollie" | ||
) | ||
|
||
func main() { | ||
bleAdaptor := ble.NewClientAdaptor(os.Args[1]) | ||
ollieBot := ollie.NewDriver(bleAdaptor) | ||
|
||
work := func() { | ||
head := 90 | ||
ollieBot.SetRGB(255, 0, 0) | ||
ollieBot.Boost(true) | ||
gobot.Every(1*time.Second, func() { | ||
ollieBot.Roll(0, uint16(head)) | ||
time.Sleep(1 * time.Second) | ||
head += 90 | ||
head = head % 360 | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("ollieBot", | ||
[]gobot.Connection{bleAdaptor}, | ||
[]gobot.Device{ollieBot}, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/platforms/ble" | ||
"gobot.io/x/gobot/platforms/sphero/ollie" | ||
) | ||
|
||
func main() { | ||
bleAdaptor := ble.NewClientAdaptor(os.Args[1]) | ||
ollieBot := ollie.NewDriver(bleAdaptor) | ||
|
||
work := func() { | ||
ollieBot.SetRGB(255, 0, 255) | ||
gobot.Every(1*time.Second, func() { | ||
// Ollie performs 'crazy-ollie' trick | ||
ollieBot.SetRawMotorValues(ollie.Forward, uint8(255), ollie.Forward, uint8(255)) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("ollieBot", | ||
[]gobot.Connection{bleAdaptor}, | ||
[]gobot.Device{ollieBot}, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/platforms/ble" | ||
"gobot.io/x/gobot/platforms/sphero/ollie" | ||
) | ||
|
||
func main() { | ||
bleAdaptor := ble.NewClientAdaptor(os.Args[1]) | ||
ollieBot := ollie.NewDriver(bleAdaptor) | ||
|
||
work := func() { | ||
ollieBot.SetRGB(255, 0, 255) | ||
gobot.Every(1*time.Second, func() { | ||
// Ollie performs 360 spin trick | ||
ollieBot.SetRawMotorValues(ollie.Forward, uint8(255), ollie.Reverse, uint8(255)) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("ollieBot", | ||
[]gobot.Connection{bleAdaptor}, | ||
[]gobot.Device{ollieBot}, | ||
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