Meet The Code

Gobot makes commanding robots incredibly simple and fun.

All you need to get started is install the library with :

go get -u github.com/hybridgroup/gobot.

Gobot with Sphero

package main

import (
  "fmt"
  "time"

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

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

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

  work := func() {
    gobot.Every(3*time.Second, func() {
      spheroDriver.Roll(30, uint16(gobot.Rand(360)))
    })
  }

  robot := gobot.NewRobot("sphero",
    []gobot.Connection{adaptor},
    []gobot.Device{spheroDriver},
    work,
  )

  gbot.AddRobot(robot)

  gbot.Start()
}

Gobot with Arduino

package main

import (
  "time"

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

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

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

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

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

  gbot.AddRobot(robot)

  gbot.Start()
}

Platform Support

Gobot has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported:

10 Platforms

Support for many devices that use General Purpose Input/Output (GPIO) have a shared set of drivers provded using the gobot-gpio module:

7 GPIO drivers

Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of drivers provded using the gobot-i2c module:

3 I2C drivers

See more drivers here

More platforms and drivers are coming soon...

Getting Started

Install the library with: go get -u github.com/hybridgroup/gobot

Then install additional libraries for whatever hardware support you want to use from your robot. For example, go get -u github.com/hybridgroup/gobot-sphero to use Gobot with a Sphero.

Ready to build Go robots with Gobot? Get Started Here!

API

Gobot includes a RESTful API to query the status of any robot running within a group, including the connection and device status, and execute device commands.

To activate the API, use the Api command like this:

master := gobot.GobotMaster()
gobot.Api(master)

You can also specify the api host and port, and turn on authentication:

master := gobot.GobotMaster()
api := gobot.Api(master)
api.Port = "3000"
api.Username = "Gort"
api.Password = "klaatu"

In order to use the robeaux AngularJS interface with Gobot you simply clone the robeaux repo and place it in the directory of your Gobot program. The robeaux assets must be in a folder called robeaux.

Then visit https://localhost:3000/#/robots and you are ready to control your robots from a web browser!

You can check out more information on the Gobot API in the docs here.

CLI

Gort is a Command Line Toolkit (CLI) for RobotOps. Gort provides tools to scan for connected devices, upload firmware, and it works perfectly with Gobot. Also included with Gobot is a CLI for generating new robots and adaptors.

You can can learn more about Gobot's CLI in the docs here.

Be Part Of The Robot Evolution