gobot: gobot.io/x/gobot/platforms/dexter/gopigo3 Index | Files

package gopigo3

import "gobot.io/x/gobot/platforms/dexter/gopigo3"

Package gopigo3 is based on https://github.com/DexterInd/GoPiGo3/blob/master/Software/Python/gopigo3.py You will need to run the following commands if using a stock raspbian image before this library will work: sudo curl -kL dexterindustries.com/update_gopigo3 | bash sudo reboot

Index

Package Files

driver.go

Constants

const (
    NONE byte = iota
    GET_MANUFACTURER
    GET_NAME
    GET_HARDWARE_VERSION
    GET_FIRMWARE_VERSION
    GET_ID
    SET_LED
    GET_VOLTAGE_5V
    GET_VOLTAGE_VCC
    SET_SERVO
    SET_MOTOR_PWM
    SET_MOTOR_POSITION
    SET_MOTOR_POSITION_KP
    SET_MOTOR_POSITION_KD
    SET_MOTOR_DPS
    SET_MOTOR_LIMITS
    OFFSET_MOTOR_ENCODER
    GET_MOTOR_ENCODER_LEFT
    GET_MOTOR_ENCODER_RIGHT
    GET_MOTOR_STATUS_LEFT
    GET_MOTOR_STATUS_RIGHT
    SET_GROVE_TYPE
    SET_GROVE_MODE
    SET_GROVE_STATE
    SET_GROVE_PWM_DUTY
    SET_GROVE_PWM_FREQUENCY
    GET_GROVE_VALUE_1
    GET_GROVE_VALUE_2
    GET_GROVE_STATE_1_1
    GET_GROVE_STATE_1_2
    GET_GROVE_STATE_2_1
    GET_GROVE_STATE_2_2
    GET_GROVE_VOLTAGE_1_1
    GET_GROVE_VOLTAGE_1_2
    GET_GROVE_VOLTAGE_2_1
    GET_GROVE_VOLTAGE_2_2
    GET_GROVE_ANALOG_1_1
    GET_GROVE_ANALOG_1_2
    GET_GROVE_ANALOG_2_1
    GET_GROVE_ANALOG_2_2
    START_GROVE_I2C_1
    START_GROVE_I2C_2
)

register addresses for gopigo3

const (
    WHEEL_BASE_WIDTH           = 117                                                       // distance (mm) from left wheel to right wheel. This works with the initial GPG3 prototype. Will need to be adjusted.
    WHEEL_DIAMETER             = 66.5                                                      // wheel diameter (mm)
    WHEEL_BASE_CIRCUMFERENCE   = WHEEL_BASE_WIDTH * math.Pi                                // circumference of the circle the wheels will trace while turning (mm)
    WHEEL_CIRCUMFERENCE        = WHEEL_DIAMETER * math.Pi                                  // circumference of the wheels (mm)
    MOTOR_GEAR_RATIO           = 120                                                       // motor gear ratio
    ENCODER_TICKS_PER_ROTATION = 6                                                         // encoder ticks per motor rotation (number of magnet positions)
    MOTOR_TICKS_PER_DEGREE     = ((MOTOR_GEAR_RATIO * ENCODER_TICKS_PER_ROTATION) / 360.0) // encoder ticks per output shaft rotation degree
    GROVE_I2C_LENGTH_LIMIT     = 16
    MOTOR_FLOAT                = -128
)
const (
    AD11     string = "AD_1_1"
    AD12     string = "AD_1_2"
    AD21     string = "AD_2_1"
    AD22     string = "AD_2_2"
     Grove  = 0x01 // default pin for most grove devices, A0/D0
     Grove  = 0x02
     Grove  = 0x04 // default pin for most grove devices, A0/D0
     Grove  = 0x08
       Grove  = AD_1_1_G + AD_1_2_G
       Grove  = AD_2_1_G + AD_2_2_G
)
const (
    CUSTOM        GroveType = 1
    IR_DI_REMOTE            = 2
    IR_EV3_REMOTE           = 3
    US                      = 4
    I2C                     = 5
)

type Driver Uses

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

Driver is a Gobot Driver for the GoPiGo3 board.

func NewDriver Uses

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

NewDriver creates a new Gobot Driver for the GoPiGo3 board.

Params:

a *Adaptor - the Adaptor to use with this Driver

Optional params:

 spi.WithBus(int):    	bus to use with this driver
	spi.WithChip(int):    	chip to use with this driver
 spi.WithMode(int):    	mode to use with this driver
 spi.WithBits(int):    	number of bits to use with this driver
 spi.WithSpeed(int64):   speed in Hz to use with this driver

func (*Driver) AnalogRead Uses

func (g *Driver) AnalogRead(pin string) (value int, err error)

AnalogRead returns the analog value of the given pin.

func (*Driver) Connection Uses

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

Connection returns the Connection of the device.

func (*Driver) DigitalRead Uses

func (g *Driver) DigitalRead(pin string) (value int, err error)

DigitalRead reads the 0/1 value from the given pin.

func (*Driver) DigitalWrite Uses

func (g *Driver) DigitalWrite(pin string, val byte) (err error)

DigitalWrite writes a 0/1 value to the given pin.

func (*Driver) Get5vVoltage Uses

func (g *Driver) Get5vVoltage() (voltage float32, err error)

Get5vVoltage returns the current voltage on the 5v line.

func (*Driver) GetBatteryVoltage Uses

func (g *Driver) GetBatteryVoltage() (voltage float32, err error)

GetBatteryVoltage gets the battery voltage from the main battery pack (7v-12v).

func (*Driver) GetBoardName Uses

func (g *Driver) GetBoardName() (bName string, err error)

GetBoardName returns the board name from the firmware.

func (*Driver) GetFirmwareVersion Uses

