picoborgrev

package module
v0.0.0-...-d066a84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 5 Imported by: 1

README

Gobot driver for PicoBorg Reverse

Allows users to control pico borg reverse motor controllers over I2C using the gobot.io robotic framework.

GoDoc Travis

Installation on Raspberry

The library was tested on Raspberry PI. It should run on other Platforms provided by gobot.io too.

It is possible to build the project directly on the Raspberry. A documentation can be found in the gobot documentation. Nevertheless cross compiling on OS X is tested.

Using go1.6 just run:

$ env GOOS=linux GOARCH=arm GOARM=6 go build

And upload the binary to the raspberry

$ scp <binary> pi@192.168.1.xxx:/home/pi/

How to use

Install missing libraries:

$ go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/platforms/i2c
$ go get github.com/joek/picoborgrev

The library is used like every gobot driver:

package main

import (
	"time"

	"github.com/hybridgroup/gobot"
	"github.com/hybridgroup/gobot/platforms/raspi"
	"github.com/joek/picoborgrev"
)

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

	r := raspi.NewRaspiAdaptor("raspi")
	rev := picoborgrev.NewDriver(r, "rev", 10)

	work := func() {
		rev.SetMotorA(0.3)
		time.Sleep(10 * time.Second)
		rev.SetMotorA(-0.3)
		time.Sleep(10 * time.Second)
		rev.SetMotorA(0)
	}

	robot := gobot.NewRobot("beerbot",
		[]gobot.Connection{r},
		[]gobot.Device{rev},
		work,
	)

	gbot.AddRobot(robot)

	gbot.Start()
}

Open Topics

The PicoBorg Reverse is offering a lot of functionality. Currently only the setMotor(A/B) functions are implemented. Based on the piborg python sample library the following functions are missing:

  • SetMotors
  • GetMotorA
  • GetMotorB
  • SetEpoIgnore
  • GetEpoIgnore
  • SetLED
  • GetLED
  • GetDriveFault
  • SetEncoderMoveMode
  • GetEncoderMoveMode
  • SetEncoderSpeed
  • GetEncoderSpeed
  • EncoderMoveMotor1
  • EncoderMoveMotor2
  • EncoderMoveMotors
  • IsEncoderMoving
  • WaitWhileEncoderMoving

As a view functions are implemented later maybe somebody out of the community likes to contribute to the library to add some out of the list.

Development

The driver is tested using the amazing ginkgo and gomega libraries. You can run the tests using go test

License

MIT License

Documentation

Overview

Package picoborgrev allows users to control pico borg reverse motor controllers over I2C using the gobot.io robotic framework. See: https://www.piborg.org/, https://gobot.io/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	i2c.Config
	// contains filtered or unexported fields
}

Driver struct

func NewDriver

func NewDriver(a i2c.Connector, options ...func(i2c.Config)) *Driver

NewDriver creates a new driver with specified name and i2c interface

Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*Driver) Connection

func (h *Driver) Connection() gobot.Connection

Connection returns the connection

func (*Driver) GetEPO

func (h *Driver) GetEPO() (bool, error)

GetEPO Reads the system EPO latch state.

func (*Driver) Halt

func (h *Driver) Halt() (errs error)

Halt stops all motors

func (*Driver) Name

func (h *Driver) Name() string

Name returns the name of the device

func (*Driver) ResetEPO

func (h *Driver) ResetEPO() error

ResetEPO latch state, use to allow movement again after the EPO has been tripped

func (*Driver) SetMotorA

func (h *Driver) SetMotorA(power float32) error

SetMotorA generic set motor speed function

func (*Driver) SetMotorB

func (h *Driver) SetMotorB(power float32) error

SetMotorB generic set motor speed function

func (*Driver) SetName

func (h *Driver) SetName(n string)

SetName of the device

func (*Driver) Start

func (h *Driver) Start() (err error)

Start initialized the picoborgrev

func (*Driver) StopAllMotors

func (h *Driver) StopAllMotors() error

StopAllMotors will stop all motors

type RevDriver

type RevDriver interface {
	Name() string
	Connection() gobot.Connection
	Start() error
	Halt() error
	ResetEPO() error
	GetEPO() (bool, error)
	SetMotorA(float32) error
	SetMotorB(float32) error
	StopAllMotors() error
}

RevDriver pico borg rev driver interace

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL