Gobot – A Framework for robots, drones, and IoT
What is Gobot?
Gobot is a framework for robotics, physical computing, and the Internet of Things (IoT), written in the Go programming language. It provides drivers and adapters for controlling a wide variety of physical devices from low-level Arduino and Raspberry Pi, as well as drones, toys, and other complete devices that themselves have APIs.
The “Robot” is the main software abstraction that makes it easy to build interesting high-level functionality for supported devices. Robots (Go programs) written with Gobot can run on a host machine communicating to connected devices, or directly on a single-board Linux computer, or anywhere in between. It can also provide an external facing API to allow other programs to control from individual devices to entire groups of Robots on a shared network, implemented using JSON-over-HTTP API. Gobot’s approach to standardization and abstraction makes it easy to write a program that works on multiple hardware platforms with little modification.
Set Up Your Environment
Installing Go
Go is an open-source programming language that makes it easy to develop simple, reliable, and efficient software.
Follow the official installation instructions to get started.
Installing Gobot
With Go installed, the go get
tool will help you install Gobot and its required dependencies:
$ go get -d -u gobot.io/x/gobot/...
Platform Support
It has a extensible system for connecting to hardware devices. Currently 35 platforms supported. Many GPIO, SPI, I2c drivers available with go lang packages.
API
It includes a RESTful API to query the status of any connection, device or robot running in your swarm. It additionally has the ability to issue commands directly to your devices and robots. Check out http://cppp.io for more information.
It also comes with the robeaux React.JS interface baked right into its API server for quick and easy configuration. You can check out more information on the Gobot API in the docs here.
CLI
Gobot is designed to be using in conjunction with Gort, 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. It also has it own CLI which you can learn more about here.
Getting Started with a Simple Tutorial
The “Hello, World” Of Things -This program connects to an Arduino, and toggles an LED, every one second.
package main import ( "time" "gobot.io/x/gobot" "gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/platforms/firmata" ) func main() { firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0") led := gpio.NewLedDriver(firmataAdaptor, "13") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } robot := gobot.NewRobot("bot", []gobot.Connection{firmataAdaptor}, []gobot.Device{led}, work, ) robot.Start() }
To run your Robot, you can just pass the source file to go run
:
$ go run blink.go
You should see the LED turn on and off every second. Explore More examples for IoT project.
Useful links
- Code on Github: https://github.com/hybridgroup/gobot
- Google Group: https://groups.google.com/forum/#!forum/gobotio
- Twitter: @gobotio
You may like also: The Go Programming Language
Pingback: The Go Programming Language - IoTbyHVM
Pingback: Go Programming Language - IoTbyHVM - Bits & Bytes of IoT