Skip to content

Commit

Permalink
Merge pull request hybridgroup#75 from hybridgroup/dev
Browse files Browse the repository at this point in the history
0.6 release
  • Loading branch information
Javier Cervantes committed Jul 11, 2014
2 parents be058d5 + b044c1b commit 7ed5017
Show file tree
Hide file tree
Showing 109 changed files with 7,150 additions and 1,127 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.sass-cache
*.test
robeaux
profile.cov
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
0.6
---
- api
- Add robeaux support
- core
- Refactor `Connection` and `Device`
- Connections are now a collection of Adaptors
- Devices are now a collection of Drivers
- Add `Event(string)` function instead of `Events[string]` for retrieving Driver event
- Add `AddEvent(string)` function to register an event on a Driver
- firmata
- Fix slice bounds out of range error
- sphero
- Fix issue where the driver would not halt correctly on OSX

0.5.2
---
- beaglebone
- Add `DirectPinDriver`
- Ensure slots are properly loaded

0.5.1
---
- core
- Add `Version()` function for Gobot version retrieval
- firmata
- Fix issue with reading analog inputs
- Add `data` event for `AnalogSensorDriver`

0.5
---
- Idomatic clean up
- Removed reflections throughout packages
- All officially supported platforms are now in ./platforms
- API is now a new package ./api
- All platforms examples are in ./examples
- Replaced martini with net/http
- Replaced ginkgo/gomega with system testing package
- Refactor gobot/robot/device commands
- Added Event type
- Replaced Master type with Gobot type
- Every` and `After` now accept `time.Duration`
- Removed reflection helper methods
26 changes: 23 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
PACKAGES := "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/api" "github.com/hybridgroup/gobot/platforms/ardrone" "github.com/hybridgroup/gobot/platforms/beaglebone" "github.com/hybridgroup/gobot/platforms/digispark" "github.com/hybridgroup/gobot/platforms/firmata" "github.com/hybridgroup/gobot/platforms/gpio" "github.com/hybridgroup/gobot/platforms/i2c" "github.com/hybridgroup/gobot/platforms/leap" "github.com/hybridgroup/gobot/platforms/neurosky" "github.com/hybridgroup/gobot/platforms/pebble" "github.com/hybridgroup/gobot/platforms/spark" "github.com/hybridgroup/gobot/platforms/sphero" "github.com/hybridgroup/gobot/platforms/opencv" "github.com/hybridgroup/gobot/platforms/joystick"
PACKAGES := gobot gobot/api $(shell ls ./platforms | sed -e 's/^/gobot\/platforms\//')

.PHONY: test cover robeaux

test:
for package in $(PACKAGES) ; do \
go test $$package ; \
go test github.com/hybridgroup/$$package ; \
done ; \

cover:
echo "mode: count" > profile.cov ; \
for package in $(PACKAGES) ; do \
go test -covermode=count -coverprofile=tmp.cov $$package ; \
go test -covermode=count -coverprofile=tmp.cov github.com/hybridgroup/$$package ; \
cat tmp.cov | grep -v "mode: count" >> profile.cov ; \
done ; \
rm tmp.cov ; \

robeaux:
ifeq (,$(shell which go-bindata))
$(error robeaux not built! https://github.com/jteeuwen/go-bindata is required to build robeaux assets )
endif
cd api ; \
git clone --depth 1 git://github.com/hybridgroup/robeaux.git robeaux-tmp; \
cd robeaux-tmp ; \
rm fonts/* ; \
rm Makefile package.json README.markdown robeaux.gemspec css/fonts.css ; \
touch css/fonts.css ; \
echo "Updating robeaux to $(shell git rev-parse HEAD)" ; \
go-bindata -pkg="robeaux" -o robeaux.go -ignore=\\.git ./... ; \
mv robeaux.go ../robeaux ; \
cd .. ; \
rm -rf robeaux-tmp/ ; \
go fmt ./robeaux/robeaux.go ; \

81 changes: 47 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,34 @@ Want to use Ruby or Javascript on robots? Check out our sister projects Artoo (h
package main

import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/gpio"
"time"
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/gpio"
)

func main() {
gbot := gobot.NewGobot()
gbot := gobot.NewGobot()

adaptor := firmata.NewFirmataAdaptor("myFirmata", "/dev/ttyACM0")
led := gpio.NewLedDriver(adaptor, "myLed", "13")
firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "led", "13")

work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}

gbot.Robots = append(gbot.Robots,
gobot.NewRobot("blink", []gobot.Connection{adaptor}, []gobot.Device{led}, work))
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)

gbot.Start()
gbot.AddRobot(robot)

gbot.Start()
}
```

