Documentation ¶
Overview ¶
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 ¶
- Constants
- type Driver
- func (g *Driver) AnalogRead(pin string) (value int, err error)
- func (g *Driver) Connection() gobot.Connection
- func (g *Driver) DigitalRead(pin string) (value int, err error)
- func (g *Driver) DigitalWrite(pin string, val byte) (err error)
- func (g *Driver) Get5vVoltage() (voltage float32, err error)
- func (g *Driver) GetBatteryVoltage() (voltage float32, err error)
- func (g *Driver) GetBoardName() (bName string, err error)
- func (g *Driver) GetFirmwareVersion() (fVer string, err error)
- func (g *Driver) GetHardwareVersion() (hVer string, err error)
- func (g *Driver) GetManufacturerName() (mName string, err error)
- func (g *Driver) GetMotorEncoder(motor Motor) (encoder int64, err error)
- func (g *Driver) GetMotorStatus(motor Motor) (flags uint8, power uint16, encoder, dps int, err error)
- func (g *Driver) GetSerialNumber() (sNum string, err error)
- func (g *Driver) Halt() (err error)
- func (g *Driver) Name() string
- func (g *Driver) OffsetMotorEncoder(motor Motor, offset float64) error
- func (g *Driver) PwmWrite(pin string, val byte) (err error)
- func (g *Driver) ServoWrite(srvo Servo, angle byte) error
- func (g *Driver) SetGroveMode(port Grove, mode GroveMode) error
- func (g *Driver) SetGroveType(port Grove, gType GroveType) error
- func (g *Driver) SetLED(led Led, red, green, blue uint8) error
- func (g *Driver) SetMotorDps(motor Motor, dps int) error
- func (g *Driver) SetMotorLimits(motor Motor, power int8, dps int) error
- func (g *Driver) SetMotorPosition(motor Motor, position int) error
- func (g *Driver) SetMotorPower(motor Motor, power int8) error
- func (g *Driver) SetName(n string)
- func (g *Driver) SetPWMDuty(port Grove, duty uint16) (err error)
- func (g *Driver) SetPWMFreq(port Grove, freq uint16) error
- func (g *Driver) SetServo(srvo Servo, us uint16) error
- func (g *Driver) Start() (err error)
- type Grove
- type GroveMode
- type GroveState
- type GroveType
- type Led
- type Motor
- type Servo
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" AD_1_1_G Grove = 0x01 // default pin for most grove devices, A0/D0 AD_1_2_G Grove = 0x02 AD_2_1_G Grove = 0x04 // default pin for most grove devices, A0/D0 AD_2_2_G Grove = 0x08 AD_1_G Grove = AD_1_1_G + AD_1_2_G AD_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 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
Driver is a Gobot Driver for the GoPiGo3 board.
func NewDriver ¶
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 ¶
AnalogRead returns the analog value of the given pin.
func (*Driver) Connection ¶
func (g *Driver) Connection() gobot.Connection
Connection returns the Connection of the device.
func (*Driver) DigitalRead ¶
DigitalRead reads the 0/1 value from the given pin.
func (*Driver) DigitalWrite ¶
DigitalWrite writes a 0/1 value to the given pin.
func (*Driver) Get5vVoltage ¶
Get5vVoltage returns the current voltage on the 5v line.
func (*Driver) GetBatteryVoltage ¶
GetBatteryVoltage gets the battery voltage from the main battery pack (7v-12v).
func (*Driver) GetBoardName ¶
GetBoardName returns the board name from the firmware.
func (*Driver) GetFirmwareVersion ¶
GetFirmwareVersion returns the current firmware version.
func (*Driver) GetHardwareVersion ¶
GetHardwareVersion returns the hardware version from the firmware.
func (*Driver) GetManufacturerName ¶
GetManufacturerName returns the manufacturer from the firmware.
func (*Driver) GetMotorEncoder ¶
GetMotorEncoder reads a motor's encoder in degrees.
func (*Driver) GetMotorStatus ¶
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 ¶
GetSerialNumber returns the 128-bit hardware serial number of the board.
func (*Driver) OffsetMotorEncoder ¶
OffsetMotorEncoder offsets a motor's encoder for calibration purposes.
func (*Driver) ServoWrite ¶
ServoWrite writes an angle (0-180) to the given servo (servo 1 or servo 2).
func (*Driver) SetGroveMode ¶
SetGroveMode sets the mode a given pin/port of the grove connector.
func (*Driver) SetGroveType ¶
SetGroveType sets the given port to a grove device type.
func (*Driver) SetMotorDps ¶
SetMotorDps sets the motor target speed in degrees per second.
func (*Driver) SetMotorLimits ¶
SetMotorLimits sets the speed limits for a motor.
func (*Driver) SetMotorPosition ¶
SetMotorPosition sets the motor's position in degrees.
func (*Driver) SetMotorPower ¶
SetMotorPower sets a motor's power from -128 to 127.
func (*Driver) SetPWMDuty ¶
SetPWMDuty sets the pwm duty cycle for the given pin/port.
func (*Driver) SetPWMFreq ¶
SetPWMFreq setst the pwm frequency for the given pin/port.
type Grove ¶
type Grove byte
Grove contains the addresses for pins/ports of the AD1/AD2 grove connector.
type GroveMode ¶
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 ¶
type GroveState int
GroveState contains the state of a grove device.
const ( VALID_DATA GroveState = iota NOT_CONFIGURED CONFIGURING NO_DATA I2C_ERROR )