Update README

This commit is contained in:
Adrian Zankich 2014-06-08 20:28:17 -07:00
parent 7cf1b991a1
commit a8f649061f
1 changed files with 63 additions and 76 deletions

139
README.md
View File

@ -12,99 +12,87 @@ Want to use Ruby or Javascript on robots? Check out our sister projects Artoo (h
## Examples ## Examples
### Basic #### Gobot with Arduino
#### Gobot on Sphero
```go ```go
package main package main
import ( import (
"github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot-sphero" "github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/gpio"
"time"
) )
func main() { func main() {
gbot := gobot.NewGobot()
spheroAdaptor := new(gobotSphero.SpheroAdaptor) firmataAdaptor := firmata.NewFirmataAdaptor("myFirmata", "/dev/ttyACM0")
spheroAdaptor.Name = "Sphero" led := gpio.NewLedDriver(firmataAdaptor, "myLed", "13")
spheroAdaptor.Port = "/dev/rfcomm0"
sphero := gobotSphero.NewSphero(spheroAdaptor)
sphero.Name = "Sphero"
work := func() { work := func() {
gobot.Every("2s", func() { gobot.Every(1*time.Second, func() {
sphero.Roll(100, uint16(gobot.Rand(360)))
})
}
robot := gobot.Robot{
Connections: []gobot.Connection{spheroAdaptor},
Devices: []gobot.Device{sphero},
Work: work,
}
robot.Start()
}
```
#### Gobot on Arduino
```go
package main
import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot-firmata"
"github.com/hybridgroup/gobot-gpio"
)
func main() {
firmata := new(gobotFirmata.FirmataAdaptor)
firmata.Name = "firmata"
firmata.Port = "/dev/ttyACM0"
led := gobotGPIO.NewLed(firmata)
led.Name = "led"
led.Pin = "13"
work := func() {
gobot.Every("1s", func() {
led.Toggle() led.Toggle()
}) })
} }
robot := gobot.Robot{ gbot.Robots = append(gbot.Robots,
Connections: []gobot.Connection{firmata}, gobot.NewRobot("blinkBot", []gobot.Connection{firmataAdaptor}, []gobot.Device{led}, work))
Devices: []gobot.Device{led},
Work: work, gbot.Start()
}
```
#### Gobot with Sphero
```go
package main
import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
"time"
)
func main() {
gbot := gobot.NewGobot()
adaptor := sphero.NewSpheroAdaptor("Sphero", "/dev/rfcomm0")
ball := sphero.NewSpheroDriver(adaptor, "sphero")
work := func() {
gobot.Every(3*time.Second, func() {
ball.Roll(30, uint16(gobot.Rand(360)))
})
} }
robot.Start() gbot.Robots = append(gbot.Robots,
gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{ball}, work))
gbot.Start()
} }
``` ```
## Hardware Support ## Hardware Support
Gobot has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported: Gobot has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported:
- [Ardrone](http://ardrone2.parrot.com/) <==> [Library](https://github.com/hybridgroup/gobot-ardrone) - [Ardrone](http://ardrone2.parrot.com/) <=> [Library](https://github.com/hybridgroup/tree/master/platforms/ardrone)
- [Arduino](http://www.arduino.cc/) <==> [Library](https://github.com/hybridgroup/gobot-firmata) - [Arduino](http://www.arduino.cc/) <=> [Library](https://github.com/hybridgroup/tree/master/platforms/firmata)
- [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/) <=> [Library](https://github.com/hybridgroup/gobot-beaglebone) - [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/beaglebone)
- [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Library](https://github.com/hybridgroup/gobot-joystick) - [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/joystick)
- [Digispark](http://digistump.com/products/1) <=> [Library](https://github.com/hybridgroup/gobot-digispark) - [Digispark](http://digistump.com/products/1) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/digispark)
- [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Library](https://github.com/hybridgroup/gobot-joystick) - [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/joystick)
- [Leap Motion](https://www.leapmotion.com/) <=> [Library](https://github.com/hybridgroup/gobot-leapmotion) - [Leap Motion](https://www.leapmotion.com/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/leapmotion)
- [Neurosky](http://neurosky.com/products-markets/eeg-biosensors/hardware/) <=> [Library](https://github.com/hybridgroup/gobot-neurosky) - [Neurosky](http://neurosky.com/products-markets/eeg-biosensors/hardware/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/neurosky)
- [OpenCV](http://opencv.org/) <=> [Library](https://github.com/hybridgroup/gobot-opencv) - [OpenCV](http://opencv.org/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/opencv)
- [Spark](https://www.spark.io/) <=> [Library](https://github.com/hybridgroup/gobot-spark) - [Spark](https://www.spark.io/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/spark)
- [Sphero](http://www.gosphero.com/) <=> [Library](https://github.com/hybridgroup/gobot-sphero) - [Sphero](http://www.gosphero.com/) <=> [Library](https://github.com/hybridgroup/tree/dev/platforms/sphero)
Support for many devices that use General Purpose Input/Output (GPIO) have Support for many devices that use General Purpose Input/Output (GPIO) have
a shared set of drivers provded using the cylon-gpio module: a shared set of drivers provded using the cylon-gpio module:
- [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/gobot-gpio) - [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/tree/dev/platforms/gpio)
- Analog Sensor - Analog Sensor
- Button - Button
- Digital Sensor - Digital Sensor
@ -115,7 +103,7 @@ a shared set of drivers provded using the cylon-gpio module:
Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of
drivers provded using the gobot-i2c module: drivers provded using the gobot-i2c module:
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/gobot-i2c) - [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/tree/dev/platforms/i2c)
- BlinkM - BlinkM
- HMC6352 - HMC6352
- Wii Nunchuck Controller - Wii Nunchuck Controller
@ -124,28 +112,27 @@ More platforms and drivers are coming soon...
## Getting Started ## Getting Started
Install the library with: `go get -u github.com/hybridgroup/gobot` Install Gobot with: `go get -u github.com/hybridgroup/gobot`
Then install additional libraries for whatever hardware support you want to use from your robot. For example, `go get -u github.com/hybridgroup/gobot-sphero` to use Gobot with a Sphero.
## API: ## 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. 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.
To activate the API, use the `Api` command like this: To activate the API, require the `github.com/hybridgroup/gobot/api` package and instantiate the `Api` like this:
```go ```go
master := gobot.GobotMaster() master := gobot.NewGobot()
gobot.Api(master) api.NewApi(master).Start()
``` ```
You can also specify the api host and port, and turn on authentication: You can also specify the api host and port, and turn on authentication:
```go ```go
master := gobot.GobotMaster() master := gobot.NewGobot()
api := gobot.Api(master) server := api.NewApi(master)
api.Port = "4000" server.Port = "4000"
api.Username = "Gort" server.Username = "Gort"
api.Password = "klaatu" 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`. 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`.