Expand All @@ -49,27 +55,34 @@ func main() {
package main

import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
"time"
"fmt"
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
)

func main() {
gbot := gobot.NewGobot()
gbot := gobot.NewGobot()

adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor, "sphero")

adaptor := sphero.NewSpheroAdaptor("Sphero", "/dev/rfcomm0")
ball := sphero.NewSpheroDriver(adaptor, "sphero")
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}

work := func() {
gobot.Every(3*time.Second, func() {
ball.Roll(30, uint16(gobot.Rand(360)))
})
}
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)

gbot.Robots = append(gbot.Robots,
gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{ball}, work))
gbot.AddRobot(robot)

gbot.Start()
gbot.Start()
}
```

Expand Down Expand Up @@ -121,21 +134,21 @@ Gobot includes a RESTful API to query the status of any robot running within a g
To activate the API, require the `github.com/hybridgroup/gobot/api` package and instantiate the `API` like this:

```go
master := gobot.NewGobot()
api.NewAPI(master).Start()
gbot := gobot.NewGobot()
api.NewAPI(gbot).Start()
```

You can also specify the api host and port, and turn on authentication:
```go
master := gobot.NewGobot()
server := api.NewAPI(master)
gbot := gobot.NewGobot()
server := api.NewAPI(gbot)
server.Port = "4000"
server.Username = "Gort"
server.Password = "klaatu"
server.Start()
```

In order to use the [robeaux](https://github.com/hybridgroup/robeaux) AngularJS interface with Gobot you simply clone the robeaux repo and place it in the directory of your Gobot program. The robeaux assets must be in a folder called `robeaux`.
You may access the [robeaux](https://github.com/hybridgroup/robeaux) AngularJS interface with Gobot by navigating to `http://localhost:3000/index.html`.

## Documentation
We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot
Expand Down
85 changes: 69 additions & 16 deletions adaptor.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,86 @@
package gobot

import "fmt"

type Adaptor struct {
Name string
Port string
Connected bool
Params map[string]interface{}
name string
port string
connected bool
params map[string]interface{}
adaptorType string
}

type AdaptorInterface interface {
Finalize() bool
Connect() bool
port() string
name() string
setName(string)
params() map[string]interface{}
Port() string
Name() string
Type() string
Connected() bool
SetConnected(bool)
SetName(string)
Params() map[string]interface{}
ToJSON() *JSONConnection
}

func NewAdaptor(name string, adaptorType string, v ...interface{}) *Adaptor {
if name == "" {
name = fmt.Sprintf("%X", Rand(int(^uint(0)>>1)))
}

a := &Adaptor{
adaptorType: adaptorType,
name: name,
port: "",
params: make(map[string]interface{}),
}

for i := range v {
switch v[i].(type) {
case string:
a.port = v[i].(string)
case map[string]interface{}:
a.params = v[i].(map[string]interface{})
default:
fmt.Println("Unknown argument passed to NewAdaptor")
}
}

return a
}

func (a *Adaptor) Port() string {
return a.port
}

func (a *Adaptor) Name() string {
return a.name
}

func (a *Adaptor) SetName(s string) {
a.name = s
}

func (a *Adaptor) Type() string {
return a.adaptorType
}

func (a *Adaptor) port() string {
return a.Port
func (a *Adaptor) Connected() bool {
return a.connected
}

func (a *Adaptor) name() string {
return a.Name
func (a *Adaptor) SetConnected(b bool) {
a.connected = b
}

func (a *Adaptor) setName(s string) {
a.Name = s
func (a *Adaptor) Params() map[string]interface{} {
return a.params
}

func (a *Adaptor) params() map[string]interface{} {
return a.Params
func (a *Adaptor) ToJSON() *JSONConnection {
return &JSONConnection{
Name: a.Name(),
Port: a.Port(),
Adaptor: a.Type(),
}
}
Loading

0 comments on commit 7ed5017

Please sign in to comment.