hybridgroup.gobot/README.md

181 lines
6.6 KiB
Markdown
Raw Normal View History

[![Gobot](https://cdn.rawgit.com/hybridgroup/gobot-site/master/source/images/elements/gophy.png)](http://gobot.io/)
2013-10-22 05:23:24 +08:00
2013-12-06 06:35:30 +08:00
http://gobot.io/
2014-11-04 09:38:20 +08:00
Gobot is a framework using the Go programming language (http://golang.org/) for robotics, physical computing, and the Internet of Things.
2013-11-10 02:51:30 +08:00
It provides a simple, yet powerful way to create solutions that incorporate multiple, different hardware devices at the same time.
Want to use Ruby or Javascript on robots? Check out our sister projects Artoo (http://artoo.io) and Cylon.js (http://cylonjs.com/)
2014-10-29 23:35:28 +08:00
[![GoDoc](https://godoc.org/github.com/hybridgroup/gobot?status.svg)](https://godoc.org/github.com/hybridgroup/gobot)
2014-04-17 00:32:13 +08:00
[![Build Status](https://travis-ci.org/hybridgroup/gobot.png?branch=master)](https://travis-ci.org/hybridgroup/gobot) [![Coverage Status](https://coveralls.io/repos/hybridgroup/gobot/badge.png?branch=master)](https://coveralls.io/r/hybridgroup/gobot?branch=master)
2013-11-10 02:51:30 +08:00
2014-10-29 23:35:28 +08:00
2013-11-10 02:51:30 +08:00
## Examples
2014-06-09 11:28:17 +08:00
#### Gobot with Arduino
2013-11-10 02:51:30 +08:00
```go
package main
2013-11-14 12:50:22 +08:00
2013-11-10 02:51:30 +08:00
import (
2014-07-11 08:02:00 +08:00
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/gpio"
2013-11-10 02:51:30 +08:00
)
func main() {
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
2013-11-10 02:51:30 +08:00
2014-07-11 08:02:00 +08:00
firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "led", "13")
2013-11-10 02:51:30 +08:00
2014-07-11 08:02:00 +08:00
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
2013-11-14 12:50:22 +08:00
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
2013-11-10 02:51:30 +08:00
2014-07-11 08:02:00 +08:00
gbot.AddRobot(robot)
gbot.Start()
2013-11-10 02:51:30 +08:00
}
```
2014-06-09 11:28:17 +08:00
#### Gobot with Sphero
2013-11-25 07:59:36 +08:00
2013-12-06 06:40:29 +08:00
```go
package main
2013-11-25 07:59:36 +08:00
2013-12-06 06:40:29 +08:00
import (
2014-07-11 08:02:00 +08:00
"fmt"
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
2013-12-06 06:40:29 +08:00
)
2013-11-25 07:59:36 +08:00
2013-12-06 06:40:29 +08:00
func main() {
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor, "sphero")
2013-12-06 06:40:29 +08:00
2014-07-11 08:02:00 +08:00
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
2014-02-05 06:27:16 +08:00
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
2014-02-05 06:27:16 +08:00
2014-07-11 08:02:00 +08:00
gbot.AddRobot(robot)
2014-02-05 06:27:16 +08:00
2014-07-11 08:02:00 +08:00
gbot.Start()
2013-12-06 06:40:29 +08:00
}
2013-11-25 07:59:36 +08:00
```
2013-11-10 02:51:30 +08:00
## Hardware Support
Gobot has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported:
2014-11-04 09:38:20 +08:00
2014-06-18 10:36:40 +08:00
- [Ardrone](http://ardrone2.parrot.com/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/ardrone)
- [Arduino](http://www.arduino.cc/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/firmata)
- [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/beaglebone)
- [Digispark](http://digistump.com/products/1) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/digispark)
- [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/joystick)
- [Leap Motion](https://www.leapmotion.com/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/leapmotion)
- [Neurosky](http://neurosky.com/products-markets/eeg-biosensors/hardware/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/neurosky)
- [OpenCV](http://opencv.org/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/opencv)
2014-11-04 09:38:20 +08:00
- [Pebble](https://www.getpebble.com/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/pebble)
2014-06-18 10:36:40 +08:00
- [Spark](https://www.spark.io/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/spark)
- [Sphero](http://www.gosphero.com/) <=> [Library](https://github.com/hybridgroup/gobot/tree/master/platforms/sphero)
2014-11-04 09:38:20 +08:00
2013-12-14 00:54:30 +08:00
Support for many devices that use General Purpose Input/Output (GPIO) have
2014-05-07 17:07:34 +08:00
a shared set of drivers provided using the cylon-gpio module:
2013-12-14 00:54:30 +08:00
2014-06-18 10:36:40 +08:00
- [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/platforms/gpio)
2014-03-27 02:59:12 +08:00
- Analog Sensor
2013-12-14 00:54:30 +08:00
- Button
2014-11-04 09:38:20 +08:00
- Direct Pin
2014-03-27 02:59:12 +08:00
- Digital Sensor
- Direct Pin
2013-12-14 00:54:30 +08:00
- LED
2014-11-04 09:38:20 +08:00
- MakeyButton
2014-03-27 02:59:12 +08:00
- Motor
2013-12-14 00:54:30 +08:00
- Servo
2013-11-10 02:51:30 +08:00
2013-12-17 06:20:21 +08:00
Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of
2014-05-07 17:07:34 +08:00
drivers provided using the gobot-i2c module:
2013-12-17 06:20:21 +08:00
2014-06-18 10:36:40 +08:00
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/platforms/i2c)
2014-03-27 02:59:12 +08:00
- BlinkM
- HMC6352
2013-12-17 06:20:21 +08:00
- Wii Nunchuck Controller
2013-11-10 02:51:30 +08:00
More platforms and drivers are coming soon...
2013-12-06 06:35:30 +08:00
## Getting Started
2014-06-09 11:28:17 +08:00
Install Gobot with: `go get -u github.com/hybridgroup/gobot`
2013-12-06 06:35:30 +08:00
2013-11-25 07:59:36 +08:00
## API:
Gobot includes a RESTful API to query the status of any robot running within a group, including the connection and device status, and execute device commands.
2014-06-11 06:16:11 +08:00
To activate the API, require the `github.com/hybridgroup/gobot/api` package and instantiate the `API` like this:
2013-11-25 07:59:36 +08:00
2014-11-04 09:38:20 +08:00
```go
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
api.NewAPI(gbot).Start()
2013-11-25 07:59:36 +08:00
```
You can also specify the api host and port, and turn on authentication:
2014-11-04 09:38:20 +08:00
```go
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
server := api.NewAPI(gbot)
2014-06-09 11:28:17 +08:00
server.Port = "4000"
server.Username = "Gort"
server.Password = "klaatu"
server.Start()
2013-11-25 07:59:36 +08:00
```
2013-11-10 02:51:30 +08:00
2014-07-11 02:13:32 +08:00
You may access the [robeaux](https://github.com/hybridgroup/robeaux) AngularJS interface with Gobot by navigating to `http://localhost:3000/index.html`.
2014-02-05 06:15:21 +08:00
2013-11-10 02:51:30 +08:00
## Documentation
We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot
Thank you!
## Contributing
2014-04-29 20:27:25 +08:00
* All active development is in the `dev` branch. New or updated features must be added to the `dev` branch. Hotfixes will be considered on the `master` branch in situations where it does not alter behaviour or features, only fixes a bug.
2013-12-28 10:33:36 +08:00
* All patches must be provided under the Apache 2.0 License
2013-12-29 04:36:56 +08:00
* Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
* Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
2013-12-28 10:33:36 +08:00
* We will look at the patch, test it out, and give you feedback.
* Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
* Take care to maintain the existing coding style.
2014-06-11 06:16:11 +08:00
* `golint` and `go fmt` your code.
2013-12-28 10:33:36 +08:00
* Add unit tests for any new or changed functionality.
2013-12-29 04:36:56 +08:00
* All pull requests should be "fast forward"
2013-12-28 10:33:36 +08:00
* If there are commits after yours use “git rebase -i <new_head_branch>
* If you have local changes you may need to use “git stash”
2013-12-29 04:36:56 +08:00
* For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git
2013-12-28 10:33:36 +08:00
2013-11-10 02:51:30 +08:00
## License
2014-03-26 04:52:48 +08:00
Copyright (c) 2013-2014 The Hybrid Group. Licensed under the Apache 2.0 license.