func (g *Driver) GetFirmwareVersion() (fVer string, err error)

GetFirmwareVersion returns the current firmware version.

func (*Driver) GetHardwareVersion Uses

func (g *Driver) GetHardwareVersion() (hVer string, err error)

GetHardwareVersion returns the hardware version from the firmware.

func (*Driver) GetManufacturerName Uses

func (g *Driver) GetManufacturerName() (mName string, err error)

GetManufacturerName returns the manufacturer from the firmware.

func (*Driver) GetMotorEncoder Uses

func (g *Driver) GetMotorEncoder(motor Motor) (encoder int64, err error)

GetMotorEncoder reads a motor's encoder in degrees.

func (*Driver) GetMotorStatus Uses

func (g *Driver) GetMotorStatus(motor Motor) (flags uint8, power uint16, encoder, dps int, err error)

GetMotorStatus returns the status for the given motor.

func (*Driver) GetSerialNumber Uses

func (g *Driver) GetSerialNumber() (sNum string, err error)

GetSerialNumber returns the 128-bit hardware serial number of the board.

func (*Driver) Halt Uses

func (g *Driver) Halt() (err error)

Halt stops the driver.

func (*Driver) Name Uses

func (g *Driver) Name() string

Name returns the name of the device.

func (*Driver) OffsetMotorEncoder Uses

func (g *Driver) OffsetMotorEncoder(motor Motor, offset float64) error

OffsetMotorEncoder offsets a motor's encoder for calibration purposes.

func (*Driver) PwmWrite Uses

func (g *Driver) PwmWrite(pin string, val byte) (err error)

PwmWrite implents the pwm interface for the gopigo3.

func (*Driver) ServoWrite Uses

func (g *Driver) ServoWrite(srvo Servo, angle byte) error

ServoWrite writes an angle (0-180) to the given servo (servo 1 or servo 2).

func (*Driver) SetGroveMode Uses

func (g *Driver) SetGroveMode(port Grove, mode GroveMode) error

SetGroveMode sets the mode a given pin/port of the grove connector.

func (*Driver) SetGroveType Uses

func (g *Driver) SetGroveType(port Grove, gType GroveType) error

SetGroveType sets the given port to a grove device type.

func (*Driver) SetLED Uses

func (g *Driver) SetLED(led Led, red, green, blue uint8) error

SetLED sets rgb values from 0 to 255.

func (*Driver) SetMotorDps Uses

func (g *Driver) SetMotorDps(motor Motor, dps int) error

SetMotorDps sets the motor target speed in degrees per second.

func (*Driver) SetMotorLimits Uses

func (g *Driver) SetMotorLimits(motor Motor, power int8, dps int) error

SetMotorLimits sets the speed limits for a motor.

func (*Driver) SetMotorPosition Uses

func (g *Driver) SetMotorPosition(motor Motor, position int) error

SetMotorPosition sets the motor's position in degrees.

func (*Driver) SetMotorPower Uses

func (g *Driver) SetMotorPower(motor Motor, power int8) error

SetMotorPower sets a motor's power from -128 to 127.

func (*Driver) SetName Uses

func (g *Driver) SetName(n string)

SetName sets the name of the device.

func (*Driver) SetPWMDuty Uses

func (g *Driver) SetPWMDuty(port Grove, duty uint16) (err error)

SetPWMDuty sets the pwm duty cycle for the given pin/port.

func (*Driver) SetPWMFreq Uses

func (g *Driver) SetPWMFreq(port Grove, freq uint16) error

SetPWMFreq setst the pwm frequency for the given pin/port.

func (*Driver) SetServo Uses

func (g *Driver) SetServo(srvo Servo, us uint16) error

SetServo sets a servo's position in microseconds (0-16666).

func (*Driver) Start Uses

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

Start initializes the GoPiGo3

type Grove Uses

type Grove byte

Grove contains the addresses for pins/ports of the AD1/AD2 grove connector.

type GroveMode Uses

type GroveMode byte

GroveMode sets the mode of AD pins on the gopigo3.

const (
    GROVE_INPUT_DIGITAL          GroveMode = 0
    GROVE_OUTPUT_DIGITAL         GroveMode = 1
    GROVE_INPUT_DIGITAL_PULLUP   GroveMode = 2
    GROVE_INPUT_DIGITAL_PULLDOWN GroveMode = 3
    GROVE_INPUT_ANALOG           GroveMode = 4
    GROVE_OUTPUT_PWM             GroveMode = 5
    GROVE_INPUT_ANALOG_PULLUP    GroveMode = 6
    GROVE_INPUT_ANALOG_PULLDOWN  GroveMode = 7
)

type GroveState Uses

type GroveState int

GroveState contains the state of a grove device.

const (
    VALID_DATA GroveState = iota
    NOT_CONFIGURED
    CONFIGURING
    NO_DATA
    I2C_ERROR
)

type GroveType Uses

type GroveType int

GroveType represents the type of a grove device.

type Led Uses

type Led byte

Led contains the addresses for all leds on the board.

const (
    LED_EYE_RIGHT     Led = 0x01
    LED_EYE_LEFT      Led = 0x02
    LED_BLINKER_LEFT  Led = 0x04
    LED_BLINKER_RIGHT Led = 0x08
    LED_WIFI          Led = 0x80
)

type Motor Uses

type Motor byte

Motor contains the address for the left and right motors.

const (
    MOTOR_LEFT  Motor = 0x01
    MOTOR_RIGHT Motor = 0x02
)

type Servo Uses

type Servo byte

Servo contains the address for the 2 servo ports.

const (
    SERVO_1 Servo = 0x01
    SERVO_2 Servo = 0x02
)

Package gopigo3 imports 7 packages (graph). Updated 2018-07-10. Refresh now. Tools for package owners.