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.
- Loading branch information
Showing
8 changed files
with
81 additions
and
8 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,25 @@ | ||
package gobot | ||
|
||
import "github.com/codegangsta/martini" | ||
|
||
func Api(bot *Gobot) { | ||
m := martini.Classic() | ||
|
||
m.Get("/robots", func() string { | ||
return toJson(bot.Robots) | ||
}) | ||
|
||
m.Get("/robots/:robotname", func(params martini.Params) string { | ||
return toJson(bot.FindRobot(params["robotname"])) | ||
}) | ||
|
||
m.Get("/robots/:robotname/devices", func(params martini.Params) string { | ||
return toJson(bot.FindRobot(params["robotname"]).GetDevices()) | ||
}) | ||
|
||
m.Get("/robots/:robotname/devices/:devicename", func(params martini.Params) string { | ||
return toJson(bot.FindRobotDevice(params["robotname"], params["devicename"])) | ||
}) | ||
|
||
go m.Run() | ||
} |
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
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,38 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot-sphero" | ||
) | ||
|
||
func main() { | ||
bot := gobot.NewGobot() | ||
gobot.Api(bot) | ||
|
||
spheros := map[string]string{ | ||
"Sphero-BPO": "127.0.0.1:4560", | ||
} | ||
|
||
for name, port := range spheros { | ||
spheroAdaptor := new(gobotSphero.SpheroAdaptor) | ||
spheroAdaptor.Name = "sphero" | ||
spheroAdaptor.Port = port | ||
|
||
sphero := gobotSphero.NewSphero(spheroAdaptor) | ||
sphero.Name = "sphero" | ||
sphero.Interval = "0.5s" | ||
|
||
work := func(){ | ||
sphero.SetRGB(uint8(255), uint8(0), uint8(0)) | ||
} | ||
|
||
bot.Robots = append(bot.Robots, gobot.Robot { | ||
Name: name, | ||
Connections: []interface{} { spheroAdaptor }, | ||
Devices: []interface{} { sphero }, | ||
Work: work, | ||
}) | ||
} | ||
|
||
bot.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
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