gopigo

package module
v0.0.0-...-49de5d5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

gopigo

The GoPiGo is a delightful and complete robot for the Raspberry Pi that turns your Pi into a fully operating robot. GoPiGo is a mobile robotic platform for the Raspberry Pi developed by Dexter Industries.

 GoPiGo

This repository contains Go library for interacting with the GoPiGo robot. This is a port of python library of GoPiGo in Go language.

Getting Started

Get the source with: go get -d -u github.com/droot/gopigo

Simple example
package main

import (
  "github.com/droot/gopigo"
  "github.com/kidoman/embd"

  _ "github.com/kidoman/embd/host/all"
)

func main() {
  if err := embd.InitI2C(); err != nil {
    panic(err)
  }
  defer embd.CloseI2C()

  bus := embd.NewI2CBus(1)

  // create GoPiGo instance.
  gp := gopigo.New(bus)

  // move GoPiGo forward by 40 cms
  err := gp.fwd(40)

  // move GoPiGo backward
  err = gp.Bwd(0)

  // make GoPiGo stop
  err = gp.Stop()

  // make GoPiGo take Left turn
  err = gp.Left()

  // make GoPiGo take right turn
  err = gp.Right()


  // Read Battery level of GoPiGo
  volt, err := gp.BatteryVoltage()


  .....
}

API Documentation

API documentation is available at https://godoc.org/github.com/droot/gopigo

Credits

Special Thanks to Dexter Industries for providing GoPiGo kit for the development.

Need help ?

Documentation

Overview

package gopigo implements APIs to control a GoPiGo robot. This package has been tested using Raspberry PI 3. If you have any trouble using it with older version of PIs, report it in Github issues.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoPiGo

type GoPiGo struct {
	// contains filtered or unexported fields
}

GoPiGo represents a GoPiGo device.

func New

func New(bus embd.I2CBus) *GoPiGo

New instantiates GoPiGo devices given I2C bus device.

func (*GoPiGo) BatteryVoltage

func (p *GoPiGo) BatteryVoltage() (volt float32, err error)

BatteryVoltage returns the Battery Voltage reading.

func (*GoPiGo) Bwd

func (p *GoPiGo) Bwd(distance int) error

Bwd moves the GoPiGo backwards. It takes distance in cms as input. If distance is 0, it moves backward without stopping.

func (*GoPiGo) DecreaseSpeed

func (p *GoPiGo) DecreaseSpeed() error

DecreaseSpeed slows down GoPiGo by speed of 10.

func (*GoPiGo) DirectMotor1

func (p *GoPiGo) DirectMotor1(direction, speed byte) error

DirectMotor1 sets the direction and speed of motor1.

func (*GoPiGo) DirectMotor2

func (p *GoPiGo) DirectMotor2(direction, speed byte) error

DirectMotor2 sets the direction and speed of motor2.

func (*GoPiGo) DisableEncoders

func (p *GoPiGo) DisableEncoders() error

DisableEncoders disables encoders.

func (*GoPiGo) EnableEncoders

func (p *GoPiGo) EnableEncoders() error

EnableEncoders enables the encoders (enabled by default).

func (*GoPiGo) Fwd

func (p *GoPiGo) Fwd(distance int) error

Fwd moves the GoPiGo forward. It takes distance in cms as input. If specified 0, it moves forward without stopping.

func (*GoPiGo) IncreaseSpeed

func (p *GoPiGo) IncreaseSpeed() error

IncreaseSpeed bumps up the motor's speed by 10.

func (*GoPiGo) Left

func (p *GoPiGo) Left() error

Left turns GoPiGo left slowly.

func (*GoPiGo) LeftRotate

func (p *GoPiGo) LeftRotate() error

LeftRotate turns GoPiGo left more aggresively by rotating both the wheels in reverse direction.

func (*GoPiGo) Right

func (p *GoPiGo) Right() error

Right turns GoPiGo to the right slowly.

func (*GoPiGo) RightRotate

func (p *GoPiGo) RightRotate() error

RightRotate turns GoPiGo to the right aggresively.

func (*GoPiGo) Stop

func (p *GoPiGo) Stop() error

Stop stops the GoPiGo devices (if its in motion).

func (*GoPiGo) TurnLeft

func (p *GoPiGo) TurnLeft(degrees float64) error

TurnLeft turns GoPiGo left by specified degrees.

func (*GoPiGo) TurnRight

func (p *GoPiGo) TurnRight(degrees float64) error

TurnRight turns GoPiGo to the right by specified angle in degrees.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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