/engine

The purpose of this package is to programmatically control the GPIO pins on a Raspberry Pi. In doing so children and adults of all ages can make crazy robots that do all manner of crazy things.

Primary LanguageGoOtherNOASSERTION

Engine

Build Status

The purpose of this package is to programmatically control the GPIO pins on a Raspberry Pi. In doing so children and adults of all ages can make crazy robots that do all manner of crazy things.

The Robot

All the parts to make a robot that runs the code in this package can be ordered from amazon for around a $105;

This however this is not just an expensive robot. It's a whole computer! Plug in a TV and keyboard then you're all setup to code the ultimate robot. Or play music, videos, games, whatever you young folk do these days.

Optional parts for more fun;

UNSTABLE: This package is under active development.

Documentation

All the source code is commented and also available as online documentation.

There are working code examples of each supported controllable device.

A complete program for a basic line following robot can be found here.

Working Notes

Setup the Raspberry Pi

You will need to create a SSD with Raspbian Jesse Lite. Follow the Raspberry Pi instructions on how to install an operating system.

It's a good idea to use a Secure Shell when working with your robot but not required.

Setup the Environment

After logging on to the Raspberry Pi execute the following commands;

sudo apt-get install git
sudo apt-get install golang
mkdir ~/robot
cd ~/robot

Add the environment variables for using Go;

export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/robot
export PATH=$PATH:$GOPATH/bin

Get the Engine from Github;

go get github.com/ricallinson/simplebdd
go get github.com/ricallinson/engine

Subsequent Logins or Refreshing the Environment

export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/robot
export PATH=$PATH:$GOPATH/bin
cd ~/robot
go get -u github.com/ricallinson/engine

Testing

Run Engine Tests

cd ~/robot/src/github.com/ricallinson/engine
go test -v -cover ./...

Examples

LED

Source code for LED example.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/led-flash
go install
led-flash

LED with Software Pulse Width Modulation (maximum of a 100Hz)

Source code for LED with Pulse Width Modulation example.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/led-pwm
go install
led-pwm

Note: This has only been tested on one pin.

IRSensor

Source code for IRSensor example.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/ir-sensor
go install
ir-sensor

RangeSensor

Source code for RangeSensor example. Requires optional parts to complete.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/range-sensor
go install
range-sensor

Motor

Source code for Motor example.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/motor
go install
motor

Line Follower

Source code for Line Follower example.

Wiring diagram

cd ~/robot/src/github.com/ricallinson/engine/examples/line-follower
go install
line-follower

Generate Code Coverage from Engine Tests

Run a packages tests and generate its coverage report with a HTML viewer;

cd ~/robot/src/github.com/ricallinson/engine
go test -covermode=count -coverprofile=count.out; go tool cover -html=count.out