1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00

core(build): CLI removed (#946)

* core(build): CLI removed
* adjust install instructions in doc and README
* fix master_test and remove useless/duplicated tests examples_test.go
This commit is contained in:
Thomas Kohler 2023-06-04 18:36:55 +02:00 committed by GitHub
parent ac849e7616
commit 0d0a508c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 1500 additions and 2001 deletions

4
.gitignore vendored
View File

@ -1,14 +1,14 @@
.sass-cache
*.test
*.swp
*.snap
profile.cov
count.out
*.swp
*.snap
/parts
/prime
/stage
vendor/
output/
.idea/
coverage.txt
.chglog/chglog_tmp*.md

View File

@ -47,6 +47,7 @@ Descriptions for each of these will eventually be provided below.
* 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”
* For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git
* Use one of the latest existing platforms/drivers etc. as a blueprint for creating a new one
## Creating Pull Requests
@ -58,9 +59,9 @@ The basics are as follows:
1. Fork the project via the GitHub UI
2. `go get` the upstream repo and set it up as the `upstream` remote and your own repo as the `origin` remote:
2. `git clone` the upstream repo and set it up as the `upstream` remote and your own repo as the `origin` remote:
`go get gobot.io/x/gobot/v2`
`git clone https://github.com/hybridgroup/gobot.git`
`cd $GOPATH/src/gobot.io/x/gobot`
`git remote rename origin upstream`
`git remote add origin git@github.com/YOUR_GITHUB_NAME/gobot`

379
README.md
View File

@ -7,87 +7,122 @@
[![Go Report Card](https://goreportcard.com/badge/hybridgroup/gobot)](https://goreportcard.com/report/hybridgroup/gobot)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/hybridgroup/gobot/blob/master/LICENSE.txt)
Gobot (https://gobot.io/) is a framework using the Go programming language (https://golang.org/) for robotics, physical
Gobot (<https://gobot.io/>) is a framework using the Go programming language (<https://golang.org/>) for robotics, physical
computing, and the Internet of Things.
It provides a simple, yet powerful way to create solutions that incorporate multiple, different hardware devices at the
same time.
Want to run Go directly on microcontrollers? Check out our sister project TinyGo (https://tinygo.org/)
Want to run Go directly on microcontrollers? Check out our sister project TinyGo (<https://tinygo.org/>)
## Getting Started
Get the Gobot package by running this command: `go get -d -u gobot.io/x/gobot/v2`
### Get in touch
Get the Gobot source code by running this commands:
```sh
git clone https://github.com/hybridgroup/gobot.git
git checkout release
```
Afterwards have a look at the [examples directory](./examples). You need to find an example matching your platform for your
first test (e.g. "raspi_blink.go"). Than build the binary (cross compile), transfer it to your target and run it.
`env GOOS=linux GOARCH=arm GOARM=5 go build -o ./output/my_raspi_bink examples/raspi_blink.go`
> Building the code on your local machine with the example code above will create a binary for ARMv5. This is probably not
> what you need for your specific target platform. Please read also the platform specific documentation in the platform
> subfolders.
### Create your first project
Create a new folder and a new Go module project.
```sh
mkdir ~/my_gobot_example
go mod init my.gobot.example.com
```
Copy your example file besides the go.mod file, import the requirements and build.
```sh
go mod tidy
env GOOS=linux GOARCH=arm GOARM=5 go build -o ./output/my_raspi_bink raspi_blink.go
```
Now you are ready to modify the example and test your changes. Start by removing the build directives at the beginning
of the file.
## Examples
#### Gobot with Arduino
### Gobot with Arduino
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
)
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
#### Gobot with Sphero
### Gobot with Sphero
```go
package main
import (
"fmt"
"time"
"fmt"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/sphero"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/sphero"
)
func main() {
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor)
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor)
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
robot.Start()
robot.Start()
}
```
#### "Metal" Gobot
### "Metal" Gobot
You can use the entire Gobot framework as shown in the examples above ("Classic" Gobot), or you can pick and choose from
the various Gobot packages to control hardware with nothing but pure idiomatic Golang code ("Metal" Gobot). For example:
@ -96,26 +131,26 @@ the various Gobot packages to control hardware with nothing but pure idiomatic G
package main
import (
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/edison"
"time"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/edison"
"time"
)
func main() {
e := edison.NewAdaptor()
e.Connect()
e := edison.NewAdaptor()
e.Connect()
led := gpio.NewLedDriver(e, "13")
led.Start()
led := gpio.NewLedDriver(e, "13")
led.Start()
for {
led.Toggle()
time.Sleep(1000 * time.Millisecond)
}
for {
led.Toggle()
time.Sleep(1000 * time.Millisecond)
}
}
```
#### "Master" Gobot
### "Master" Gobot
You can also use the full capabilities of the framework aka "Master Gobot" to control swarms of robots or other features
such as the built-in API server. For example:
@ -124,62 +159,62 @@ such as the built-in API server. For example:
package main
import (
"fmt"
"time"
"fmt"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/api"
"gobot.io/x/gobot/v2/platforms/sphero"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/api"
"gobot.io/x/gobot/v2/platforms/sphero"
)
func NewSwarmBot(port string) *gobot.Robot {
spheroAdaptor := sphero.NewAdaptor(port)
spheroDriver := sphero.NewSpheroDriver(spheroAdaptor)
spheroDriver.SetName("Sphero" + port)
spheroAdaptor := sphero.NewAdaptor(port)
spheroDriver := sphero.NewSpheroDriver(spheroAdaptor)
spheroDriver.SetName("Sphero" + port)
work := func() {
spheroDriver.Stop()
work := func() {
spheroDriver.Stop()
spheroDriver.On(sphero.Collision, func(data interface{}) {
fmt.Println("Collision Detected!")
})
spheroDriver.On(sphero.Collision, func(data interface{}) {
fmt.Println("Collision Detected!")
})
gobot.Every(1*time.Second, func() {
spheroDriver.Roll(100, uint16(gobot.Rand(360)))
})
gobot.Every(3*time.Second, func() {
spheroDriver.SetRGB(uint8(gobot.Rand(255)),
uint8(gobot.Rand(255)),
uint8(gobot.Rand(255)),
)
})
}
gobot.Every(1*time.Second, func() {
spheroDriver.Roll(100, uint16(gobot.Rand(360)))
})
gobot.Every(3*time.Second, func() {
spheroDriver.SetRGB(uint8(gobot.Rand(255)),
uint8(gobot.Rand(255)),
uint8(gobot.Rand(255)),
)
})
}
robot := gobot.NewRobot("sphero",
[]gobot.Connection{spheroAdaptor},
[]gobot.Device{spheroDriver},
work,
)
robot := gobot.NewRobot("sphero",
[]gobot.Connection{spheroAdaptor},
[]gobot.Device{spheroDriver},
work,
)
return robot
return robot
}
func main() {
master := gobot.NewMaster()
api.NewAPI(master).Start()
master := gobot.NewMaster()
api.NewAPI(master).Start()
spheros := []string{
"/dev/rfcomm0",
"/dev/rfcomm1",
"/dev/rfcomm2",
"/dev/rfcomm3",
}
spheros := []string{
"/dev/rfcomm0",
"/dev/rfcomm1",
"/dev/rfcomm2",
"/dev/rfcomm3",
}
for _, port := range spheros {
master.AddRobot(NewSwarmBot(port))
}
for _, port := range spheros {
master.AddRobot(NewSwarmBot(port))
}
master.Start()
master.Start()
}
```
@ -233,94 +268,94 @@ Support for many devices that use General Purpose Input/Output (GPIO) have
a shared set of drivers provided using the `gobot/drivers/gpio` package:
- [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/gpio)
- AIP1640 LED
- Button
- Buzzer
- Direct Pin
- EasyDriver
- Grove Button
- Grove Buzzer
- Grove LED
- Grove Magnetic Switch
- Grove Relay
- Grove Touch Sensor
- LED
- Makey Button
- Motor
- Proximity Infra Red (PIR) Motion Sensor
- Relay
- RGB LED
- Servo
- Stepper Motor
- TM1638 LED Controller
- AIP1640 LED
- Button
- Buzzer
- Direct Pin
- EasyDriver
- Grove Button
- Grove Buzzer
- Grove LED
- Grove Magnetic Switch
- Grove Relay
- Grove Touch Sensor
- LED
- Makey Button
- Motor
- Proximity Infra Red (PIR) Motion Sensor
- Relay
- RGB LED
- Servo
- Stepper Motor
- TM1638 LED Controller
Support for many devices that use Analog Input/Output (AIO) have
a shared set of drivers provided using the `gobot/drivers/aio` package:
- [AIO](https://en.wikipedia.org/wiki/Analog-to-digital_converter) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/aio)
- Analog Sensor
- Grove Light Sensor
- Grove Piezo Vibration Sensor
- Grove Rotary Dial
- Grove Sound Sensor
- Grove Temperature Sensor
- Analog Sensor
- Grove Light Sensor
- Grove Piezo Vibration Sensor
- Grove Rotary Dial
- Grove Sound Sensor
- Grove Temperature Sensor
Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of
drivers provided using the `gobot/drivers/i2c` package:
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/i2c)
- Adafruit 2x16 RGB-LCD with 5 keys
- Adafruit Motor Hat
- ADS1015 Analog to Digital Converter
- ADS1115 Analog to Digital Converter
- ADXL345 Digital Accelerometer
- BH1750 Digital Luminosity/Lux/Light Sensor
- BlinkM LED
- BME280 Barometric Pressure/Temperature/Altitude/Humidity Sensor
- BMP180 Barometric Pressure/Temperature/Altitude Sensor
- BMP280 Barometric Pressure/Temperature/Altitude Sensor
- BMP388 Barometric Pressure/Temperature/Altitude Sensor
- DRV2605L Haptic Controller
- Generic driver for read and write values to/from register address
- Grove Digital Accelerometer
- GrovePi Expansion Board
- Grove RGB LCD
- HMC6352 Compass
- HMC5883L 3-Axis Digital Compass
- INA3221 Voltage Monitor
- JHD1313M1 LCD Display w/RGB Backlight
- L3GD20H 3-Axis Gyroscope
- LIDAR-Lite
- MCP23017 Port Expander
- MMA7660 3-Axis Accelerometer
- MPL115A2 Barometric Pressure/Temperature
- MPU6050 Accelerometer/Gyroscope
- PCA9501 8-bit I/O port with interrupt, 2-kbit EEPROM
- PCA953x LED Dimmer for PCA9530 (2-bit), PCA9533 (4-bit), PCA9531 (8-bit), PCA9532 (16-bit)
- PCA9685 16-channel 12-bit PWM/Servo Driver
- PCF8583 clock and calendar or event counter, 240 x 8-bit RAM
- PCF8591 8-bit 4xA/D & 1xD/A converter
- SHT2x Temperature/Humidity
- SHT3x-D Temperature/Humidity
- SSD1306 OLED Display Controller
- TSL2561 Digital Luminosity/Lux/Light Sensor
- Wii Nunchuck Controller
- YL-40 Brightness/Temperature sensor, Potentiometer, analog input, analog output Driver
- Adafruit 2x16 RGB-LCD with 5 keys
- Adafruit Motor Hat
- ADS1015 Analog to Digital Converter
- ADS1115 Analog to Digital Converter
- ADXL345 Digital Accelerometer
- BH1750 Digital Luminosity/Lux/Light Sensor
- BlinkM LED
- BME280 Barometric Pressure/Temperature/Altitude/Humidity Sensor
- BMP180 Barometric Pressure/Temperature/Altitude Sensor
- BMP280 Barometric Pressure/Temperature/Altitude Sensor
- BMP388 Barometric Pressure/Temperature/Altitude Sensor
- DRV2605L Haptic Controller
- Generic driver for read and write values to/from register address
- Grove Digital Accelerometer
- GrovePi Expansion Board
- Grove RGB LCD
- HMC6352 Compass
- HMC5883L 3-Axis Digital Compass
- INA3221 Voltage Monitor
- JHD1313M1 LCD Display w/RGB Backlight
- L3GD20H 3-Axis Gyroscope
- LIDAR-Lite
- MCP23017 Port Expander
- MMA7660 3-Axis Accelerometer
- MPL115A2 Barometric Pressure/Temperature
- MPU6050 Accelerometer/Gyroscope
- PCA9501 8-bit I/O port with interrupt, 2-kbit EEPROM
- PCA953x LED Dimmer for PCA9530 (2-bit), PCA9533 (4-bit), PCA9531 (8-bit), PCA9532 (16-bit)
- PCA9685 16-channel 12-bit PWM/Servo Driver
- PCF8583 clock and calendar or event counter, 240 x 8-bit RAM
- PCF8591 8-bit 4xA/D & 1xD/A converter
- SHT2x Temperature/Humidity
- SHT3x-D Temperature/Humidity
- SSD1306 OLED Display Controller
- TSL2561 Digital Luminosity/Lux/Light Sensor
- Wii Nunchuck Controller
- YL-40 Brightness/Temperature sensor, Potentiometer, analog input, analog output Driver
Support for devices that use Serial Peripheral Interface (SPI) have
a shared set of drivers provided using the `gobot/drivers/spi` package:
- [SPI](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/spi)
- APA102 Programmable LEDs
- MCP3002 Analog/Digital Converter
- MCP3004 Analog/Digital Converter
- MCP3008 Analog/Digital Converter
- MCP3202 Analog/Digital Converter
- MCP3204 Analog/Digital Converter
- MCP3208 Analog/Digital Converter
- MCP3304 Analog/Digital Converter
- MFRC522 RFID Card Reader
- SSD1306 OLED Display Controller
- APA102 Programmable LEDs
- MCP3002 Analog/Digital Converter
- MCP3004 Analog/Digital Converter
- MCP3008 Analog/Digital Converter
- MCP3202 Analog/Digital Converter
- MCP3204 Analog/Digital Converter
- MCP3208 Analog/Digital Converter
- MCP3304 Analog/Digital Converter
- MFRC522 RFID Card Reader
- SSD1306 OLED Display Controller
More platforms and drivers are coming soon...
@ -354,20 +389,18 @@ Gobot uses the Gort [http://gort.io](http://gort.io) Command Line Interface (CLI
right from the command line. We call it "RobotOps", aka "DevOps For Robotics". You can scan, connect, update device
firmware, and more!
Gobot also has its own CLI to generate new platforms, adaptors, and drivers. You can check it out in the `/cli` directory.
## Documentation
We're always adding documentation to our web site at https://gobot.io/ please check there as we continue to work on Gobot
We're always adding documentation to our web site at <https://gobot.io/> please check there as we continue to work on Gobot
Thank you!
## Need help?
* Issues: https://github.com/hybridgroup/gobot/issues
* Twitter: [@gobotio](https://twitter.com/gobotio)
* Slack: [https://gophers.slack.com/messages/C0N5HDB08](https://gophers.slack.com/messages/C0N5HDB08)
* Mailing list: https://groups.google.com/forum/#!forum/gobotio
- Issues: <https://github.com/hybridgroup/gobot/issues>
- Twitter: [@gobotio](https://twitter.com/gobotio)
- Slack: [https://gophers.slack.com/messages/C0N5HDB08](https://gophers.slack.com/messages/C0N5HDB08)
- Mailing list: <https://groups.google.com/forum/#!forum/gobotio>
## Contributing

View File

@ -1,40 +0,0 @@
# Gobot CLI
Gobot has its own CLI to generate new platforms, adaptors, and drivers.
## Building the CLI
```
go build -o /path/to/dest/gobot .
```
## Running the CLI
```
/path/to/dest/gobot help
```
Should display help for the Gobot CLI:
```
CLI tool for generating new Gobot projects.
NAME:
gobot - Command Line Utility for generating new Gobot adaptors, drivers, and platforms
USAGE:
gobot [global options] command [command options] [arguments...]
...
```
## Installing from the snap
Gobot is also published in the [snap store](https://snapcraft.io/). It is not yet stable, so you can help testing it in any of the [supported Linux distributions](https://snapcraft.io/docs/core/install) with:
```
sudo snap install gobot --edge
```
## License
Copyright (c) 2013-2018 The Hybrid Group. Licensed under the Apache 2.0 license.

View File

@ -1,11 +0,0 @@
/*
CLI tool for generating new Gobot projects.
NAME:
gobot - Command Line Utility for generating new Gobot adaptors, drivers, and platforms
USAGE:
gobot [global options] command [command options] [arguments...]
*/
package main

View File

@ -1,417 +0,0 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
"text/template"
"github.com/urfave/cli"
)
type config struct {
Package string
Name string
UpperName string
FirstLetter string
Example string
dir string
}
func Generate() cli.Command {
return cli.Command{
Name: "generate",
Usage: "Generate new Gobot adaptors, drivers, and platforms",
Action: func(c *cli.Context) {
valid := false
for _, s := range []string{"adaptor", "driver", "platform"} {
if s == c.Args().First() {
valid = true
}
}
if !valid {
fmt.Println("Invalid/no subcommand supplied.")
fmt.Println("Usage:")
fmt.Println(" gobot generate adaptor <name> [package] # generate a new Gobot adaptor")
fmt.Println(" gobot generate driver <name> [package] # generate a new Gobot driver")
fmt.Println(" gobot generate platform <name> [package] # generate a new Gobot platform")
return
}
if len(c.Args()) < 2 {
fmt.Println("Please provide a one word name.")
return
}
name := strings.ToLower(c.Args()[1])
packageName := name
if len(c.Args()) > 2 {
packageName = strings.ToLower(c.Args()[2])
}
upperName := strings.ToUpper(string(name[0])) + string(name[1:])
cfg := config{
Package: packageName,
UpperName: upperName,
Name: name,
FirstLetter: string(name[0]),
dir: ".",
}
switch c.Args().First() {
case "adaptor":
if err := generateAdaptor(cfg); err != nil {
fmt.Println(err)
}
case "driver":
if err := generateDriver(cfg); err != nil {
fmt.Println(err)
}
case "platform":
pwd, err := os.Getwd()
if err != nil {
fmt.Println(err)
return
}
dir := pwd + "/" + cfg.Name
fmt.Println("Creating", dir)
if err := os.MkdirAll(dir, 0700); err != nil {
fmt.Println(err)
return
}
cfg.dir = dir
examplesDir := dir + "/examples"
fmt.Println("Creating", examplesDir)
if err := os.MkdirAll(examplesDir, 0700); err != nil {
fmt.Println(err)
return
}
if err := generatePlatform(cfg); err != nil {
fmt.Println(err)
}
}
},
}
}
func generate(c config, file string, tmpl string) error {
fileLocation := c.dir + "/" + file
fmt.Println("Creating", fileLocation)
f, err := os.Create(fileLocation)
defer f.Close() //nolint:staticcheck // for historical reasons
if err != nil {
return err
}
t, err := template.New("").Parse(tmpl)
if err != nil {
return err
}
return t.Execute(f, c)
}
func generateDriver(c config) error {
if err := generate(c, c.Name+"_driver.go", driver()); err != nil {
return err
}
return generate(c, c.Name+"_driver_test.go", driverTest())
}
func generateAdaptor(c config) error {
if err := generate(c, c.Name+"_adaptor.go", adaptor()); err != nil {
return err
}
return generate(c, c.Name+"_adaptor_test.go", adaptorTest())
}
func generatePlatform(c config) error {
if err := generateDriver(c); err != nil {
return err
}
if err := generateAdaptor(c); err != nil {
return err
}
dir := c.dir
exampleDir := dir + "/examples"
c.dir = exampleDir
if err := generate(c, "main.go", example()); err != nil {
return err
}
c.dir = dir
exp, err := ioutil.ReadFile(exampleDir + "/main.go")
if err != nil {
return err
}
c.Example = string(exp)
return generate(c, "README.md", readme())
}
func adaptor() string {
return `package {{.Package}}
type {{.UpperName}}Adaptor struct {
name string
}
func New{{.UpperName}}Adaptor() *{{.UpperName}}Adaptor {
return &{{.UpperName}}Adaptor{
name: "{{.UpperName}}",
}
}
func ({{.FirstLetter}} *{{.UpperName}}Adaptor) Name() string { return {{.FirstLetter}}.name }
func ({{.FirstLetter}} *{{.UpperName}}Adaptor) SetName(name string) { {{.FirstLetter}}.name = name }
func ({{.FirstLetter}} *{{.UpperName}}Adaptor) Connect() error { return nil }
func ({{.FirstLetter}} *{{.UpperName}}Adaptor) Finalize() error { return nil }
func ({{.FirstLetter}} *{{.UpperName}}Adaptor) Ping() string { return "pong" }
`
}
func driver() string {
return `package {{.Package}}
import (
"time"
"gobot.io/x/gobot/v2"
)
const Hello string = "hello"
type {{.UpperName}}Driver struct {
name string
connection gobot.Connection
interval time.Duration
halt chan bool
gobot.Eventer
gobot.Commander
}
func New{{.UpperName}}Driver(a *{{.UpperName}}Adaptor) *{{.UpperName}}Driver {
{{.FirstLetter}} := &{{.UpperName}}Driver{
name: "{{.UpperName}}",
connection: a,
interval: 500*time.Millisecond,
halt: make(chan bool, 0),
Eventer: gobot.NewEventer(),
Commander: gobot.NewCommander(),
}
{{.FirstLetter}}.AddEvent(Hello)
{{.FirstLetter}}.AddCommand(Hello, func(params map[string]interface{}) interface{} {
return {{.FirstLetter}}.Hello()
})
return {{.FirstLetter}}
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) Name() string { return {{.FirstLetter}}.name }
func ({{.FirstLetter}} *{{.UpperName}}Driver) SetName(name string) { {{.FirstLetter}}.name = name }
func ({{.FirstLetter}} *{{.UpperName}}Driver) Connection() gobot.Connection {
return {{.FirstLetter}}.connection
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) adaptor() *{{.UpperName}}Adaptor {
return {{.FirstLetter}}.Connection().(*{{.UpperName}}Adaptor)
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) Hello() string {
return "hello from " + {{.FirstLetter}}.Name() + "!"
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) Ping() string {
return {{.FirstLetter}}.adaptor().Ping()
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) Start() error {
go func() {
for {
{{.FirstLetter}}.Publish({{.FirstLetter}}.Event(Hello), {{.FirstLetter}}.Hello())
select {
case <- time.After({{.FirstLetter}}.interval):
case <- {{.FirstLetter}}.halt:
return
}
}
}()
return nil
}
func ({{.FirstLetter}} *{{.UpperName}}Driver) Halt() error {
{{.FirstLetter}}.halt <- true
return nil
}
`
}
func example() string {
return `
package main
import (
"../"
"fmt"
"time"
"gobot.io/x/gobot/v2"
)
func main() {
gbot := gobot.NewMaster()
conn := {{.Package}}.New{{.UpperName}}Adaptor()
dev := {{.Package}}.New{{.UpperName}}Driver(conn)
work := func() {
dev.On(dev.Event({{.Package}}.Hello), func(data interface{}) {
fmt.Println(data)
})
gobot.Every(1200*time.Millisecond, func() {
fmt.Println(dev.Ping())
})
}
robot := gobot.NewRobot(
"robot",
[]gobot.Connection{conn},
[]gobot.Device{dev},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}
`
}
func driverTest() string {
return `package {{.Package}}
import (
"testing"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/gobottest"
)
var _ gobot.Driver = (*{{.UpperName}}Driver)(nil)
func Test{{.UpperName}}Driver(t *testing.T) {
d := New{{.UpperName}}Driver(New{{.UpperName}}Adaptor())
gobottest.Assert(t, d.Name(), "{{.UpperName}}")
gobottest.Assert(t, d.Connection().Name(), "{{.UpperName}}")
ret := d.Command(Hello)(nil)
gobottest.Assert(t, ret.(string), "hello from {{.UpperName}}!")
gobottest.Assert(t, d.Ping(), "pong")
gobottest.Assert(t, len(d.Start()), 0)
time.Sleep(d.interval)
sem := make(chan bool, 0)
d.On(d.Event(Hello), func(data interface{}) {
sem <- true
})
select {
case <-sem:
case <-time.After(600 * time.Millisecond):
t.Errorf("Hello Event was not published")
}
gobottest.Assert(t, len(d.Halt()), 0)
d.On(d.Event(Hello), func(data interface{}) {
sem <- true
})
select {
case <-sem:
t.Errorf("Hello Event should not publish after Halt")
case <-time.After(600 * time.Millisecond):
}
}
`
}
func adaptorTest() string {
return `package {{.Package}}
import (
"testing"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/gobottest"
)
var _ gobot.Adaptor = (*{{.UpperName}}Adaptor)(nil)
func Test{{.UpperName}}Adaptor(t *testing.T) {
a := New{{.UpperName}}Adaptor()
gobottest.Assert(t, a.Name(), "{{.UpperName}}")
gobottest.Assert(t, len(a.Connect()), 0)
gobottest.Assert(t, a.Ping(), "pong")
gobottest.Assert(t, len(a.Connect()), 0)
gobottest.Assert(t, len(a.Finalize()), 0)
}
`
}
func readme() string {
return `# {{.Package}}
Gobot (http://gobot.io/) is a framework for robotics and physical computing using Go
This repository contains the Gobot adaptor and driver for {{.Package}}.
For more information about Gobot, check out the github repo at
https://gobot.io/x/gobot/v2
## Installing
` + "```bash\ngo get path/to/repo/{{.Package}}\n```" + `
## Using
` + "```go{{.Example}}\n```" + `
## Connecting
Explain how to connect to the device here...
## License
Copyright (c) 2018 <Your Name Here>. Licensed under the <Insert license here> license.
`
}

View File

@ -1,21 +0,0 @@
package main
import (
"os"
"github.com/urfave/cli"
"gobot.io/x/gobot/v2"
)
func main() {
app := cli.NewApp()
app.Name = "gobot"
app.Author = "The Gobot team"
app.Email = "https://gobot.io/x/gobot/v2"
app.Version = gobot.Version()
app.Usage = "Command Line Utility for generating new Gobot adaptors, drivers, and platforms"
app.Commands = []cli.Command{
Generate(),
}
app.Run(os.Args)
}

View File

@ -6,11 +6,7 @@ that supports the needed interfaces for analog devices.
## Getting Started
## Installing
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## Hardware Support

View File

@ -3,7 +3,7 @@ Package aio provides Gobot drivers for Analog Input/Output devices.
Installing:
go get -d -u gobot.io/x/gobot/v2
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to aio README:
https://github.com/hybridgroup/gobot/blob/master/platforms/aio/README.md

View File

@ -6,11 +6,7 @@ that supports the needed interfaces for GPIO devices.
## Getting Started
## Installing
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## Hardware Support

View File

@ -3,7 +3,7 @@ Package gpio provides Gobot drivers for General Purpose Input/Output devices.
Installing:
go get -d -u gobot.io/x/gobot/v2
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to gpio README:
https://github.com/hybridgroup/gobot/blob/master/platforms/gpio/README.md

View File

@ -6,11 +6,7 @@ interfaces for i2c devices.
## Getting Started
## Installing
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## Hardware Support

View File

@ -3,7 +3,7 @@ Package i2c provides Gobot drivers for i2c devices.
Installing:
go get -d -u gobot.io/x/gobot/v2
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to i2c README:
https://github.com/hybridgroup/gobot/blob/master/drivers/i2c/README.md

View File

@ -4,11 +4,7 @@ This package provides drivers for [SPI](https://en.wikipedia.org/wiki/Serial_Per
## Getting Started
## Installing
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## Hardware Support

View File

@ -3,7 +3,7 @@ Package spi provides Gobot drivers for spi devices.
Uses periph.io for spi
Installing:
go get -d -u gobot.io/x/gobot/v2
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to spi README:
https://github.com/hybridgroup/gobot/blob/master/drivers/spi/README.md

View File

@ -1,53 +0,0 @@
package gobot_test
import (
"fmt"
"testing"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/gobottest"
)
func ExampleEvery() {
gobot.Every(1*time.Second, func() {
fmt.Println("Hello")
})
}
func ExampleAfter() {
gobot.After(1*time.Second, func() {
fmt.Println("Hello")
})
}
func ExampleRand() {
i := gobot.Rand(100)
fmt.Printf("%v is > 0 && < 100", i)
}
func ExampleFromScale() {
fmt.Println(gobot.FromScale(5, 0, 10))
// Output:
// 0.5
}
func ExampleToScale() {
fmt.Println(gobot.ToScale(500, 0, 10))
// Output:
// 10
}
func ExampleAssert() {
t := &testing.T{}
var a int = 100
var b int = 100
gobottest.Assert(t, a, b)
}
func ExampleRefute() {
t := &testing.T{}
var a int = 100
var b int = 200
gobottest.Refute(t, a, b)
}

View File

@ -34,10 +34,6 @@ func initTestMaster1Robot() *Master {
return g
}
func TestVersion(t *testing.T) {
gobottest.Assert(t, version, Version())
}
func TestNullReadWriteCloser(t *testing.T) {
n := &NullReadWriteCloser{}
i, _ := n.Write([]byte{1, 2, 3})

View File

@ -2,59 +2,60 @@
The BeagleBone is an ARM based single board computer, with lots of GPIO, I2C, and analog interfaces built in.
The Gobot adaptor for the BeagleBone supports all of the various BeagleBone boards such as the BeagleBone Black, SeeedStudio BeagleBone Green, SeeedStudio BeagleBone Green Wireless, and others that use the latest Debian and standard "Cape Manager" interfaces.
The Gobot adaptor for the BeagleBone supports all of the various BeagleBone boards such as the BeagleBone Black,
SeeedStudio BeagleBone Green, SeeedStudio BeagleBone Green Wireless, and others that use the latest Debian and standard
"Cape Manager" interfaces.
For more info about the BeagleBone platform go to [http://beagleboard.org/getting-started](http://beagleboard.org/getting-started).
In addition, there is an separate Adaptor for the PocketBeagle, a USB-key-fob sized computer. The PocketBeagle has a different pin layout and somewhat different capabilities.
In addition, there is an separate Adaptor for the PocketBeagle, a USB-key-fob sized computer. The PocketBeagle has a
different pin layout and somewhat different capabilities.
For more info about the PocketBeagle platform go to [http://beagleboard.org/pocket](http://beagleboard.org/pocket).
## How to Install
We recommend updating to the latest Debian OS when using the BeagleBone. The current Gobot only supports 4.x versions of the OS. If you need support for older versions of the OS, you will need to use Gobot v1.4.
We recommend updating to the latest Debian OS when using the BeagleBone. The current Gobot only supports 4.x versions of
the OS. If you need support for older versions of the OS, you will need to use Gobot v1.4.
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your BeagleBone, and run the program on the BeagleBone itself as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation,
transfer the final executable to your BeagleBone, and run the program on the BeagleBone itself as documented here.
## How to Use
The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.
Gobot also has support for the four built-in LEDs on the BeagleBone Black, by referring to them as `usr0`, `usr1`, `usr2`, and `usr3`.
Gobot also has support for the four built-in LEDs on the BeagleBone Black, by referring to them as `usr0`, `usr1`, `usr2`,
and `usr3`.
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/beaglebone"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/beaglebone"
)
func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P9_12")
beagleboneAdaptor := beaglebone.NewAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P9_12")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -64,30 +65,30 @@ To use the PocketBeagle, use `beaglebone.NewPocketBeagleAdaptor()` like this:
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/beaglebone"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/beaglebone"
)
func main() {
beagleboneAdaptor := beaglebone.NewPocketBeagleAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P1_02")
beagleboneAdaptor := beaglebone.NewPocketBeagleAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P1_02")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("pocketBeagleBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("pocketBeagleBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -97,53 +98,63 @@ func main() {
Compile your Gobot program on your workstation like this:
```bash
$ GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go
```sh
GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go
```
Once you have compiled your code, you can you can upload your program and execute it on the BeagleBone from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the BeagleBone from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp beaglebone_blink debian@192.168.7.2:/home/debian/
$ ssh -t debian@192.168.7.2 "./beaglebone_blink"
```sh
scp beaglebone_blink debian@192.168.7.2:/home/debian/
ssh -t debian@192.168.7.2 "./beaglebone_blink"
```
In order to run the preceeding commands, you must be running the official Debian Linux through the usb->ethernet connection, or be connected to the board using WiFi.
In order to run the preceeding commands, you must be running the official Debian Linux through the usb->ethernet connection,
or be connected to the board using WiFi.
You must also configure hardware settings as described below.
### Updating your board to the latest OS
We recommend using your BeagleBone with the latest Debian OS. It is very easy to do this using the Etcher (https://etcher.io/) utility program.
We recommend using your BeagleBone with the latest Debian OS. It is very easy to do this using the Etcher (<https://etcher.io/>)
utility program.
First, download the latest BeagleBone OS from http://beagleboard.org/latest-images
First, download the latest BeagleBone OS from <http://beagleboard.org/latest-images>
Now, use Etcher to create an SD card with the OS image you have downloaded.
Once you have created the SD card, boot your BeagleBone using the new image as follows:
- Insert SD card into your (powered-down) board, hold down the USER/BOOT button (if using Black) and apply power, either by the USB cable or 5V adapter.
- Insert SD card into your (powered-down) board, hold down the USER/BOOT button (if using Black) and apply power, either
by the USB cable or 5V adapter.
- If all you want to do it boot once from the SD card, it should now be booting.
- If using BeagleBone Black and desire to write the image to your on-board eMMC, you'll need to follow the instructions at http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC. When the flashing is complete, all 4 USRx LEDs will be steady on or off. The latest Debian flasher images automatically power down the board upon completion. This can take up to 45 minutes. Power-down your board, remove the SD card and apply power again to be complete.
- If using BeagleBone Black and desire to write the image to your on-board eMMC, you'll need to follow the instructions at
<http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC>. When the flashing is complete, all 4 USRx LEDs
will be steady on or off. The latest Debian flasher images automatically power down the board upon completion. This can
take up to 45 minutes. Power-down your board, remove the SD card and apply power again to be complete.
These instructions come from the Beagleboard web site's "Getting Started" page located here:
http://beagleboard.org/getting-started
<http://beagleboard.org/getting-started>
### Configure hardware settings
Thanks to the BeagleBone team, the new "U-Boot Overlays" system for enabling hardware and the "cape-universal", the latest Debian OS should "just work" with any GPIO, PWM, I2C, or SPI pins.
Thanks to the BeagleBone team, the new "U-Boot Overlays" system for enabling hardware and the "cape-universal", the latest
Debian OS should "just work" with any GPIO, PWM, I2C, or SPI pins.
If you want to dig in and learn more about this check out:
https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
<https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays>
### Upgrading from an older version
Please note that if you are upgrading a board that has already run from an older version of Debian OS, you might need to clear out your older eMMC bootloader, otherwise the new U-Boot Overlays in the newer U-Boot may not get enabled. If so, login using SSH and run the following command on your BeagleBone board:
Please note that if you are upgrading a board that has already run from an older version of Debian OS, you might need to
clear out your older eMMC bootloader, otherwise the new U-Boot Overlays in the newer U-Boot may not get enabled. If so,
login using SSH and run the following command on your BeagleBone board:
sudo dd if=/dev/zero of=/dev/mmcblk1 count=1 seek=1 bs=128k
`sudo dd if=/dev/zero of=/dev/mmcblk1 count=1 seek=1 bs=128k`
Thanks to [@RobertCNelson](https://github.com/RobertCNelson) for the tip on the above.

View File

@ -4,7 +4,7 @@ separate Adaptor for the PocketBeagle.
Installing:
go get gobot.io/x/gobot/v2/platforms/beaglebone
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -4,7 +4,7 @@ The Gobot BLE adaptor makes it easy to interact with Bluetooth LE aka Bluetooth
It is written using the [TinyGo Bluetooh](tinygo.org/x/bluetooth) package.
Learn more about Bluetooth LE at http://en.wikipedia.org/wiki/Bluetooth_low_energy
Learn more about Bluetooth LE at <http://en.wikipedia.org/wiki/Bluetooth_low_energy>
This package also includes drivers for several well-known BLE Services:
@ -13,13 +13,13 @@ This package also includes drivers for several well-known BLE Services:
- Generic Access Service
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
### macOS
You need to have XCode installed to be able to compile code that uses the Gobot BLE adaptor on macOS. This is because the `bluetooth` package uses a CGo based implementation.
You need to have XCode installed to be able to compile code that uses the Gobot BLE adaptor on macOS. This is because the
`bluetooth` package uses a CGo based implementation.
### Ubuntu
@ -27,24 +27,28 @@ Everything should already just compile on most Linux systems.
### Windows
You will need to have a GCC compiler such as [mingw-w64](https://github.com/mingw-w64/mingw-w64) installed in order to use BLE on Windows.
You will need to have a GCC compiler such as [mingw-w64](https://github.com/mingw-w64/mingw-w64) installed in order to use
BLE on Windows.
## How To Connect
When using BLE a "peripheral" aka "server" is something you connect to such a a pulse meter. A "central" aka "client" is what does the connecting, such as your computer or mobile phone.
When using BLE a "peripheral" aka "server" is something you connect to such a a pulse meter. A "central" aka "client" is
what does the connecting, such as your computer or mobile phone.
You need to know the BLE ID of the peripheral you want to connect to. The Gobot BLE client adaptor also lets you connect to a peripheral by friendly name.
You need to know the BLE ID of the peripheral you want to connect to. The Gobot BLE client adaptor also lets you connect
to a peripheral by friendly name.
### Ubuntu
### Connect on Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/minidrone.go
sudo ./minidrone AA:BB:CC:DD:EE
### Windows
### Connect on Windows
Hopefully coming soon...
@ -56,30 +60,30 @@ Here is an example that uses the BLE "Battery" service to retrieve the current c
package main
import (
"fmt"
"os"
"time"
"fmt"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
battery := ble.NewBatteryDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
battery := ble.NewBatteryDriver(bleAdaptor)
work := func() {
gobot.Every(5*time.Second, func() {
fmt.Println("Battery level:", battery.GetBatteryLevel())
})
}
work := func() {
gobot.Every(5*time.Second, func() {
fmt.Println("Battery level:", battery.GetBatteryLevel())
})
}
robot := gobot.NewRobot("bleBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{battery},
work,
)
robot := gobot.NewRobot("bleBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{battery},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -1,40 +1,43 @@
# C.H.I.P.
The [C.H.I.P.](http://www.getchip.com/) is a small, inexpensive ARM based single board computer, with many different IO interfaces available on the [pin headers](http://docs.getchip.com/#pin-headers).
The [C.H.I.P.](http://www.getchip.com/) is a small, inexpensive ARM based single board computer, with many different IO
interfaces available on the [pin headers](http://docs.getchip.com/#pin-headers).
For documentation about the C.H.I.P. platform click [here](http://docs.getchip.com/).
The [C.H.I.P. Pro](https://getchip.com/pages/chippro) is a version of C.H.I.P. intended for use in embedded product development. Here is info about the [C.H.I.P. Pro pin headers](https://docs.getchip.com/chip_pro.html#pin-descriptions).
The [C.H.I.P. Pro](https://getchip.com/pages/chippro) is a version of C.H.I.P. intended for use in embedded product
development. Here is info about the [C.H.I.P. Pro pin headers](https://docs.getchip.com/chip_pro.html#pin-descriptions).
## How to Install
We recommend updating to the latest Debian OS when using the C.H.I.P., however Gobot should also support older versions of the OS, should your application require this.
We recommend updating to the latest Debian OS when using the C.H.I.P., however Gobot should also support older versions
of the OS, should your application require this.
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your C.H.I.P and run the program on the C.H.I.P. itself as documented here.
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your
workstation, transfer the final executable to your C.H.I.P and run the program on the C.H.I.P. itself as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
### PWM support
Note that PWM might not be available in your kernel. In that case, you can install the required device tree overlay
from the command line using [Gort](https://gobot.io/x/gort) CLI commands on the C.H.I.P device.
Here are the steps:
Install the required patched device tree compiler as described in the [C.H.I.P docs](https://docs.getchip.com/dip.html#make-a-dtbo-device-tree-overlay-blob):
```
```sh
gort chip install dtc
```
Now, install the pwm overlay to activate pwm on the PWM0 pin:
```
```sh
gort chip install pwm
```
Reboot the device to make sure the init script loads the overlay on boot.
## How to Use
The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.
@ -87,12 +90,13 @@ chipProAdaptor := chip.NewProAdaptor()
Compile your Gobot program on your workstation like this:
```bash
$ GOARM=7 GOARCH=arm GOOS=linux go build examples/chip_button.go
GOARM=7 GOARCH=arm GOOS=linux go build examples/chip_button.go
```
Once you have compiled your code, you can you can upload your program and execute it on the C.H.I.P. from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the C.H.I.P. from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp chip_button root@192.168.1.xx:
$ ssh -t root@192.168.1.xx "./chip_button"
scp chip_button root@192.168.1.xx:
ssh -t root@192.168.1.xx "./chip_button"
```

View File

@ -4,50 +4,49 @@ The GoPiGo3 is a robotics controller by Dexter Industries that is compatible wit
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
This example will blink the left and right leds red/blue.
```go
package main
import (
"fmt"
"time"
"fmt"
"time"
"gobot.io/x/gobot/v2"
g "gobot.io/x/gobot/v2/platforms/dexter/gopigo3"
"gobot.io/x/gobot/v2/platforms/raspi"
"gobot.io/x/gobot/v2"
g "gobot.io/x/gobot/v2/platforms/dexter/gopigo3"
"gobot.io/x/gobot/v2/platforms/raspi"
)
func main() {
raspiAdaptor := raspi.NewAdaptor()
gopigo3 := g.NewDriver(raspiAdaptor)
raspiAdaptor := raspi.NewAdaptor()
gopigo3 := g.NewDriver(raspiAdaptor)
work := func() {
on := uint8(0xFF)
gobot.Every(1000*time.Millisecond, func() {
err := gopigo3.SetLED(g.LED_EYE_RIGHT, 0x00, 0x00, on)
if err != nil {
fmt.Println(err)
}
err = gopigo3.SetLED(g.LED_EYE_LEFT, ^on, 0x00, 0x00)
if err != nil {
fmt.Println(err)
}
on = ^on
})
}
work := func() {
on := uint8(0xFF)
gobot.Every(1000*time.Millisecond, func() {
err := gopigo3.SetLED(g.LED_EYE_RIGHT, 0x00, 0x00, on)
if err != nil {
fmt.Println(err)
}
err = gopigo3.SetLED(g.LED_EYE_LEFT, ^on, 0x00, 0x00)
if err != nil {
fmt.Println(err)
}
on = ^on
})
}
robot := gobot.NewRobot("gopigo3",
[]gobot.Connection{raspiAdaptor},
[]gobot.Device{gopigo3},
work,
)
robot := gobot.NewRobot("gopigo3",
[]gobot.Connection{raspiAdaptor},
[]gobot.Device{gopigo3},
work,
)
robot.Start()
robot.Start()
}
```
```

View File

@ -1,33 +1,32 @@
# Digispark
The Digispark is an Attiny85 based microcontroller development board similar to the Arduino line, only cheaper, smaller, and a bit less powerful. With a whole host of shields to extend its functionality and the ability to use the familiar Arduino IDE the Digispark is a great way to jump into electronics, or perfect for when an Arduino is too big or too much.
The Digispark is an Attiny85 based microcontroller development board similar to the Arduino line, only cheaper, smaller,
and a bit less powerful. With a whole host of shields to extend its functionality and the ability to use the familiar
Arduino IDE the Digispark is a great way to jump into electronics, or perfect for when an Arduino is too big or too much.
This package provides the Gobot adaptor for the [Digispark](http://digistump.com/products/1) ATTiny-based USB development board with the [Little Wire](http://littlewire.github.io/) protocol firmware installed.
This package provides the Gobot adaptor for the [Digispark](http://digistump.com/products/1) ATTiny-based USB development
board with the [Little Wire](http://littlewire.github.io/) protocol firmware installed.
## How to Install
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
This package requires `libusb`.
### OSX
To install `libusb` on OSX using Homebrew:
```
$ brew install libusb && brew install libusb-compat
```sh
brew install libusb && brew install libusb-compat
```
### Ubuntu
To install libusb on linux:
```
$ sudo apt-get install libusb-dev
```
Now you can install the package with
```
go get -d -u gobot.io/x/gobot/v2/...
```sh
sudo apt-get install libusb-dev
```
## How to Use
@ -36,30 +35,30 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/digispark"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/digispark"
)
func main() {
digisparkAdaptor := digispark.NewAdaptor()
led := gpio.NewLedDriver(digisparkAdaptor, "0")
digisparkAdaptor := digispark.NewAdaptor()
led := gpio.NewLedDriver(digisparkAdaptor, "0")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{digisparkAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{digisparkAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -75,26 +74,26 @@ Download and install Gort, and then use the following commands:
Then, install the needed Digispark firmware.
```
```sh
gort digispark install
```
### OSX
### Connect on OSX
**Important**: 2012 MBP The USB ports on the 2012 MBPs (Retina and non) cause issues due to their USB3 controllers,
currently the best work around is to use a cheap USB hub (non USB3).
Plug the Digispark into your computer via the USB port and run:
```
```sh
gort digispark upload littlewire
```
### Ubuntu
### Connect on Ubuntu
Ubuntu requires an extra one-time step to set up the Digispark for communication with Gobot. Run the following command:
```
```sh
gort digispark set-udev-rules
```
@ -102,18 +101,18 @@ You might need to enter your administrative password. This steps adds a udev rul
Once this is done, you can upload Little Wire to your Digispark:
```
```sh
gort digispark upload littlewire
```
### Windows
### Connect on Windows
We need instructions here, because it supposedly works.
### Manual instructions
For manual instructions on how to install Little Wire on a Digispark check out http://digistump.com/board/index.php/topic,160.0.html
For manual instructions on how to install Little Wire on a Digispark check out <http://digistump.com/board/index.php/topic,160.0.html>
Thanks to [@bluebie](https://github.com/Bluebie) for these instructions! (https://github.com/Bluebie/micronucleus-t85/wiki/Ubuntu-Linux)
Thanks to [@bluebie](https://github.com/Bluebie) for these instructions! (<https://github.com/Bluebie/micronucleus-t85/wiki/Ubuntu-Linux>)
Now plug the Digispark into your computer via the USB port.

View File

@ -6,7 +6,7 @@ Installing:
This package requires installing `libusb`.
Then you can install the package with:
go get -u -d gobot.io/x/gobot/v2/platforms/digispark
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -6,9 +6,7 @@ For more information on this drone, go to: [https://www.ryzerobotics.com/tello](
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -22,31 +20,31 @@ Here is a sample of how you initialize and use the driver:
package main
import (
"fmt"
"time"
"fmt"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/dji/tello"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/dji/tello"
)
func main() {
drone := tello.NewDriver("8888")
drone := tello.NewDriver("8888")
work := func() {
drone.TakeOff()
work := func() {
drone.TakeOff()
gobot.After(5*time.Second, func() {
drone.Land()
})
}
gobot.After(5*time.Second, func() {
drone.Land()
})
}
robot := gobot.NewRobot("tello",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot := gobot.NewRobot("tello",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot.Start()
robot.Start()
}
```
@ -62,10 +60,13 @@ drone := tello.NewDriverWithIP("192.168.10.1", "8888")
This driver could not exist without the awesome members of the unofficial Tello forum:
https://tellopilots.com/forums/tello-development.8/
<https://tellopilots.com/forums/tello-development.8/>
Special thanks to [@Kragrathea](https://github.com/Kragrathea) who figured out a LOT of the packets and code as implemented in C#: [https://github.com/Kragrathea/TelloPC](https://github.com/Kragrathea/TelloPC)
Special thanks to [@Kragrathea](https://github.com/Kragrathea) who figured out a LOT of the packets and code as implemented
in C#: [https://github.com/Kragrathea/TelloPC](https://github.com/Kragrathea/TelloPC)
Also thanks to [@microlinux](https://github.com/microlinux) with the Python library which served as the first example for the Tello community: [https://github.com/microlinux/tello](https://github.com/microlinux/tello)
Also thanks to [@microlinux](https://github.com/microlinux) with the Python library which served as the first example for
the Tello community: [https://github.com/microlinux/tello](https://github.com/microlinux/tello)
Thank you to bluejune for the [https://bitbucket.org/PingguSoft/pytello](https://bitbucket.org/PingguSoft/pytello) repo, especially the Wireshark Lua dissector which has proven indispensable.
Thank you to bluejune for the [https://bitbucket.org/PingguSoft/pytello](https://bitbucket.org/PingguSoft/pytello) repo,
especially the Wireshark Lua dissector which has proven indispensable.

View File

@ -1,16 +1,18 @@
# DragonBoard™ 410c
The [DragonBoard 410c](http://www.96boards.org/product/dragonboard410c/), a product of Arrow Electronics, is the development board based on the mid-tier Qualcomm® Snapdragon™ 410E processor. It features advanced processing power, Wi-Fi, Bluetooth connectivity, and GPS, all packed into a board the size of a credit card.
The [DragonBoard 410c](http://www.96boards.org/product/dragonboard410c/), a product of Arrow Electronics, is the development
board based on the mid-tier Qualcomm® Snapdragon™ 410E processor. It features advanced processing power, Wi-Fi, Bluetooth
connectivity, and GPS, all packed into a board the size of a credit card.
## How to Install
Make sure you are using the latest Linaro Debian image. Both AArch32 and AArch64 work™ though you should stick to 64bit as OS internals may be different and aren't tested.
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your DragonBoard and run the program on the DragonBoard itself as documented here.
Make sure you are using the latest Linaro Debian image. Both AArch32 and AArch64 work™ though you should stick to 64bit
as OS internals may be different and aren't tested.
```
go get -d -u gobot.io/x/gobot/v2/...
```
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation,
transfer the final executable to your DragonBoard and run the program on the DragonBoard itself as documented here.
## How to Use
@ -57,13 +59,14 @@ func main() {
Compile your Gobot program on your workstation like this:
```bash
$ GOARCH=arm64 GOOS=linux go build examples/dragon_button.go
```sh
GOARCH=arm64 GOOS=linux go build examples/dragon_button.go
```
Once you have compiled your code, you can you can upload your program and execute it on the DragonBoard from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the DragonBoard from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp dragon_button root@192.168.1.xx:
$ ssh -t root@192.168.1.xx "./dragon_button"
```sh
scp dragon_button root@192.168.1.xx:
ssh -t root@192.168.1.xx "./dragon_button"
```

View File

@ -1,22 +1,25 @@
# Firmata
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists and anyone interested in creating interactive objects or environments.
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's
intended for artists, designers, hobbyists and anyone interested in creating interactive objects or environments.
This package provides the adaptor for microcontrollers such as Arduino that support the [Firmata](https://github.com/firmata/protocol) protocol
This package provides the adaptor for microcontrollers such as Arduino that support the [Firmata](https://github.com/firmata/protocol)
protocol.
You can connect to the microcontroller using either a serial connection, or a TCP connection to a WiFi-connected microcontroller such as the ESP8266.
You can connect to the microcontroller using either a serial connection, or a TCP connection to a WiFi-connected
microcontroller such as the ESP8266.
For more info about the Arduino platform, go to [http://arduino.cc/](http://arduino.cc/).
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You must install Firmata on your microcontroller before you can connect to it using Gobot. You can do this in many cases using Gort ([http://gort.io](http://gort.io)).
You must install Firmata on your microcontroller before you can connect to it using Gobot. You can do this in many cases
using Gort ([http://gort.io](http://gort.io)).
In order to use a TCP connection with a WiFi-enbaled microcontroller, you must install WifiFirmata on the microcontroller. You can use the Arduino IDE to do this.
In order to use a TCP connection with a WiFi-enbaled microcontroller, you must install WifiFirmata on the microcontroller.
You can use the Arduino IDE to do this.
## How to Use
@ -26,30 +29,30 @@ With a serial connection:
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
)
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -59,41 +62,42 @@ With a TCP connection, use the `NewTCPAdaptor`:
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
)
func main() {
firmataAdaptor := firmata.NewTCPAdaptor("192.168.0.66:3030")
led := gpio.NewLedDriver(firmataAdaptor, "2")
firmataAdaptor := firmata.NewTCPAdaptor("192.168.0.66:3030")
led := gpio.NewLedDriver(firmataAdaptor, "2")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
**Important** note that analog pins A4 and A5 are normally used by the Firmata I2C interface, so you will not be able to use them as analog inputs without changing the Firmata sketch.
**Important** note that analog pins A4 and A5 are normally used by the Firmata I2C interface, so you will not be able to
use them as analog inputs without changing the Firmata sketch.
## How to Connect
### Upload the Firmata Firmware to the Arduino
This section assumes you're using an Arduino Uno or another compatible board. If you already have the Firmata sketch installed, you can skip straight to the examples.
This section assumes you're using an Arduino Uno or another compatible board. If you already have the Firmata sketch installed,
you can skip straight to the examples.
### OS X
@ -101,22 +105,24 @@ First plug the Arduino into your computer via the USB/serial port.
A dialog box will appear telling you that a new network interface has been detected.
Click "Network Preferences...", and when it opens, simply click "Apply".
Once plugged in, use [Gort](http://gort.io)'s `gort scan serial` command to find out your connection info and serial port address:
Once plugged in, use [Gort](http://gort.io)'s `gort scan serial` command to find out your connection info and serial port
address:
```
$ gort scan serial
```sh
gort scan serial
```
Use the `gort arduino install` command to install `avrdude`, this will allow you to upload firmata to the arduino:
```
$ gort arduino install
```sh
gort arduino install
```
Once the avrdude uploader is installed we upload the firmata protocol to the arduino, use the arduino serial port address found when you ran `gort scan serial`:
Once the avrdude uploader is installed we upload the firmata protocol to the arduino, use the arduino serial port address
found when you ran `gort scan serial`:
```
$ gort arduino upload firmata /dev/tty.usbmodem1421
```sh
gort arduino upload firmata /dev/tty.usbmodem1421
```
Now you are ready to connect and communicate with the Arduino using serial port connection
@ -127,48 +133,55 @@ Note that Gobot works best with the `tty.` version of the serial port as shown a
First plug the Arduino into your computer via the USB/serial port.
Once plugged in, use [Gort](http://gort.io)'s `gort scan serial` command to find out your connection info and serial port address:
Once plugged in, use [Gort](http://gort.io)'s `gort scan serial` command to find out your connection info and serial port
address:
```
$ gort scan serial
```sh
gort scan serial
```
Use the `gort arduino install` command to install `avrdude`, this will allow you to upload firmata to the arduino:
```
$ gort arduino install
```sh
gort arduino install
```
Once the avrdude uploader is installed we upload the firmata protocol to the arduino, use the arduino serial port address found when you ran `gort scan serial`, or leave it blank to use the default address `ttyACM0`:
Once the avrdude uploader is installed we upload the firmata protocol to the arduino, use the arduino serial port address
found when you ran `gort scan serial`, or leave it blank to use the default address `ttyACM0`:
```
$ gort arduino upload firmata /dev/ttyACM0
```sh
gort arduino upload firmata /dev/ttyACM0
```
Now you are ready to connect and communicate with the Arduino using serial port connection
### Windows
First download and install gort for your OS from the [gort.io](gort.io) [downloads page](http://gort.io/documentation/getting_started/downloads/) and install it.
First download and install gort for your OS from the [gort.io](gort.io) [downloads page](http://gort.io/documentation/getting_started/downloads/)
and install it.
Open a command prompt window by right clicking on the start button and choose `Command Prompt (Admin)` (on windows 8.1). Then navigate to the folder where you uncompressed gort (uncomress to a folder first if you haven't done this yet).
Open a command prompt window by right clicking on the start button and choose `Command Prompt (Admin)` (on windows 8.1).
Then navigate to the folder where you uncompressed gort (uncomress to a folder first if you haven't done this yet).
Once inside the gort folder, first install avrdude which we'll use to upload firmata to the arduino.
```
$ gort arduino install
```cmd
gort arduino install
```
When the installation is complete, close the command prompt window and open a new one. We need to do this for the env variables to reload.
When the installation is complete, close the command prompt window and open a new one. We need to do this for the env variables
to reload.
```
$ gort scan serial
```cmd
gort scan serial
```
Take note of your arduinos serialport address (COM1 | COM2 | COM3| etc). You need to already have installed the arduino drivers from [arduino.cc/en/Main/Software](https://www.arduino.cc/en/Main/Software). Finally upload the firmata protocol sketch to the arduino.
Take note of your arduinos serialport address (COM1 | COM2 | COM3| etc). You need to already have installed the arduino
drivers from [arduino.cc/en/Main/Software](https://www.arduino.cc/en/Main/Software). Finally upload the firmata protocol
sketch to the arduino.
```
$ gort arduino upload firmata <COMX>
```cmd
gort arduino upload firmata <COMX>
```
Make sure to substitute `<COMX>` with the apropiate serialport address.
@ -182,13 +195,15 @@ for your arduino and click upload. Wait for the upload to finish and you should
with your arduino.
## Hardware Support
The following Firmata devices have been tested and are known to work:
- [Arduino Uno R3](http://arduino.cc/en/Main/arduinoBoardUno)
- [Arduino/Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101)
- [Teensy 3.0](http://www.pjrc.com/store/teensy3.html)
- [Arduino Uno R3](http://arduino.cc/en/Main/arduinoBoardUno)
- [Arduino/Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101)
- [Teensy 3.0](http://www.pjrc.com/store/teensy3.html)
The following WiFi devices have been tested and are known to work:
- [NodeMCU 1.0](http://nodemcu.com/index_en.html)
- [NodeMCU 1.0](http://nodemcu.com/index_en.html)
More devices are coming soon...

View File

@ -3,7 +3,7 @@ Package firmata provides the Gobot adaptor for microcontrollers that support the
Installing:
go get -d -u gobot.io/x/gobot/v2/... && go get gobot.io/x/gobot/v2/platforms/firmata
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -3,18 +3,18 @@
This package contains the Gobot driver for the Holystone HS200 drone.
For more information on this drone, go to:
http://www.holystone.com/product/Holy_Stone_HS200W_FPV_Drone_with_720P_HD_Live_Video_Wifi_Camera_2_4GHz_4CH_6_Axis_Gyro_RC_Quadcopter_with_Altitude_Hold,_Gravity_Sensor_and_Headless_Mode_Function_RTF,_Color_Red-39.html
<http://www.holystone.com/product/Holy_Stone_HS200W_FPV_Drone_with_720P_HD_Live_Video_Wifi_Camera_2_4GHz_4CH_6_Axis_Gyro_RC_Quadcopter_with_Altitude_Hold,_Gravity_Sensor_and_Headless_Mode_Function_RTF,_Color_Red-39.html>
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
- Connect to the drone's Wi-Fi network and identify the drone/gateway IP address.
- Use that IP address when you create a new driver.
- Some drones appear to use a different TCP port (8080 vs. 8888?). If the example doesn't work scan the drone for open ports or modify the driver not to use TCP.
- Some drones appear to use a different TCP port (8080 vs. 8888?). If the example doesn't work scan the drone for open
ports or modify the driver not to use TCP.
Here is a sample of how you initialize and use the driver:
@ -22,45 +22,49 @@ Here is a sample of how you initialize and use the driver:
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/holystone/hs200"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/holystone/hs200"
)
func main() {
drone := hs200.NewDriver("172.16.10.1:8888", "172.16.10.1:8080")
drone := hs200.NewDriver("172.16.10.1:8888", "172.16.10.1:8080")
work := func() {
drone.TakeOff()
work := func() {
drone.TakeOff()
gobot.After(5*time.Second, func() {
drone.Land()
})
}
gobot.After(5*time.Second, func() {
drone.Land()
})
}
robot := gobot.NewRobot("hs200",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot := gobot.NewRobot("hs200",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot.Start()
robot.Start()
}
```
## References
https://hackaday.io/project/19356/logs
https://github.com/lancecaraccioli/holystone-hs110w
<https://hackaday.io/project/19356/logs>
<https://github.com/lancecaraccioli/holystone-hs110w>
## Random notes
- The hs200 sends out an RTSP video feed from its own board camera. Not clear how this is turned on. The data is apparently streamed over UDP. (Reference mentions rtsp://192.168.0.1/0 in VLC, I didn't try it!)
- The hs200 sends out an RTSP video feed from its own board camera. Not clear how this is turned on. The data is
apparently streamed over UDP. (Reference mentions rtsp://192.168.0.1/0 in VLC, I didn't try it!)
- The Android control app seems to be sending out the following TCP bytes for an unknown purpose:
`00 01 02 03 04 05 06 07 08 09 25 25` but the drone flies without a TCP connection.
`00 01 02 03 04 05 06 07 08 09 25 25` but the drone flies without a TCP connection.
- The drone apparently always replies "noact\r\n" over TCP.
- The app occasionally sends out 29 bytes long UDP packets besides the 11 byte control packet for an unknown purpose:
`26 e1 07 00 00 07 00 00 00 10 00 00 00 00 00 00 00 14 00 00 00 0e 00 00 00 03 00 00 00`
`26 e1 07 00 00 07 00 00 00 10 00 00 00 00 00 00 00 14 00 00 00 0e 00 00 00 03 00 00 00`
- The doesn't seem to be any telemetry coming out of the drone besides the video feed.
- The drone can sometimes be a little flaky. Ensure you've got a fully charged battery, minimal Wi-Fi interference, various connectors on the drone all well seated.
- The drone can sometimes be a little flaky. Ensure you've got a fully charged battery, minimal Wi-Fi interference,
various connectors on the drone all well seated.
- It's not clear whether the drone's remote uses Wi-Fi or not, possibly Wi-Fi is only for the mobile app.

View File

@ -1,18 +1,20 @@
# Curie
The Intel Curie is a tiny computer for the Internet of Things. It is the processor used by the [Arduino/Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101) and the [Intel TinyTILE](https://software.intel.com/en-us/node/675623).
The Intel Curie is a tiny computer for the Internet of Things. It is the processor used by the [Arduino/Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101)
and the [Intel TinyTILE](https://software.intel.com/en-us/node/675623).
In addition to the GPIO, ADC, and I2C hardware interfaces, the Curie also has a built-in Inertial Measurement Unit (IMU), including an accelerometer, gyroscope, and thermometer.
In addition to the GPIO, ADC, and I2C hardware interfaces, the Curie also has a built-in Inertial Measurement Unit (IMU),
including an accelerometer, gyroscope, and thermometer.
For more info about the Intel Curie platform go to: [https://www.intel.com/content/www/us/en/products/boards-kits/curie.html](https://www.intel.com/content/www/us/en/products/boards-kits/curie.html).
## How to Install
You would normally install Go and Gobot on your computer. When you execute the Gobot program code, it communicates with the connected microcontroller using the [Firmata protocol](https://github.com/firmata/protocol), either using a serial port, or the Bluetooth LE wireless interface.
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
```
go get -d -u gobot.io/x/gobot/v2/...
```
You would normally install Go and Gobot on your computer. When you execute the Gobot program code, it communicates with
the connected microcontroller using the [Firmata protocol](https://github.com/firmata/protocol), either using a serial
port, or the Bluetooth LE wireless interface.
## How To Use
@ -20,51 +22,51 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"log"
"time"
"log"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
"gobot.io/x/gobot/v2/platforms/intel-iot/curie"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
"gobot.io/x/gobot/v2/platforms/intel-iot/curie"
)
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
imu := curie.NewIMUDriver(firmataAdaptor)
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
imu := curie.NewIMUDriver(firmataAdaptor)
work := func() {
imu.On("Accelerometer", func(data interface{}) {
log.Println("Accelerometer", data)
})
work := func() {
imu.On("Accelerometer", func(data interface{}) {
log.Println("Accelerometer", data)
})
imu.On("Gyroscope", func(data interface{}) {
log.Println("Gyroscope", data)
})
imu.On("Gyroscope", func(data interface{}) {
log.Println("Gyroscope", data)
})
imu.On("Temperature", func(data interface{}) {
log.Println("Temperature", data)
})
imu.On("Temperature", func(data interface{}) {
log.Println("Temperature", data)
})
gobot.Every(1*time.Second, func() {
led.Toggle()
})
gobot.Every(1*time.Second, func() {
led.Toggle()
})
gobot.Every(100*time.Millisecond, func() {
imu.ReadAccelerometer()
imu.ReadGyroscope()
imu.ReadTemperature()
})
}
gobot.Every(100*time.Millisecond, func() {
imu.ReadAccelerometer()
imu.ReadGyroscope()
imu.ReadTemperature()
})
}
robot := gobot.NewRobot("curieBot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{imu, led},
work,
)
robot := gobot.NewRobot("curieBot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{imu, led},
work,
)
robot.Start()
robot.Start()
}
```
@ -77,29 +79,29 @@ You need to flash your Intel Curie with firmware that uses ConfigurableFirmata a
To setup your Arduino environment:
- Install the latest Arduino, if you have not done so yet.
- Install the "Intel Curie Boards" board files using the "Board Manager". You can find it in the Arduino IDE under the "Tools" menu. Choose "Boards > Boards Manager".
Search for the "Intel Curie Boards" package in the "Boards Manager" dialog, and then install the latest version.
- Download the ZIP file for the ConfigurableFirmata library. You can download the latest version of the ConfigurableFirmata from here:
[https://github.com/firmata/ConfigurableFirmata/archive/master.zip](https://github.com/firmata/ConfigurableFirmata/archive/master.zip)
Once you have downloaded ConfigurableFirmata, install it by using the "Library Manager". You can find it in the Arduino IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the ConfigurableFirmata library that you just downloaded.
- Install the "Intel Curie Boards" board files using the "Board Manager". You can find it in the Arduino IDE under the
"Tools" menu. Choose "Boards > Boards Manager".
- Search for the "Intel Curie Boards" package in the "Boards Manager" dialog, and then install the latest version.
- Download the ZIP file for the ConfigurableFirmata library. You can download the latest version of the ConfigurableFirmata
from here:
[https://github.com/firmata/ConfigurableFirmata/archive/master.zip](https://github.com/firmata/ConfigurableFirmata/archive/master.zip)
Once you have downloaded ConfigurableFirmata, install it by using the "Library Manager". You can find it in the Arduino
IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the ConfigurableFirmata
library that you just downloaded.
- Download the ZIP file for the FirmataCurieIMU library. You can download the latest version of FirmataCurieIMU from here:
[https://github.com/intel-iot-devkit/firmata-curie-imu/archive/master.zip](https://github.com/intel-iot-devkit/firmata-curie-imu/archive/master.zip)
Once you have downloaded the FirmataCurieIMU library, install it by using the "Library Manager". You can find it in the Arduino IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the FirmataCurieIMU library that you just downloaded.
- Linux only: On some Linux distributions, additional device rules are required in order to connect to the board. Run the following command then unplug the board and plug it back in before proceeding:
[https://github.com/intel-iot-devkit/firmata-curie-imu/archive/master.zip](https://github.com/intel-iot-devkit/firmata-curie-imu/archive/master.zip)
- Once you have downloaded the FirmataCurieIMU library, install it by using the "Library Manager". You can find it in the
Arduino IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the FirmataCurieIMU
library that you just downloaded.
- Linux only: On some Linux distributions, additional device rules are required in order to connect to the board. Run the
following command then unplug the board and plug it back in before proceeding:
```sh
curl -sL https://raw.githubusercontent.com/01org/corelibs-arduino101/master/scripts/create_dfu_udev_rule | sudo -E bash -
```
Now you are ready to install your firmware. You must decide if you want to connect via the serial port, or using Bluetooth LE.
Now you are ready to install your firmware. You must decide if you want to connect via the serial port, or using
Bluetooth LE.
### Serial Port
@ -107,7 +109,9 @@ To use your Intel Curie connected via serial port, you should use the sketch loc
[https://github.com/intel-iot-devkit/firmata-curie-imu/blob/master/examples/everythingIMU/everythingIMU.ino](https://github.com/intel-iot-devkit/firmata-curie-imu/blob/master/examples/everythingIMU/everythingIMU.ino)
Once you have loaded this sketch on your Intel Curie, you can run your Gobot code to communicate with it. Leave your Arduino 101 or TinyTILE connected using the serial cable that you used to flash the firmware, and refer to that same serial port name in your Gobot code.
Once you have loaded this sketch on your Intel Curie, you can run your Gobot code to communicate with it. Leave your
Arduino 101 or TinyTILE connected using the serial cable that you used to flash the firmware, and refer to that same serial
port name in your Gobot code.
### Bluetooth LE
@ -117,4 +121,5 @@ To use your Intel Curie connected via Bluetooth LE, you should use the sketch lo
Once you have loaded this sketch on your Intel Curie, you can run your Gobot code to communicate with it.
Power up your Arduino 101 or TinyTILE using a battery or other power source, and connect using the BLE address or name. The default BLE name is "FIRMATA".
Power up your Arduino 101 or TinyTILE using a battery or other power source, and connect using the BLE address or name.
The default BLE name is "FIRMATA".

View File

@ -1,40 +1,39 @@
# Edison
The Intel Edison is a WiFi and Bluetooth enabled development platform for the Internet of Things. It packs a robust set of features into its small size and supports a broad spectrum of I/O and software support.
The Intel Edison is a WiFi and Bluetooth enabled development platform for the Internet of Things. It packs a robust set
of features into its small size and supports a broad spectrum of I/O and software support.
For more info about the Edison platform click [here](http://www.intel.com/content/www/us/en/do-it-yourself/edison.html).
## How to Install
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your Intel Edison, and run the program on the Intel Edison itself as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
### Setting up your Intel Edison
Everything you need to get started with the Edison is in the Intel Getting Started Guide:
https://software.intel.com/en-us/iot/library/edison-getting-started
<https://software.intel.com/en-us/iot/library/edison-getting-started>
Don't forget to configure your Edison's wifi connection and flash your Edison with the latest firmware image!
The recommended way to connect to your device is via wifi, for that follow the directions here:
https://software.intel.com/en-us/connecting-your-intel-edison-board-using-wifi
<https://software.intel.com/en-us/connecting-your-intel-edison-board-using-wifi>
If you don't have a wifi network available, the Intel documentation explains how to use another connection type, but note that this guide assumes you are using wifi connection.
If you don't have a wifi network available, the Intel documentation explains how to use another connection type, but note
that this guide assumes you are using wifi connection.
You can obtain the IP address of your Edison, by running the floowing command:
```
```sh
ip addr show | grep inet
```
Don't forget to setup the a password for the device otherwise you won't be able to connect using SSH. From within the screen session, run the following command:
Don't forget to setup the a password for the device otherwise you won't be able to connect using SSH. From within the screen
session, run the following command:
```
```ah
configure_edison --password
```
@ -43,38 +42,36 @@ later on you aren't able to scp to the device, try to reset the
password. This password will obviously be needed next time you connect to
your device.
## How To Use
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/edison"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/edison"
)
func main() {
e := edison.NewAdaptor()
led := gpio.NewLedDriver(e, "13")
e := edison.NewAdaptor()
led := gpio.NewLedDriver(e, "13")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -86,15 +83,16 @@ You can read the [full API documentation online](http://godoc.org/gobot.io/x/gob
Compile your Gobot program on your workstation like this:
```bash
$ GOARCH=386 GOOS=linux go build examples/edison_blink.go
```sh
GOARCH=386 GOOS=linux go build examples/edison_blink.go
```
Once you have compiled your code, you can you can upload your program and execute it on the Intel Edison from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the Intel Edison from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp edison_blink root@<IP of your device>:/home/root/
$ ssh -t root@<IP of your device> "./edison_blink"
```sh
scp edison_blink root@<IP of your device>:/home/root/
ssh -t root@<IP of your device> "./edison_blink"
```
At this point you should see one of the onboard LEDs blinking. Press control + c

View File

@ -4,55 +4,51 @@ The Intel Joule is a WiFi and Bluetooth enabled development platform for the Int
For more info about the Intel Joule platform go to:
http://www.intel.com/joule
<http://www.intel.com/joule>
## How to Install
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your Intel Joule, and run the program on the Intel Joule itself as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
### Setting up your Intel Joule
Everything you need to get started with the Joule is in the Intel Getting Started Guide located at:
https://intel.com/joule/getstarted
<https://intel.com/joule/getstarted>
Don't forget to configure your Joule's WiFi connection and update your Joule to the latest firmware image. Gobot has been tested using the reference OS based on Ostro.
Don't forget to configure your Joule's WiFi connection and update your Joule to the latest firmware image. Gobot has been
tested using the reference OS based on Ostro.
## How To Use
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/joule"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/intel-iot/joule"
)
func main() {
e := joule.NewAdaptor()
led := gpio.NewLedDriver(e, "GP103")
e := joule.NewAdaptor()
led := gpio.NewLedDriver(e, "GP103")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -64,15 +60,16 @@ You can read the [full API documentation online](http://godoc.org/gobot.io/x/gob
Compile your Gobot program on your workstation like this:
```bash
$ GOARCH=386 GOOS=linux go build joule_blink.go
```sh
GOARCH=386 GOOS=linux go build joule_blink.go
```
Once you have compiled your code, you can you can upload your program and execute it on the Intel Joule from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the Intel Joule from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp joule_blink root@<IP of your device>:/home/root/
$ ssh -t root@<IP of your device> "./joule_blink"
```sh
scp joule_blink root@<IP of your device>:/home/root/
ssh -t root@<IP of your device> "./joule_blink"
```
At this point you should see one of the onboard LEDs blinking. Press control + c
@ -85,8 +82,10 @@ over once again and start it from the command line (via screen).
The Gobot pin mapping for the Intel Joule uses a naming system based on how the pins are labeled on the board itself.
There are 2 jumpers on the Joule expansion board, labeled "J12" and "J13". There are 2 rows of pins on each jumper, labeled from 1 to 40. So to use the 26th pin of jumper J12, you use pin name "J12_26".
There are 2 jumpers on the Joule expansion board, labeled "J12" and "J13". There are 2 rows of pins on each jumper, labeled
from 1 to 40. So to use the 26th pin of jumper J12, you use pin name "J12_26".
In addition, there are pins that control the build-in LEDs (pins GP100 thru GP103) as used in the example above.
The i2c interfaces on the Intel Joule developer kit board require that you terminate the SDA & SCL lines using 2 10K resistors pulled up to the voltage used for the i2c device, for example 5V.
The i2c interfaces on the Intel Joule developer kit board require that you terminate the SDA & SCL lines using 2 10K resistors
pulled up to the voltage used for the i2c device, for example 5V.

View File

@ -8,13 +8,10 @@ For more info about the Jetson Nano platform, click [here](https://developer.nvi
## How to Install
We recommend updating to the latest jetson-nano OS when using the Jetson Nano, however Gobot should also support older versions of the OS, should your application require this.
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your Jetson Nano, and run the program on the Jetson Nano as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
We recommend updating to the latest jetson-nano OS when using the Jetson Nano, however Gobot should also support older
versions of the OS, should your application require this.
## How to Use
@ -24,30 +21,30 @@ The pin numbering used by your Gobot program should match the way your board is
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/jetson"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/jetson"
)
func main() {
r := jetson.NewAdaptor()
led := gpio.NewLedDriver(r, "40")
r := jetson.NewAdaptor()
led := gpio.NewLedDriver(r, "40")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -56,9 +53,10 @@ func main() {
### Compiling
Once you have compiled your code, you can upload your program and execute it on the Jetson Nano from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can upload your program and execute it on the Jetson Nano from your workstation using
the `scp` and `ssh` commands like this:
```bash
$ scp jetson-nano_blink jn@192.168.1.xxx:/home/jn/
$ ssh -t jn@192.168.1.xxx "./jetson-nano_blink"
```sh
scp jetson-nano_blink jn@192.168.1.xxx:/home/jn/
ssh -t jn@192.168.1.xxx "./jetson-nano_blink"
```

View File

@ -3,6 +3,7 @@
You can use Gobot with any USB joystick or game controller that is compatible with [Simple DirectMedia Layer](http://www.libsdl.org/).
Current configurations included:
- Dualshock3 game controller
- Dualshock4 game controller
- Dualsense game controller
@ -19,35 +20,31 @@ This package requires `sdl2` to be installed on your system
To install `sdl2` on macOS using Homebrew:
```
$ brew install sdl2
```sh
brew install sdl2
```
To use an XBox360 controller on macOS, you will most likely need to install additional software such as [https://github.com/360Controller/360Controller](https://github.com/360Controller/360Controller).
### Linux (Ubuntu and Raspbian)
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You must be running a Linux kernel that is v4.14+ in order for the various controller mappings to work as expected.
Then you must install the latest SDL2 v2.0.8 or greater:
```
```sh
wget https://www.libsdl.org/release/SDL2-2.0.8.tar.gz
tar -zxvf SDL2-2.0.8.tar.gz
cd SDL2-2.0.8/
./configure && make && sudo make install
```
Now you can install the package with
```
go get -d -u gobot.io/x/gobot/v2/...
```
## How to Use
Controller configurations are stored in Gobot it, but you can also use external file in JSON format. Take a look at the `configs` directory for examples.
Controller configurations are stored in Gobot it, but you can also use external file in JSON format. Take a look at the
`configs` directory for examples.
## How to Connect
@ -63,100 +60,101 @@ This small program receives joystick and button press events from an PlayStation
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/joystick"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/joystick"
)
func main() {
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "dualshock3",
)
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "dualshock3",
)
work := func() {
// buttons
stick.On(joystick.SquarePress, func(data interface{}) {
fmt.Println("square_press")
})
stick.On(joystick.SquareRelease, func(data interface{}) {
fmt.Println("square_release")
})
stick.On(joystick.TrianglePress, func(data interface{}) {
fmt.Println("triangle_press")
})
stick.On(joystick.TriangleRelease, func(data interface{}) {
fmt.Println("triangle_release")
})
stick.On(joystick.CirclePress, func(data interface{}) {
fmt.Println("circle_press")
})
stick.On(joystick.CircleRelease, func(data interface{}) {
fmt.Println("circle_release")
})
stick.On(joystick.XPress, func(data interface{}) {
fmt.Println("x_press")
})
stick.On(joystick.XRelease, func(data interface{}) {
fmt.Println("x_release")
})
stick.On(joystick.StartPress, func(data interface{}) {
fmt.Println("start_press")
})
stick.On(joystick.StartRelease, func(data interface{}) {
fmt.Println("start_release")
})
stick.On(joystick.SelectPress, func(data interface{}) {
fmt.Println("select_press")
})
stick.On(joystick.SelectRelease, func(data interface{}) {
fmt.Println("select_release")
})
work := func() {
// buttons
stick.On(joystick.SquarePress, func(data interface{}) {
fmt.Println("square_press")
})
stick.On(joystick.SquareRelease, func(data interface{}) {
fmt.Println("square_release")
})
stick.On(joystick.TrianglePress, func(data interface{}) {
fmt.Println("triangle_press")
})
stick.On(joystick.TriangleRelease, func(data interface{}) {
fmt.Println("triangle_release")
})
stick.On(joystick.CirclePress, func(data interface{}) {
fmt.Println("circle_press")
})
stick.On(joystick.CircleRelease, func(data interface{}) {
fmt.Println("circle_release")
})
stick.On(joystick.XPress, func(data interface{}) {
fmt.Println("x_press")
})
stick.On(joystick.XRelease, func(data interface{}) {
fmt.Println("x_release")
})
stick.On(joystick.StartPress, func(data interface{}) {
fmt.Println("start_press")
})
stick.On(joystick.StartRelease, func(data interface{}) {
fmt.Println("start_release")
})
stick.On(joystick.SelectPress, func(data interface{}) {
fmt.Println("select_press")
})
stick.On(joystick.SelectRelease, func(data interface{}) {
fmt.Println("select_release")
})
// joysticks
stick.On(joystick.LeftX, func(data interface{}) {
fmt.Println("left_x", data)
})
stick.On(joystick.LeftY, func(data interface{}) {
fmt.Println("left_y", data)
})
stick.On(joystick.RightX, func(data interface{}) {
fmt.Println("right_x", data)
})
stick.On(joystick.RightY, func(data interface{}) {
fmt.Println("right_y", data)
})
// joysticks
stick.On(joystick.LeftX, func(data interface{}) {
fmt.Println("left_x", data)
})
stick.On(joystick.LeftY, func(data interface{}) {
fmt.Println("left_y", data)
})
stick.On(joystick.RightX, func(data interface{}) {
fmt.Println("right_x", data)
})
stick.On(joystick.RightY, func(data interface{}) {
fmt.Println("right_y", data)
})
// triggers
stick.On(joystick.R1Press, func(data interface{}) {
fmt.Println("R1Press", data)
})
stick.On(joystick.R2Press, func(data interface{}) {
fmt.Println("R2Press", data)
})
stick.On(joystick.L1Press, func(data interface{}) {
fmt.Println("L1Press", data)
})
stick.On(joystick.L2Press, func(data interface{}) {
fmt.Println("L2Press", data)
})
}
// triggers
stick.On(joystick.R1Press, func(data interface{}) {
fmt.Println("R1Press", data)
})
stick.On(joystick.R2Press, func(data interface{}) {
fmt.Println("R2Press", data)
})
stick.On(joystick.L1Press, func(data interface{}) {
fmt.Println("L1Press", data)
})
stick.On(joystick.L2Press, func(data interface{}) {
fmt.Println("L2Press", data)
})
}
robot := gobot.NewRobot("joystickBot",
[]gobot.Connection{joystickAdaptor},
[]gobot.Device{stick},
work,
)
robot := gobot.NewRobot("joystickBot",
[]gobot.Connection{joystickAdaptor},
[]gobot.Device{stick},
work,
)
robot.Start()
robot.Start()
}
```
## How to Add A New Joystick
In the `bin` directory for this package is a CLI utility program that scans for SDL joystick events, and displays the ID and value:
In the `bin` directory for this package is a CLI utility program that scans for SDL joystick events, and displays the ID
and value:
```
```sh
$ go run ./platforms/joystick/bin/scanner.go
Joystick 0 connected
[6625 ms] Axis: 1 value:-22686
@ -172,4 +170,6 @@ Joystick 0 connected
[10345 ms] Axis: 0 value:0
```
You can use the output from this program to create a JSON file for the various buttons and axes on your joystick/gamepad. You could also create a file similar to `joystick_dualshock3.go` and submit a pull request with the new configuration so others can use it as well.
You can use the output from this program to create a JSON file for the various buttons and axes on your joystick/gamepad.
You could also create a file similar to `joystick_dualshock3.go` and submit a pull request with the new configuration so
others can use it as well.

View File

@ -3,10 +3,9 @@ Package joystick provides the Gobot adaptor and drivers for game controllers tha
Installing:
This package requires `sdl2` to be installed on your system
Then install package with:
This package requires `sdl2` to be installed on your system
go get gobot.io/x/gobot/v2/platforms/joystick
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -4,9 +4,7 @@ This module implements support for keyboard events, wrapping the `stty` utility.
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -16,33 +14,33 @@ Example parsing key events
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/keyboard"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/keyboard"
)
func main() {
keys := keyboard.NewDriver()
keys := keyboard.NewDriver()
work := func() {
keys.On(keyboard.Key, func(data interface{}) {
key := data.(keyboard.KeyEvent)
work := func() {
keys.On(keyboard.Key, func(data interface{}) {
key := data.(keyboard.KeyEvent)
if key.Key == keyboard.A {
fmt.Println("A pressed!")
} else {
fmt.Println("keyboard event!", key, key.Char)
}
})
}
if key.Key == keyboard.A {
fmt.Println("A pressed!")
} else {
fmt.Println("keyboard event!", key, key.Char)
}
})
}
robot := gobot.NewRobot("keyboardbot",
[]gobot.Connection{},
[]gobot.Device{keys},
work,
)
robot := gobot.NewRobot("keyboardbot",
[]gobot.Connection{},
[]gobot.Device{keys},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -5,7 +5,7 @@ Installing:
Then you can install the package with:
go get gobot.io/x/gobot/v2 && go install gobot.io/x/gobot/v2/platforms/keyboard
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,48 +1,45 @@
# Leap
The Leap Motion is a user-interface device that tracks the user's hand motions, and translates them into events that can control robots and physical computing hardware.
The Leap Motion is a user-interface device that tracks the user's hand motions, and translates them into events that can
control robots and physical computing hardware.
For more info about the Leap Motion platform click [Leap Motion](https://www.leapmotion.com/)
## How to Install
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
First install the [Leap Motion Software](https://www.leapmotion.com/setup)
Now you can install the package with:
```
go get -d -u gobot.io/x/gobot/v2/...
```
## How to Use
```go
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/leap"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/leap"
)
func main() {
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
l := leap.NewDriver(leapMotionAdaptor)
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
l := leap.NewDriver(leapMotionAdaptor)
work := func() {
l.On(l.Event("message"), func(data interface{}) {
fmt.Println(data.(leap.Frame))
})
}
work := func() {
l.On(l.Event("message"), func(data interface{}) {
fmt.Println(data.(leap.Frame))
})
}
robot := gobot.NewRobot("leapBot",
[]gobot.Connection{leapMotionAdaptor},
[]gobot.Device{l},
work,
)
robot := gobot.NewRobot("leapBot",
[]gobot.Connection{leapMotionAdaptor},
[]gobot.Device{l},
work,
)
robot.Start()
robot.Start()
}
```
@ -54,16 +51,17 @@ This driver works out of the box with the vanilla installation of the Leap Motio
The main steps are:
* Run Leap Motion.app to open a websocket connection in port 6437.
* Connect your Computer and Leap Motion Controller.
* Connect to the device via Gobot.
* Run Leap Motion.app to open a websocket connection in port 6437.
* Connect your Computer and Leap Motion Controller.
* Connect to the device via Gobot.
### Ubuntu
The Linux download of the Leap Motion software can be obtained from [Leap Motion Dev Center](https://developer.leapmotion.com/downloads) (requires free signup)
The Linux download of the Leap Motion software can be obtained from [Leap Motion Dev Center](https://developer.leapmotion.com/downloads)
(requires free signup).
The main steps are:
* Run the leapd daemon, to open a websocket connection in port 6437.
* Connect your computer and the Leap Motion controller
* Connect to the device via Gobot
* Run the leapd daemon, to open a websocket connection in port 6437.
* Connect your computer and the Leap Motion controller
* Connect to the device via Gobot

View File

@ -3,10 +3,9 @@ Package leap provides the Gobot adaptor and driver for the Leap Motion.
Installing:
* First install the [Leap Motion Software](https://www.leapmotion.com/setup).
* Then install the package:
go get gobot.io/x/gobot/v2/platforms/leap
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Install the [Leap Motion Software](https://www.leapmotion.com/setup).
Example:

View File

@ -16,10 +16,7 @@ configured to send version 1.0 frames.
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -27,63 +24,63 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/mavlink"
common "gobot.io/x/gobot/v2/platforms/mavlink/common"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/mavlink"
common "gobot.io/x/gobot/v2/platforms/mavlink/common"
)
func main() {
adaptor := mavlink.NewAdaptor("/dev/ttyACM0")
iris := mavlink.NewDriver(adaptor)
adaptor := mavlink.NewAdaptor("/dev/ttyACM0")
iris := mavlink.NewDriver(adaptor)
work := func() {
iris.Once(iris.Event("packet"), func(data interface{}) {
packet := data.(*common.MAVLinkPacket)
work := func() {
iris.Once(iris.Event("packet"), func(data interface{}) {
packet := data.(*common.MAVLinkPacket)
dataStream := common.NewRequestDataStream(100,
packet.SystemID,
packet.ComponentID,
4,
1,
)
iris.SendPacket(common.CraftMAVLinkPacket(packet.SystemID,
packet.ComponentID,
dataStream,
))
})
dataStream := common.NewRequestDataStream(100,
packet.SystemID,
packet.ComponentID,
4,
1,
)
iris.SendPacket(common.CraftMAVLinkPacket(packet.SystemID,
packet.ComponentID,
dataStream,
))
})
iris.On(iris.Event("message"), func(data interface{}) {
if data.(common.MAVLinkMessage).Id() == 30 {
message := data.(*common.Attitude)
fmt.Println("Attitude")
fmt.Println("TIME_BOOT_MS", message.TIME_BOOT_MS)
fmt.Println("ROLL", message.ROLL)
fmt.Println("PITCH", message.PITCH)
fmt.Println("YAW", message.YAW)
fmt.Println("ROLLSPEED", message.ROLLSPEED)
fmt.Println("PITCHSPEED", message.PITCHSPEED)
fmt.Println("YAWSPEED", message.YAWSPEED)
fmt.Println("")
}
})
}
iris.On(iris.Event("message"), func(data interface{}) {
if data.(common.MAVLinkMessage).Id() == 30 {
message := data.(*common.Attitude)
fmt.Println("Attitude")
fmt.Println("TIME_BOOT_MS", message.TIME_BOOT_MS)
fmt.Println("ROLL", message.ROLL)
fmt.Println("PITCH", message.PITCH)
fmt.Println("YAW", message.YAW)
fmt.Println("ROLLSPEED", message.ROLLSPEED)
fmt.Println("PITCHSPEED", message.PITCHSPEED)
fmt.Println("YAWSPEED", message.YAWSPEED)
fmt.Println("")
}
})
}
robot := gobot.NewRobot("mavBot",
[]gobot.Connection{adaptor},
[]gobot.Device{iris},
work,
)
robot := gobot.NewRobot("mavBot",
[]gobot.Connection{adaptor},
[]gobot.Device{iris},
work,
)
robot.Start()
robot.Start()
}
```
## How to use: UDP
``` go
adaptor := mavlink.NewUDPAdaptor(":14550")
adaptor := mavlink.NewUDPAdaptor(":14550")
```
To test, install Mavproxy and set it up to listen on serial and repeat

View File

@ -3,7 +3,7 @@ Package mavlink contains the Gobot adaptor and driver for the MAVlink Communicat
Installing:
go get gobot.io/x/gobot/v2/platforms/mavlink
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,14 +1,13 @@
# MegaPi
The [MegaPi](http://learn.makeblock.com/en/megapi/) is a motor controller by MakeBlock that is compatible with the Raspberry Pi.
The [MegaPi](http://learn.makeblock.com/en/megapi/) is a motor controller by MakeBlock that is compatible with the
Raspberry Pi.
The code is based on a python implementation that can be found [here](https://github.com/Makeblock-official/PythonForMegaPi).
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -16,36 +15,36 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/megapi"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/megapi"
"time"
)
func main() {
// use "/dev/ttyUSB0" if connecting with USB cable
// use "/dev/ttyAMA0" on devices older than Raspberry Pi 3 Model B
megaPiAdaptor := megapi.NewAdaptor("/dev/ttyS0")
motor := megapi.NewMotorDriver(megaPiAdaptor, 1)
// use "/dev/ttyUSB0" if connecting with USB cable
// use "/dev/ttyAMA0" on devices older than Raspberry Pi 3 Model B
megaPiAdaptor := megapi.NewAdaptor("/dev/ttyS0")
motor := megapi.NewMotorDriver(megaPiAdaptor, 1)
work := func() {
speed := int16(0)
fadeAmount := int16(30)
work := func() {
speed := int16(0)
fadeAmount := int16(30)
gobot.Every(100*time.Millisecond, func() {
motor.Speed(speed)
speed = speed + fadeAmount
if speed == 0 || speed == 300 {
fadeAmount = -fadeAmount
}
})
}
gobot.Every(100*time.Millisecond, func() {
motor.Speed(speed)
speed = speed + fadeAmount
if speed == 0 || speed == 300 {
fadeAmount = -fadeAmount
}
})
}
robot := gobot.NewRobot("megaPiBot",
[]gobot.Connection{megaPiAdaptor},
[]gobot.Device{motor},
work,
)
robot := gobot.NewRobot("megaPiBot",
[]gobot.Connection{megaPiAdaptor},
[]gobot.Device{motor},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -3,26 +3,28 @@
The [Microbit](http://microbit.org/) is a tiny computer with built-in Bluetooth LE aka Bluetooth 4.0.
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
You must install the Microbit firmware from [@sandeepmistry] located at [https://github.com/sandeepmistry/node-bbc-microbit](https://github.com/sandeepmistry/node-bbc-microbit) to use the Microbit with Gobot. This firmware is based on the micro:bit template, but with a few changes.
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You must install the Microbit firmware from [@sandeepmistry] located at [https://github.com/sandeepmistry/node-bbc-microbit](https://github.com/sandeepmistry/node-bbc-microbit)
to use the Microbit with Gobot. This firmware is based on the micro:bit template, but with a few changes.
If you have the [Gort](https://gort.io) command line tool installed, you can install the firmware using the following commands:
```
```sh
gort microbit download
gort microbit install /media/mysystem/MICROBIT
```
Substitute the proper location to your Microbit for `/media/mysystem/MICROBIT` in the previous command.
Once the firmware is installed, make sure your rotate your Microbit in a circle to calibrate the magnetometer before your try to connect to it using Gobot, or it will not respond.
Once the firmware is installed, make sure your rotate your Microbit in a circle to calibrate the magnetometer before your
try to connect to it using Gobot, or it will not respond.
You can also follow the firmware installation instructions at [https://github.com/sandeepmistry/node-bbc-microbit#flashing-microbit-firmware](https://github.com/sandeepmistry/node-bbc-microbit#flashing-microbit-firmware).
The source code for the firmware is located at [https://github.com/sandeepmistry/node-bbc-microbit-firmware](https://github.com/sandeepmistry/node-bbc-microbit-firmware) however you do not need this source code to install the firmware using the installation instructions.
The source code for the firmware is located at [https://github.com/sandeepmistry/node-bbc-microbit-firmware](https://github.com/sandeepmistry/node-bbc-microbit-firmware)
however you do not need this source code to install the firmware using the installation instructions.
## How to Use
@ -41,35 +43,35 @@ The following example uses the LEDDriver:
package main
import (
"os"
"time"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/microbit"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/microbit"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ubit := microbit.NewLEDDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ubit := microbit.NewLEDDriver(bleAdaptor)
work := func() {
ubit.Blank()
gobot.After(1*time.Second, func() {
ubit.WriteText("Hello")
})
gobot.After(7*time.Second, func() {
ubit.Smile()
})
}
work := func() {
ubit.Blank()
gobot.After(1*time.Second, func() {
ubit.WriteText("Hello")
})
gobot.After(7*time.Second, func() {
ubit.Smile()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ubit},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ubit},
work,
)
robot.Start()
robot.Start()
}
```
@ -83,37 +85,37 @@ This means you can use it with any gpio or aio Driver. In this example, we are u
package main
import (
"os"
"os"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/microbit"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/microbit"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ubit := microbit.NewIOPinDriver(bleAdaptor)
button := gpio.NewButtonDriver(ubit, "0")
led := gpio.NewLedDriver(ubit, "1")
ubit := microbit.NewIOPinDriver(bleAdaptor)
button := gpio.NewButtonDriver(ubit, "0")
led := gpio.NewLedDriver(ubit, "1")
work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
led.On()
})
button.On(gpio.ButtonRelease, func(data interface{}) {
led.Off()
})
}
work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
led.On()
})
button.On(gpio.ButtonRelease, func(data interface{}) {
led.Off()
})
}
robot := gobot.NewRobot("buttonBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ubit, button, led},
work,
)
robot := gobot.NewRobot("buttonBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ubit, button, led},
work,
)
robot.Start()
robot.Start()
}
```
@ -125,22 +127,26 @@ You need to know the BLE ID of the Microbit that you want to connect to.
### OSX
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID,
OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
For example:
For example: `go run examples/microbit_led.go "BBC micro:bit"`
go run examples/microbit_led.go "BBC micro:bit"
OSX uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
OSX uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
### Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/microbit_led.go
sudo ./microbit_led "BBC micro:bit"
```sh
go build examples/microbit_led.go
sudo ./microbit_led "BBC micro:bit"
```
### Windows

View File

@ -10,11 +10,7 @@ For more info about the MQTT machine to machine messaging standard, go to <http:
## How to Install
Install running:
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use

View File

@ -3,7 +3,7 @@ Package mqtt provides Gobot adaptor for the mqtt message service.
Installing:
go get gobot.io/x/gobot/v2/platforms/mqtt
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to mqtt README:
https://github.com/hybridgroup/gobot/blob/master/platforms/mqtt/README.md

View File

@ -7,17 +7,12 @@ For more info about the NanoPi Boards, go to [https://wiki.friendlyelec.com/wiki
## How to Install
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Tested OS:
* [armbian](https://www.armbian.com/nanopi-neo/) with Debian or Ubuntu
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your
workstation, transfer the final executable to your board, and run the program on the board as documented here.
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
### System access and configuration basics
Please follow the installation instructions for the chosen OS.

View File

@ -17,11 +17,7 @@ your IoT and Robotics projects.
## How to Install
Install running:
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use

View File

@ -2,7 +2,7 @@
Package nats provides Gobot adaptor for the nats message service.
Installing:
go get gobot.io/x/gobot/v2/platforms/nats
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to nats README:
https://github.com/hybridgroup/gobot/blob/master/platforms/nats/README.md

View File

@ -1,46 +1,52 @@
# Neurosky
NeuroSky delivers fully integrated, single chip EEG biosensors. NeuroSky enables its partners and developers to bring their brainwave application ideas to market with the shortest amount of time, and lowest end consumer price.
NeuroSky delivers fully integrated, single chip EEG biosensors. NeuroSky enables its partners and developers to bring their
brainwave application ideas to market with the shortest amount of time, and lowest end consumer price.
This package contains the Gobot adaptor and driver for the [Neurosky Mindwave Mobile EEG](http://store.neurosky.com/products/mindwave-mobile).
## How to Install
Installing Gobot with Neurosky support is pretty easy.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How To Connect
### OSX
In order to allow Gobot running on your Mac to access the Mindwave, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup" and make sure that "Bluetooth Sharing" is checked.
In order to allow Gobot running on your Mac to access the Mindwave, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup"
and make sure that "Bluetooth Sharing" is checked.
Now you must pair with the Mindwave. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, hold the On/Pair button on the Mindwave towards the On/Pair text until you see "Mindwave" pop up as available devices. Pair with that device. Once paired your Mindwave will be accessable through the serial device similarly named as `/dev/tty.MindWaveMobile-DevA`
Now you must pair with the Mindwave. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, hold
the On/Pair button on the Mindwave towards the On/Pair text until you see "Mindwave" pop up as available devices. Pair with
that device. Once paired your Mindwave will be accessable through the serial device similarly named as `/dev/tty.MindWaveMobile-DevA`
### Ubuntu
Connecting to the Mindwave from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](https://gobot.io/x/gort) CLI commands. Here are the steps.
Connecting to the Mindwave from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](https://gobot.io/x/gort)
CLI commands. Here are the steps.
Find the address of the Mindwave, by using:
```
```sh
gort scan bluetooth
```
Pair to Mindwave using this command (substituting the actual address of your Mindwave):
```
```sh
gort bluetooth pair <address>
```
Connect to the Mindwave using this command (substituting the actual address of your Mindwave):
```
```sh
gort bluetooth connect <address>
```
### Windows
You should be able to pair your Mindwave using your normal system tray applet for Bluetooth, and then connect to the COM port that is bound to the device, such as `COM3`.
You should be able to pair your Mindwave using your normal system tray applet for Bluetooth, and then connect to the
COM port that is bound to the device, such as `COM3`.
## How to Use
@ -50,55 +56,55 @@ This small program lets you connect the Neurosky an load data.
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/neurosky"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/neurosky"
)
func main() {
adaptor := neurosky.NewAdaptor("/dev/rfcomm0")
neuro := neurosky.NewDriver(adaptor)
adaptor := neurosky.NewAdaptor("/dev/rfcomm0")
neuro := neurosky.NewDriver(adaptor)
work := func() {
neuro.On(neuro.Event("extended"), func(data interface{}) {
fmt.Println("Extended", data)
})
neuro.On(neuro.Event("signal"), func(data interface{}) {
fmt.Println("Signal", data)
})
neuro.On(neuro.Event("attention"), func(data interface{}) {
fmt.Println("Attention", data)
})
neuro.On(neuro.Event("meditation"), func(data interface{}) {
fmt.Println("Meditation", data)
})
neuro.On(neuro.Event("blink"), func(data interface{}) {
fmt.Println("Blink", data)
})
neuro.On(neuro.Event("wave"), func(data interface{}) {
fmt.Println("Wave", data)
})
neuro.On(neuro.Event("eeg"), func(data interface{}) {
eeg := data.(neurosky.EEGData)
fmt.Println("Delta", eeg.Delta)
fmt.Println("Theta", eeg.Theta)
fmt.Println("LoAlpha", eeg.LoAlpha)
fmt.Println("HiAlpha", eeg.HiAlpha)
fmt.Println("LoBeta", eeg.LoBeta)
fmt.Println("HiBeta", eeg.HiBeta)
fmt.Println("LoGamma", eeg.LoGamma)
fmt.Println("MidGamma", eeg.MidGamma)
fmt.Println("\n")
})
}
work := func() {
neuro.On(neuro.Event("extended"), func(data interface{}) {
fmt.Println("Extended", data)
})
neuro.On(neuro.Event("signal"), func(data interface{}) {
fmt.Println("Signal", data)
})
neuro.On(neuro.Event("attention"), func(data interface{}) {
fmt.Println("Attention", data)
})
neuro.On(neuro.Event("meditation"), func(data interface{}) {
fmt.Println("Meditation", data)
})
neuro.On(neuro.Event("blink"), func(data interface{}) {
fmt.Println("Blink", data)
})
neuro.On(neuro.Event("wave"), func(data interface{}) {
fmt.Println("Wave", data)
})
neuro.On(neuro.Event("eeg"), func(data interface{}) {
eeg := data.(neurosky.EEGData)
fmt.Println("Delta", eeg.Delta)
fmt.Println("Theta", eeg.Theta)
fmt.Println("LoAlpha", eeg.LoAlpha)
fmt.Println("HiAlpha", eeg.HiAlpha)
fmt.Println("LoBeta", eeg.LoBeta)
fmt.Println("HiBeta", eeg.HiBeta)
fmt.Println("LoGamma", eeg.LoGamma)
fmt.Println("MidGamma", eeg.MidGamma)
fmt.Println("\n")
})
}
robot := gobot.NewRobot("brainBot",
[]gobot.Connection{adaptor},
[]gobot.Device{neuro},
work,
)
robot := gobot.NewRobot("brainBot",
[]gobot.Connection{adaptor},
[]gobot.Device{neuro},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -3,7 +3,7 @@ Package neurosky contains the Gobot adaptor and driver for the Neurosky Mindwave
Installing:
go get gobot.io/x/gobot/v2/platforms/neurosky
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,12 +1,16 @@
# OpenCV
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.
OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine
perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and
modify the code.
For more info about OpenCV click [here](http://opencv.org/)
## How to Install
This package requires OpenCV 3.4+ be installed on your system, along with GoCV, which is the Go programming language wrapper used by Gobot. The best way is to follow the installation instructions on the GoCV website at [https://gocv.io](https://gocv.io).
This package requires OpenCV 3.4+ be installed on your system, along with GoCV, which is the Go programming language
wrapper used by Gobot. The best way is to follow the installation instructions on the GoCV website at [https://gocv.io](https://gocv.io).
The instructions should automatically install OpenCV 4+
@ -14,26 +18,21 @@ The instructions should automatically install OpenCV 4+
To install on macOS follow the instructions here:
https://gocv.io/getting-started/macos/
<https://gocv.io/getting-started/macos/>
### Ubuntu
To install on Ubuntu follow the instructions here:
https://gocv.io/getting-started/linux/
<https://gocv.io/getting-started/linux/>
### Windows
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
To install on Windows follow the instructions here:
https://gocv.io/getting-started/windows/
Now you can install the Gobot package itself with
```
go get -d -u gobot.io/x/gobot/v2/...
```
<https://gocv.io/getting-started/windows/>
## How to Use
@ -43,28 +42,28 @@ Here is an example using the camera:
package main
import (
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/opencv"
"gocv.io/x/gocv"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/opencv"
"gocv.io/x/gocv"
)
func main() {
window := opencv.NewWindowDriver()
camera := opencv.NewCameraDriver(0)
window := opencv.NewWindowDriver()
camera := opencv.NewCameraDriver(0)
work := func() {
camera.On(opencv.Frame, func(data interface{}) {
img := data.(gocv.Mat)
window.ShowImage(img)
window.WaitKey(1)
})
}
work := func() {
camera.On(opencv.Frame, func(data interface{}) {
img := data.(gocv.Mat)
window.ShowImage(img)
window.WaitKey(1)
})
}
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -7,7 +7,7 @@ Installing:
Then you can install the package with:
go get gobot.io/x/gobot/v2 && go install gobot.io/x/gobot/v2/platforms/opencv
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,48 +1,50 @@
# Ardrone
The ARDrone from Parrot is an inexpensive quadcopter that is controlled using WiFi. It includes a built-in front-facing HD video camera, as well as a second lower resolution bottom facing video camera.
The ARDrone from Parrot is an inexpensive quadcopter that is controlled using WiFi. It includes a built-in front-facing
HD video camera, as well as a second lower resolution bottom facing video camera.
For more info about the ARDrone platform click [here](http://ardrone2.parrot.com/).
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/parrot/ardrone"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/parrot/ardrone"
)
func main() {
ardroneAdaptor := ardrone.NewAdaptor("Drone")
drone := ardrone.NewDriver(ardroneAdaptor, "Drone")
ardroneAdaptor := ardrone.NewAdaptor("Drone")
drone := ardrone.NewDriver(ardroneAdaptor, "Drone")
work := func() {
drone.On(drone.Event("flying"), func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
drone.TakeOff()
}
work := func() {
drone.On(drone.Event("flying"), func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
drone.TakeOff()
}
robot := gobot.NewRobot("drone",
[]gobot.Connection{ardroneAdaptor},
[]gobot.Device{drone},
work,
)
robot := gobot.NewRobot("drone",
[]gobot.Connection{ardroneAdaptor},
[]gobot.Device{drone},
work,
)
robot.Start()
robot.Start()
}
```
## How to Connect
The ARDrone is a WiFi device, so there is no additional work to establish a connection to a single drone. However, in order to connect to multiple drones, you need to perform some configuration steps on each drone via SSH.
The ARDrone is a WiFi device, so there is no additional work to establish a connection to a single drone. However, in
order to connect to multiple drones, you need to perform some configuration steps on each drone via SSH.

View File

@ -3,7 +3,7 @@ Package ardrone provides the Gobot adaptor and driver for the Parrot Ardrone.
Installing:
go get -d -u gobot.io/x/gobot/v2/... && go install gobot.io/x/gobot/v2/platforms/parrot/ardrone
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,52 +1,55 @@
# Bebop
The Parrot Bebop and Parrot Bebop 2 are inexpensive quadcopters that can be controlled using their built-in API commands via a WiFi connection. They include a built-in front-facing HD video camera, as well as a second lower resolution bottom-facing video camera.
The Parrot Bebop and Parrot Bebop 2 are inexpensive quadcopters that can be controlled using their built-in API commands
via a WiFi connection. They include a built-in front-facing HD video camera, as well as a second lower resolution
bottom-facing video camera.
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
```go
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/parrot/bebop"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/parrot/bebop"
)
func main() {
bebopAdaptor := bebop.NewAdaptor()
drone := bebop.NewDriver(bebopAdaptor)
bebopAdaptor := bebop.NewAdaptor()
drone := bebop.NewDriver(bebopAdaptor)
work := func() {
work := func() {
drone.HullProtection(true)
drone.TakeOff()
gobot.On(drone.Event("flying"), func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
}
drone.TakeOff()
gobot.On(drone.Event("flying"), func(data interface{}) {
gobot.After(3*time.Second, func() {
drone.Land()
})
})
}
robot := gobot.NewRobot("drone",
[]gobot.Connection{bebopAdaptor},
[]gobot.Device{drone},
work,
)
robot := gobot.NewRobot("drone",
[]gobot.Connection{bebopAdaptor},
[]gobot.Device{drone},
work,
)
robot.Start()
robot.Start()
}
```
## How to Connect
By default, the Parrot Bebop is a WiFi access point, so there is no additional work to establish a connection to a single drone, you just connect to it.
By default, the Parrot Bebop is a WiFi access point, so there is no additional work to establish a connection to a single
drone, you just connect to it.
Once connected, if you want to stream drone video you can either:
- Use the RTP protocol with an external player such as mplayer or VLC.
- Grab the video frames from the drone's data frames, and work with them directly.
- Use the RTP protocol with an external player such as mplayer or VLC.
- Grab the video frames from the drone's data frames, and work with them directly.

View File

@ -3,7 +3,7 @@ Package bebop provides the Gobot adaptor and driver for the Parrot Bebop.
Installing:
go get -d -u gobot.io/x/gobot/v2/... && go install gobot.io/x/gobot/v2/platforms/parrot/bebop
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For more information refer to the bebop README:
https://github.com/hybridgroup/gobot/tree/master/platforms/parrot/bebop/README.md

View File

@ -4,28 +4,26 @@ The Parrot Minidrones are very inexpensive drones that are controlled using Blue
Models that are known to work with this package include:
- Parrot Rolling Spider
- Parrot Airborne Cargo Mars
- Parrot Airborne Cargo Travis
- Parrot Mambo
- Parrot Rolling Spider
- Parrot Airborne Cargo Mars
- Parrot Airborne Cargo Travis
- Parrot Mambo
Models that should work now, but have not been tested by us:
- Parrot Airborne Night Swat
- Parrot Airborne Night Maclane
- Parrot Airborne Night Blaze
- Parrot HYDROFOIL Orak
- Parrot HYDROFOIL NewZ
- Parrot Airborne Night Swat
- Parrot Airborne Night Maclane
- Parrot Airborne Night Blaze
- Parrot HYDROFOIL Orak
- Parrot HYDROFOIL NewZ
Models that will require additional work for compatibility:
- Parrot Swing
- Parrot Swing
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -33,58 +31,58 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"fmt"
"os"
"time"
"fmt"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/parrot/minidrone"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/parrot/minidrone"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
drone := minidrone.NewDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
drone := minidrone.NewDriver(bleAdaptor)
work := func() {
drone.On(minidrone.Battery, func(data interface{}) {
fmt.Printf("battery: %d\n", data)
})
work := func() {
drone.On(minidrone.Battery, func(data interface{}) {
fmt.Printf("battery: %d\n", data)
})
drone.On(minidrone.FlightStatus, func(data interface{}) {
fmt.Printf("flight status: %d\n", data)
})
drone.On(minidrone.FlightStatus, func(data interface{}) {
fmt.Printf("flight status: %d\n", data)
})
drone.On(minidrone.Takeoff, func(data interface{}) {
fmt.Println("taking off...")
})
drone.On(minidrone.Takeoff, func(data interface{}) {
fmt.Println("taking off...")
})
drone.On(minidrone.Hovering, func(data interface{}) {
fmt.Println("hovering!")
gobot.After(5*time.Second, func() {
drone.Land()
})
})
drone.On(minidrone.Hovering, func(data interface{}) {
fmt.Println("hovering!")
gobot.After(5*time.Second, func() {
drone.Land()
})
})
drone.On(minidrone.Landing, func(data interface{}) {
fmt.Println("landing...")
})
drone.On(minidrone.Landing, func(data interface{}) {
fmt.Println("landing...")
})
drone.On(minidrone.Landed, func(data interface{}) {
fmt.Println("landed.")
})
drone.On(minidrone.Landed, func(data interface{}) {
fmt.Println("landed.")
})
time.Sleep(1000 * time.Millisecond)
drone.TakeOff()
}
time.Sleep(1000 * time.Millisecond)
drone.TakeOff()
}
robot := gobot.NewRobot("minidrone",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{drone},
work,
)
robot := gobot.NewRobot("minidrone",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{drone},
work,
)
robot.Start()
robot.Start()
}
```
@ -92,26 +90,33 @@ func main() {
The Parrot Minidrones are Bluetooth LE devices.
You need to know the BLE ID or name of the Minidrone you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "RS_1234".
You need to know the BLE ID or name of the Minidrone you want to connect to. The Gobot BLE client adaptor also lets you
connect by friendly name, aka "RS_1234".
### OSX
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in the CGo-based implementation.
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in
the CGo-based implementation.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID,
OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
For example:
GODEBUG=cgocheck=0 go run examples/minidrone.go RS_1234
`GODEBUG=cgocheck=0 go run examples/minidrone.go RS_1234`
### Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/minidrone.go
sudo ./minidrone RS_1234
```sh
go build examples/minidrone.go
sudo ./minidrone RS_1234
```
### Windows

View File

@ -1,16 +1,16 @@
# Particle
The Particle Photon and Particle Electron are connected microcontrollers from Particle (http://particle.io), the company formerly known as Spark Devices. The Photon uses a Wi-Fi connection to the Particle cloud, and the Electron uses a 3G wireless connection. Once the Photon or Electron connects to the network, it automatically connects with a central server (the "Particle Cloud") and stays connected so it can be controlled from external systems, such as a Gobot program. To run Gobot programs please make sure you are running default Tinker firmware on the Photon or Electron.
The Particle Photon and Particle Electron are connected microcontrollers from Particle (<http://particle.io>), the company
formerly known as Spark Devices. The Photon uses a Wi-Fi connection to the Particle cloud, and the Electron uses a
3G wireless connection. Once the Photon or Electron connects to the network, it automatically connects with a central server
(the "Particle Cloud") and stays connected so it can be controlled from external systems, such as a Gobot program. To run
Gobot programs please make sure you are running default Tinker firmware on the Photon or Electron.
For more info about the Particle platform go to https://www.particle.io/
For more info about the Particle platform go to <https://www.particle.io/>
## How to Install
Installing Gobot with Particle support is pretty easy.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -18,29 +18,29 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/particle"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/particle"
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
led := gpio.NewLedDriver(core, "D7")
core := particle.NewAdaptor("device_id", "access_token")
led := gpio.NewLedDriver(core, "D7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -3,7 +3,7 @@ Package particle provides the Gobot adaptor for the Particle Photon and Electron
Installing:
go get gobot.io/x/gobot/v2 && go install gobot.io/x/gobot/v2/platforms/particle
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -2,59 +2,59 @@
This repository contains the Gobot adaptor for [Pebble smart watch](http://getpebble.com/).
It uses the Pebble 2.0 SDK, and requires the 2.0 iOS or Android app, and that the ["watchbot" app](https://gobot.io/x/watchbot) has been installed on the Pebble watch.
It uses the Pebble 2.0 SDK, and requires the 2.0 iOS or Android app, and that the ["watchbot" app](https://gobot.io/x/watchbot)
has been installed on the Pebble watch.
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
* Install Pebble 2.0 iOS or Android app. (If you haven't already)
* Follow README to install and configure "watchbot" on your watch: https://gobot.io/x/watchbot
* Follow README to install and configure "watchbot" on your watch: <https://gobot.io/x/watchbot>
## How to Use
Before running the example, make sure configuration settings match with your program. In the example, api host is your computer IP, robot name is 'pebble' and robot api port is 8080
Before running the example, make sure configuration settings match with your program. In the example, api host is your
computer IP, robot name is 'pebble' and robot api port is 8080
```go
package main
import (
"fmt"
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/api"
"gobot.io/x/gobot/v2/platforms/pebble"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/api"
"gobot.io/x/gobot/v2/platforms/pebble"
)
func main() {
master := gobot.NewMaster()
api.NewAPI(master).Start()
master := gobot.NewMaster()
api.NewAPI(master).Start()
pebbleAdaptor := pebble.NewAdaptor()
watch := pebble.NewDriver(pebbleAdaptor)
pebbleAdaptor := pebble.NewAdaptor()
watch := pebble.NewDriver(pebbleAdaptor)
work := func() {
watch.SendNotification("Hello Pebble!")
watch.On(watch.Event("button"), func(data interface{}) {
fmt.Println("Button pushed: " + data.(string))
})
work := func() {
watch.SendNotification("Hello Pebble!")
watch.On(watch.Event("button"), func(data interface{}) {
fmt.Println("Button pushed: " + data.(string))
})
watch.On(watch.Event("tap"), func(data interface{}) {
fmt.Println("Tap event detected")
})
}
watch.On(watch.Event("tap"), func(data interface{}) {
fmt.Println("Tap event detected")
})
}
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{watch},
work,
)
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{watch},
work,
)
master.AddRobot(robot)
master.AddRobot(robot)
master.Start()
master.Start()
}
```
@ -67,17 +67,19 @@ func main() {
## Documentation
We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot
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
* All patches must be provided under the Apache 2.0 License
* 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
* 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.
* 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.
* 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.
* Add unit tests for any new or changed functionality
* All pull requests should be "fast forward"

View File

@ -6,7 +6,7 @@ Installing:
It requires the 2.x iOS or Android app, and "watchbot" app (https://gobot.io/x/watchbot)
installed on Pebble watch. Then install running:
go get gobot.io/x/gobot/v2/platforms/pebble
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -1,20 +1,20 @@
# Raspberry Pi
The Raspberry Pi is an inexpensive and popular ARM based single board computer with digital & PWM GPIO, and i2c interfaces built in.
The Raspberry Pi is an inexpensive and popular ARM based single board computer with digital & PWM GPIO, and i2c interfaces
built in.
The Gobot adaptor for the Raspberry Pi should support all of the various Raspberry Pi boards such as the Raspberry Pi 4 Model B, Raspberry Pi 3 Model B, Raspberry Pi 2 Model B, Raspberry Pi 1 Model A+, Raspberry Pi Zero, and Raspberry Pi Zero W.
The Gobot adaptor for the Raspberry Pi should support all of the various Raspberry Pi boards such as the
Raspberry Pi 4 Model B, Raspberry Pi 3 Model B, Raspberry Pi 2 Model B, Raspberry Pi 1 Model A+, Raspberry Pi Zero,
and Raspberry Pi Zero W.
For more info about the Raspberry Pi platform, click [here](http://www.raspberrypi.org/).
## How to Install
We recommend updating to the latest Raspian Jessie OS when using the Raspberry Pi, however Gobot should also support older versions of the OS, should your application require this.
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your Raspberry Pi, and run the program on the Raspberry Pi as documented here.
```
go get -d -u gobot.io/x/gobot/v2/...
```
We recommend updating to the latest Raspian Jessie OS when using the Raspberry Pi, however Gobot should also support
older versions of the OS, should your application require this.
## How to Use
@ -24,30 +24,30 @@ The pin numbering used by your Gobot program should match the way your board is
package main
import (
"time"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/raspi"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/raspi"
)
func main() {
r := raspi.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
r := raspi.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot.Start()
robot.Start()
}
```
@ -57,8 +57,8 @@ func main() {
Compile your Gobot program on your workstation like this:
```bash
$ GOARM=6 GOARCH=arm GOOS=linux go build examples/raspi_blink.go
```sh
GOARM=6 GOARCH=arm GOOS=linux go build examples/raspi_blink.go
```
Use the following `GOARM` values to compile depending on which model Raspberry Pi you are using:
@ -66,15 +66,17 @@ Use the following `GOARM` values to compile depending on which model Raspberry P
`GOARM=6` (Raspberry Pi A, A+, B, B+, Zero)
`GOARM=7` (Raspberry Pi 2, 3)
Once you have compiled your code, you can upload your program and execute it on the Raspberry Pi from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can upload your program and execute it on the Raspberry Pi from your workstation
using the `scp` and `ssh` commands like this:
```bash
$ scp raspi_blink pi@192.168.1.xxx:/home/pi/
$ ssh -t pi@192.168.1.xxx "./raspi_blink"
```sh
scp raspi_blink pi@192.168.1.xxx:/home/pi/
ssh -t pi@192.168.1.xxx "./raspi_blink"
```
### Enabling PWM output on GPIO pins.
### Enabling PWM output on GPIO pins
For extended PWM support on the Raspberry Pi, you will need to use a program called pi-blaster. You can follow the instructions for pi-blaster install in the pi-blaster repo here:
For extended PWM support on the Raspberry Pi, you will need to use a program called pi-blaster. You can follow the
instructions for pi-blaster install in the pi-blaster repo here:
[https://github.com/sarfata/pi-blaster](https://github.com/sarfata/pi-blaster)

View File

@ -2,39 +2,48 @@
Sphero is a sophisticated and programmable robot housed in a polycarbonate sphere shell.
The Gobot Sphero Adaptor & Driver makes it easy to interact with Sphero using Go. Once you have your Sphero setup and connected to your computer you can start writing code to make Sphero move, change direction, speed and colors, or detect Sphero events and execute some code when they occur.
The Gobot Sphero Adaptor & Driver makes it easy to interact with Sphero using Go. Once you have your Sphero setup and connected
to your computer you can start writing code to make Sphero move, change direction, speed and colors, or detect Sphero events
and execute some code when they occur.
Learn more about the Sphero robot go here: http://www.gosphero.com/
Learn more about the Sphero robot go here: <http://www.gosphero.com/>
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How To Connect
### OSX
In order to allow Gobot running on your Mac to access the Sphero, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup" and make sure that "Bluetooth Sharing" is checked.
In order to allow Gobot running on your Mac to access the Sphero, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup"
and make sure that "Bluetooth Sharing" is checked.
Now you must pair with the Sphero. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, smack the Sphero until it starts flashing three colors. You should see "Sphero-XXX" pop up as available devices where "XXX" is the first letter of the three colors the sphero is flashing. Pair with that device. Once paired your Sphero will be accessable through the serial device similarly named as `/dev/tty.Sphero-XXX-RN-SPP`
Now you must pair with the Sphero. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, smack
the Sphero until it starts flashing three colors. You should see "Sphero-XXX" pop up as available devices where "XXX" is
the first letter of the three colors the sphero is flashing. Pair with that device. Once paired your Sphero will be accessable
through the serial device similarly named as `/dev/tty.Sphero-XXX-RN-SPP`
### Ubuntu
Connecting to the Sphero from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](http://gort.io/) CLI commands. Here are the steps.
Connecting to the Sphero from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](http://gort.io/)
CLI commands. Here are the steps.
Find the address of the Sphero, by using:
```
```sh
gort scan bluetooth
```
Pair to Sphero using this command (substituting the actual address of your Sphero):
```
```sh
gort bluetooth pair <address>
```
Connect to the Sphero using this command (substituting the actual address of your Sphero):
```
```sh
gort bluetooth connect <address>
```
@ -50,29 +59,29 @@ Example of a simple program that makes the Sphero roll.
package main
import (
"fmt"
"time"
"fmt"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/sphero"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/sphero"
)
func main() {
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor)
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor)
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
robot.Start()
robot.Start()
}
```

View File

@ -4,9 +4,7 @@ The Sphero BB-8 is a toy robot from Sphero that is controlled using Bluetooth LE
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -14,34 +12,34 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"os"
"time"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/bb8"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/bb8"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
bb8 := bb8.NewDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
bb8 := bb8.NewDriver(bleAdaptor)
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
bb8.SetRGB(r, g, b)
})
}
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
bb8.SetRGB(r, g, b)
})
}
robot := gobot.NewRobot("bb",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{bb8},
work,
)
robot := gobot.NewRobot("bb",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{bb8},
work,
)
robot.Start()
robot.Start()
}
```
@ -49,26 +47,33 @@ func main() {
The Sphero BB-8 is a Bluetooth LE device.
You need to know the BLE ID of the BB-8 you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "BB-1247".
You need to know the BLE ID of the BB-8 you want to connect to. The Gobot BLE client adaptor also lets you connect by
friendly name, aka "BB-1247".
### OSX
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in the CGo-based implementation.
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in
the CGo-based implementation.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID,
OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
For example:
GODEBUG=cgocheck=0 go run examples/bb8.go BB-1247
`GODEBUG=cgocheck=0 go run examples/bb8.go BB-1247`
### Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/bb8.go
sudo ./bb8 BB-1247
```sh
go build examples/bb8.go
sudo ./bb8 BB-1247
```
### Windows

View File

@ -3,7 +3,7 @@ Package sphero provides the Gobot adaptor and driver for the Sphero.
Installing:
go get gobot.io/x/gobot/v2/platforms/sphero
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Example:

View File

@ -4,9 +4,7 @@ The Sphero Ollie is a toy robot from Sphero that is controlled using Bluetooth L
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -14,34 +12,34 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"os"
"time"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/ollie"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/ollie"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ollie := ollie.NewDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
ollie := ollie.NewDriver(bleAdaptor)
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
ollie.SetRGB(r, g, b)
})
}
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
ollie.SetRGB(r, g, b)
})
}
robot := gobot.NewRobot("ollieBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ollie},
work,
)
robot := gobot.NewRobot("ollieBot",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{ollie},
work,
)
robot.Start()
robot.Start()
}
```
@ -49,26 +47,33 @@ func main() {
The Sphero Ollie is a Bluetooth LE device.
You need to know the BLE ID of the Ollie you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "2B-1247".
You need to know the BLE ID of the Ollie you want to connect to. The Gobot BLE client adaptor also lets you connect by
friendly name, aka "2B-1247".
### OSX
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in the CGo-based implementation.
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in
the CGo-based implementation.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID,
OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
For example:
GODEBUG=cgocheck=0 go run examples/ollie.go 2B-1247
`GODEBUG=cgocheck=0 go run examples/ollie.go 2B-1247`
### Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/ollie.go
sudo ./minidrone 2B-1247
```sh
go build examples/ollie.go
sudo ./minidrone 2B-1247
```
### Windows

View File

@ -4,9 +4,7 @@ The Sphero SPRK+ is a toy robot from Sphero that is controlled using Bluetooth L
## How to Install
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -14,34 +12,34 @@ go get -d -u gobot.io/x/gobot/v2/...
package main
import (
"os"
"time"
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/sprkplus"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
"gobot.io/x/gobot/v2/platforms/sphero/sprkplus"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
sprk := sprkplus.NewDriver(bleAdaptor)
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
sprk := sprkplus.NewDriver(bleAdaptor)
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
sprk.SetRGB(r, g, b)
})
}
work := func() {
gobot.Every(1*time.Second, func() {
r := uint8(gobot.Rand(255))
g := uint8(gobot.Rand(255))
b := uint8(gobot.Rand(255))
sprk.SetRGB(r, g, b)
})
}
robot := gobot.NewRobot("sprk",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{sprk},
work,
)
robot := gobot.NewRobot("sprk",
[]gobot.Connection{bleAdaptor},
[]gobot.Device{sprk},
work,
)
robot.Start()
robot.Start()
}
```
@ -49,26 +47,33 @@ func main() {
The Sphero SPRK+ is a Bluetooth LE device.
You need to know the BLE ID of the SPRK+ you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "SK-1247".
You need to know the BLE ID of the SPRK+ you want to connect to. The Gobot BLE client adaptor also lets you connect by
friendly name, aka "SK-1247".
### OSX
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in the CGo-based implementation.
To run any of the Gobot BLE code you must use the `GODEBUG=cgocheck=0` flag in order to get around some of the issues in
the CGo-based implementation.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID, OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.
If you connect by name, then you do not need to worry about the Bluetooth LE ID. However, if you want to connect by ID,
OS X uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces
provided by OSX, so as a result does not need to run under sudo.
For example:
GODEBUG=cgocheck=0 go run examples/sprkplus.go SK-1247
`GODEBUG=cgocheck=0 go run examples/sprkplus.go SK-1247`
### Ubuntu
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use `go build` to build your program, and then to run the requesting executable using `sudo`.
On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use
`go build` to build your program, and then to run the requesting executable using `sudo`.
For example:
go build examples/sprkplus.go
sudo ./sprkplus SK-1247
```sh
go build examples/sprkplus.go
sudo ./sprkplus SK-1247
```
### Windows

View File

@ -7,6 +7,8 @@ For more info about the Tinker Board, go to [https://www.asus.com/uk/Single-Boar
## How to Install
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
Tested OS:
* [Debian TinkerOS](https://github.com/TinkerBoard/debian_kernel/releases)
@ -15,13 +17,6 @@ Tested OS:
> The latest "Tinker Board Debian 10 V3.0.11" is official discontinued. Nevertheless it is well tested with gobot. There
> is a known i2c issue with the Kernel 4.4.194 if using block reads. armbian is known to work in this area.
You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your
workstation, transfer the final executable to your Tinker Board, and run the program on the Tinker Board as documented here.
```sh
go get -d -u gobot.io/x/gobot/v2/...
```
### System access and configuration basics
Some configuration steps are needed to enable drivers and simplify the interaction with your Tinker Board. Once your

View File

@ -1,6 +1,7 @@
# UP2
The UP2 Board aka "Up Squared" is a single board SoC computer based on the Intel Apollo Lake processor. It has built-in GPIO, PWM, SPI, and I2C interfaces.
The UP2 Board aka "Up Squared" is a single board SoC computer based on the Intel Apollo Lake processor. It has built-in
GPIO, PWM, SPI, and I2C interfaces.
For more info about the UP2 Board, go to [http://www.up-board.org/upsquared/](http://www.up-board.org/upsquared/).
@ -10,13 +11,14 @@ For more info about the UP2 Board, go to [http://www.up-board.org/upsquared/](ht
We recommend updating to the latest Ubuntu 16.04 and BIOS v3.3 when using the UP2 board. To update your UP2 OS go to:
https://downloads.up-community.org/download/up-squared-iot-grove-development-kit-ubuntu-16-04-server-image/
<https://downloads.up-community.org/download/up-squared-iot-grove-development-kit-ubuntu-16-04-server-image/>
To update your UP2 BIOS, go to:
https://downloads.up-community.org/download/up-squared-uefi-bios-v3-3/
<https://downloads.up-community.org/download/up-squared-uefi-bios-v3-3/>
Once your UP2 has been updated, you will need to provide permission to the `upsquared` user to access the GPIO or I2C subsystems on the board.
Once your UP2 has been updated, you will need to provide permission to the `upsquared` user to access the GPIO or I2C
subsystems on the board.
### Configuring GPIO on UP2 board
@ -24,14 +26,14 @@ To access the GPIO subsystem, you will need to create a new group, add your user
First, run the following commands on the board itself:
```
```sh
sudo groupadd gpio
sudo adduser upsquared gpio
```
Now, add a new UDEV rule to the UP2 board. Add the following text as a new UDEV rule named `/etc/udev/rules.d/99-gpio.rules`:
```
```sh
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
chown -R root:gpiouser /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
chown -R root:gpiouser /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
@ -45,14 +47,14 @@ To use the built-in LEDs you will need to create a new group, add your user to t
First, run the following commands on the board itself:
```
```sh
sudo groupadd leds
sudo adduser upsquared leds
```
Now add the following text as a new UDEV rule named `/etc/udev/rules.d/99-leds.rules`:
```
```sh
SUBSYSTEM=="leds*", PROGRAM="/bin/sh -c '\
chown -R root:leds /sys/class/leds && chmod -R 770 /sys/class/leds;\
chown -R root:leds /sys/devices/platform/up-pinctrl/leds && chmod -R 770 /sys/devices/platform/up-pinctrl/leds;\
@ -64,22 +66,20 @@ SUBSYSTEM=="leds*", PROGRAM="/bin/sh -c '\
To access the I2C subsystem, run the following command:
```
```sh
sudo usermod -aG i2c upsquared
```
You should reboot your UP2 board after making these changes for them to take effect.
**IMPORTANT NOTE REGARDING I2C:**
The current UP2 firmware is not able to scan for I2C devices using the `i2cdetect` command line tool. If you run this tool, it will cause the I2C subsystem to malfunction until you reboot your system. That means at this time, do not use `i2cdetect` on the UP2 board.
**IMPORTANT NOTE REGARDING I2C:**
The current UP2 firmware is not able to scan for I2C devices using the `i2cdetect` command line tool. If you run this tool,
it will cause the I2C subsystem to malfunction until you reboot your system. That means at this time, do not use `i2cdetect`
on the UP2 board.
### Local setup
You would normally install Go and Gobot on your local workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your UP2, and run the program on the UP2 as documented below.
```
go get -d -u gobot.io/x/gobot/v2/...
```
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
## How to Use
@ -90,7 +90,8 @@ r := up2.NewAdaptor()
led := gpio.NewLedDriver(r, "13")
```
You can also use the values `up2.LEDRed`, `up2.LEDBlue`, `up2.LEDGreen`, and `up2.LEDYellow` as pin reference to access the 4 built-in LEDs. For example:
You can also use the values `up2.LEDRed`, `up2.LEDBlue`, `up2.LEDGreen`, and `up2.LEDYellow` as pin reference to access
the 4 built-in LEDs. For example:
```go
r := up2.NewAdaptor()
@ -103,13 +104,14 @@ led := gpio.NewLedDriver(r, up2.LEDRed)
Compile your Gobot program on your workstation like this:
```bash
$ GOARCH=amd64 GOOS=linux go build examples/up2_blink.go
```sh
GOARCH=amd64 GOOS=linux go build examples/up2_blink.go
```
Once you have compiled your code, you can you can upload your program and execute it on the UP2 from your workstation using the `scp` and `ssh` commands like this:
Once you have compiled your code, you can you can upload your program and execute it on the UP2 from your workstation using
the `scp` and `ssh` commands like this:
```bash
$ scp up2_blink upsquared@192.168.1.xxx:/home/upsquared/
$ ssh -t upsquared@192.168.1.xxx "./up2_blink"
```sh
scp up2_blink upsquared@192.168.1.xxx:/home/upsquared/
ssh -t upsquared@192.168.1.xxx "./up2_blink"
```

View File

@ -1,28 +0,0 @@
name: gobot
version: dev
summary: Gobot is a framework for robotics, physical computing, and IoT.
description: |
Gobot is a framework using the Go programming language for robotics, physical
computing, and the Internet of Things.
It provides a simple, yet powerful way to create solutions that incorporate
multiple, different hardware devices at the same time.
grade: devel
confinement: strict
apps:
gobot:
command: gobot
plugs: [home]
parts:
gobot:
source: .
plugin: go
go-packages: [gobot.io/x/gobot/v2/cli]
go-importpath: gobot.io/x/gobot/v2
organize:
bin/cli: bin/gobot
after: [go]
go:
source-tag: go1.7.5

View File

@ -1,8 +0,0 @@
package gobot
const version = "2.0.0"
// Version returns the current Gobot version
func Version() string {
return version
}