Class GoBildaPinpoint
- All Implemented Interfaces:
AutoCloseable
Aborted I2C transactions and invalid read data are reported through GoBildaPinpoint.DeviceStatus.FAULT_BAD_READ instead of throwing an exception. Unless otherwise noted, methods
that access the device throw IllegalStateException after this driver is closed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPinpoint status, including device-reported faults and local read failures.static enumEncoder direction relative to the Pinpoint coordinate system.static enumError detection method used for I2C reads.static enumReason the driver rejected data or an I2C transaction.static enumgoBILDA odometry pod with a predefined encoder resolution.static enumRegister map for the Pinpoint. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault 7-bit I2C address of the Pinpoint. -
Constructor Summary
ConstructorsConstructorDescriptionGoBildaPinpoint(I2C.Port port) Constructs a Pinpoint on its default I2C address.GoBildaPinpoint(I2C.Port port, int deviceAddress) Constructs a Pinpoint. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the I2C connection.intReturns the I2C address.intReturns the device identifier.Returns the highest-priority current device or read status.intReturns the cached device status bits combined with the local bad-read status bit, if set.intReturns the firmware version.doubleReturns the configured encoder resolution.longReturns the total number of failures detected by this driver instance.longgetFailureCount(GoBildaPinpoint.Register register) Returns the number of failures associated with a register.Returns the most recently reported device loop frequency.doubleReturns the most recently reported device loop frequency.Returns the continuous tracked heading.doubleReturns the continuous tracked heading.Returns the heading velocity.doubleReturns the heading velocity.Returns the register associated with the most recent driver-detected failure.Returns the reason for the most recent driver-detected failure.intReturns the most recently reported device loop time.getPitch()Returns the pitch.doubleReturns the pitch.getPort()Returns the I2C port.getPose()Returns the tracked pose.Returns the device orientation quaternion.getRoll()Returns the roll.doubleReturns the roll.Returns the device orientation as a 3D rotation.intReturns the raw X encoder count.Returns the X pod offset.doubleReturns the X pod offset.Returns the tracked X position.doubleReturns the tracked X position.Returns the tracked X velocity.doubleReturns the tracked X velocity.doubleReturns the configured yaw scalar.intReturns the raw Y encoder count.Returns the Y pod offset.doubleReturns the Y pod offset.Returns the tracked Y position.doubleReturns the tracked Y position.Returns the tracked Y velocity.doubleReturns the tracked Y velocity.voidRecalibrates the IMU.voidResets the pose to the origin and recalibrates the IMU.voidsetBulkReadScope(GoBildaPinpoint.Register... registers) Configures the registers returned by a bulk read on v3 or newer firmware.voidsetEncoderDirections(GoBildaPinpoint.EncoderDirection xEncoder, GoBildaPinpoint.EncoderDirection yEncoder) Sets the directions of both odometry pod encoders.voidsetEncoderResolution(double ticksPerMeter) Sets a custom odometry pod encoder resolution.voidSets the encoder resolution for a goBILDA odometry pod.voidsetErrorDetectionType(GoBildaPinpoint.ErrorDetectionType errorDetectionType) Selects the read error detection method.voidsetHeading(Angle heading) Overrides the tracked heading.voidsetHeadingRadians(double headingRadians) Overrides the tracked heading.voidsetOffsets(double xOffsetMeters, double yOffsetMeters) Sets the odometry pod offsets in meters.voidsetOffsets(Distance xOffset, Distance yOffset) Sets the odometry pod offsets.voidOverrides the pose tracked by the Pinpoint.voidsetXPosition(Distance position) Overrides the tracked X position.voidsetXPositionMeters(double positionMeters) Overrides the tracked X position.voidsetYawScalar(double yawScalar) Sets the scalar applied to the IMU yaw measurement.voidsetYPosition(Distance position) Overrides the tracked Y position.voidsetYPositionMeters(double positionMeters) Overrides the tracked Y position.voidupdate()Reads all registers in the configured bulk-read scope and updates the cached measurements.voidReads and caches only the heading register.
-
Field Details
-
DEFAULT_ADDRESS
public static final int DEFAULT_ADDRESSDefault 7-bit I2C address of the Pinpoint.- See Also:
-
-
Constructor Details
-
GoBildaPinpoint
Constructs a Pinpoint on its default I2C address.- Parameters:
port- I2C port to which the Pinpoint is connected- Throws:
NullPointerException- ifportis null
-
GoBildaPinpoint
Constructs a Pinpoint.- Parameters:
port- I2C port to which the Pinpoint is connecteddeviceAddress- 7-bit I2C address- Throws:
NullPointerException- ifportis nullIllegalArgumentException- ifdeviceAddressis outside the 7-bit address range
-
-
Method Details
-
getPort
Returns the I2C port.- Returns:
- I2C port
- Throws:
IllegalStateException- if this driver has been closed
-
getDeviceAddress
public int getDeviceAddress()Returns the I2C address.- Returns:
- 7-bit I2C address
- Throws:
IllegalStateException- if this driver has been closed
-
close
public void close()Closes the I2C connection. Calling this method more than once has no effect.- Specified by:
closein interfaceAutoCloseable
-
update
public void update()Reads all registers in the configured bulk-read scope and updates the cached measurements. Call this once per robot loop.An aborted or invalid I2C read does not throw; it sets the device status to
GoBildaPinpoint.DeviceStatus.FAULT_BAD_READand preserves the last valid measurements.- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if CRC error detection is active with firmware older than v3
-
updateHeading
public void updateHeading()Reads and caches only the heading register.An aborted or invalid I2C read does not throw; it sets the device status to
GoBildaPinpoint.DeviceStatus.FAULT_BAD_READand preserves the last valid heading.- Throws:
IllegalStateException- if this driver has been closed
-
setBulkReadScope
Configures the registers returned by a bulk read on v3 or newer firmware. Duplicate registers are ignored while preserving the order of their first occurrence.- Parameters:
registers- readable registers to include- Throws:
NullPointerException- ifregistersor any register in it is nullUnsupportedOperationException- if the firmware is older than v3IllegalArgumentException- if no registers are provided or a register is not readableIllegalStateException- if this driver has been closed
-
setErrorDetectionType
Selects the read error detection method. Selecting CRC reads the firmware version and requires v3 or newer firmware.- Parameters:
errorDetectionType- error detection method- Throws:
NullPointerException- iferrorDetectionTypeis nullUnsupportedOperationException- if CRC is selected with firmware older than v3IllegalStateException- if this driver has been closed
-
setOffsets
public void setOffsets(double xOffsetMeters, double yOffsetMeters) Sets the odometry pod offsets in meters.The X pod offset is positive to the left of the tracking point. The Y pod offset is positive in front of the tracking point.
- Parameters:
xOffsetMeters- X pod offset in metersyOffsetMeters- Y pod offset in meters- Throws:
IllegalArgumentException- if either offset is nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setOffsets
Sets the odometry pod offsets.The X pod offset is positive to the left of the tracking point. The Y pod offset is positive in front of the tracking point.
- Parameters:
xOffset- X pod offsetyOffset- Y pod offset- Throws:
NullPointerException- if either offset is nullIllegalArgumentException- if either converted offset is nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
recalibrateImu
public void recalibrateImu()Recalibrates the IMU. The robot must remain stationary for approximately 0.25 seconds.- Throws:
IllegalStateException- if this driver has been closed
-
resetPositionAndImu
public void resetPositionAndImu()Resets the pose to the origin and recalibrates the IMU. The robot must remain stationary.- Throws:
IllegalStateException- if this driver has been closed
-
setEncoderDirections
public void setEncoderDirections(GoBildaPinpoint.EncoderDirection xEncoder, GoBildaPinpoint.EncoderDirection yEncoder) Sets the directions of both odometry pod encoders.- Parameters:
xEncoder- X (forward) pod directionyEncoder- Y (left) pod direction- Throws:
NullPointerException- if either direction is nullIllegalStateException- if this driver has been closed
-
setEncoderResolution
Sets the encoder resolution for a goBILDA odometry pod.- Parameters:
pod- odometry pod type- Throws:
NullPointerException- ifpodis nullIllegalStateException- if this driver has been closed
-
setEncoderResolution
public void setEncoderResolution(double ticksPerMeter) Sets a custom odometry pod encoder resolution.- Parameters:
ticksPerMeter- encoder ticks per meter of pod travel- Throws:
IllegalArgumentException- ifticksPerMeteris nonfinite, not positive, or does not produce a positive ticks-per-millimeter value representable by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setYawScalar
public void setYawScalar(double yawScalar) Sets the scalar applied to the IMU yaw measurement.- Parameters:
yawScalar- yaw scalar- Throws:
IllegalArgumentException- ifyawScalaris nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setPose
Overrides the pose tracked by the Pinpoint.- Parameters:
pose- pose in meters and radians- Throws:
NullPointerException- ifposeis nullIllegalArgumentException- if a pose component is nonfinite or cannot be represented by the device's 32-bit floating-point registersIllegalStateException- if this driver has been closed
-
setXPositionMeters
public void setXPositionMeters(double positionMeters) Overrides the tracked X position.- Parameters:
positionMeters- X position in meters- Throws:
IllegalArgumentException- ifpositionMetersis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setXPosition
Overrides the tracked X position.- Parameters:
position- X position- Throws:
NullPointerException- ifpositionis nullIllegalArgumentException- ifpositionis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setYPositionMeters
public void setYPositionMeters(double positionMeters) Overrides the tracked Y position.- Parameters:
positionMeters- Y position in meters- Throws:
IllegalArgumentException- ifpositionMetersis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setYPosition
Overrides the tracked Y position.- Parameters:
position- Y position- Throws:
NullPointerException- ifpositionis nullIllegalArgumentException- ifpositionis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setHeadingRadians
public void setHeadingRadians(double headingRadians) Overrides the tracked heading.- Parameters:
headingRadians- heading in radians- Throws:
IllegalArgumentException- ifheadingRadiansis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
setHeading
Overrides the tracked heading.- Parameters:
heading- heading- Throws:
NullPointerException- ifheadingis nullIllegalArgumentException- ifheadingis nonfinite or cannot be represented by the device's 32-bit floating-point registerIllegalStateException- if this driver has been closed
-
getDeviceId
public int getDeviceId()Returns the device identifier.- Returns:
- device identifier
- Throws:
IllegalStateException- if this driver has been closed
-
getDeviceVersion
public int getDeviceVersion()Returns the firmware version.- Returns:
- firmware version
- Throws:
IllegalStateException- if this driver has been closed
-
getYawScalar
public double getYawScalar()Returns the configured yaw scalar.- Returns:
- yaw scalar
- Throws:
IllegalStateException- if this driver has been closed
-
getEncoderResolutionTicksPerMeter
public double getEncoderResolutionTicksPerMeter()Returns the configured encoder resolution.- Returns:
- encoder ticks per meter
- Throws:
IllegalStateException- if this driver has been closed
-
getDeviceStatus
Returns the highest-priority current device or read status.- Returns:
- device status
- Throws:
IllegalStateException- if this driver has been closed
-
getDeviceStatusBits
public int getDeviceStatusBits()Returns the cached device status bits combined with the local bad-read status bit, if set.- Returns:
- status bits
- Throws:
IllegalStateException- if this driver has been closed
-
getLastFailedRegister
Returns the register associated with the most recent driver-detected failure.- Returns:
- failed register, or null if the driver has not detected a failure
- Throws:
IllegalStateException- if this driver has been closed
-
getLastFailureReason
Returns the reason for the most recent driver-detected failure.- Returns:
- failure reason, or null if the driver has not detected a failure
- Throws:
IllegalStateException- if this driver has been closed
-
getFailureCount
public long getFailureCount()Returns the total number of failures detected by this driver instance.- Returns:
- total failure count
- Throws:
IllegalStateException- if this driver has been closed
-
getFailureCount
Returns the number of failures associated with a register.- Parameters:
register- register whose failure count should be returned- Returns:
- failure count for the register
- Throws:
NullPointerException- ifregisteris nullIllegalStateException- if this driver has been closed
-
getLoopTimeMicroseconds
public int getLoopTimeMicroseconds()Returns the most recently reported device loop time.- Returns:
- loop time in microseconds
- Throws:
IllegalStateException- if this driver has been closed
-
getFrequencyHz
public double getFrequencyHz()Returns the most recently reported device loop frequency.- Returns:
- frequency in hertz, or zero when no loop time has been read
- Throws:
IllegalStateException- if this driver has been closed
-
getFrequency
Returns the most recently reported device loop frequency.- Returns:
- loop frequency, or zero when no loop time has been read
- Throws:
IllegalStateException- if this driver has been closed
-
getXEncoder
public int getXEncoder()Returns the raw X encoder count.- Returns:
- X encoder ticks
- Throws:
IllegalStateException- if this driver has been closed
-
getYEncoder
public int getYEncoder()Returns the raw Y encoder count.- Returns:
- Y encoder ticks
- Throws:
IllegalStateException- if this driver has been closed
-
getXPositionMeters
public double getXPositionMeters()Returns the tracked X position.- Returns:
- X position in meters
- Throws:
IllegalStateException- if this driver has been closed
-
getXPosition
Returns the tracked X position.- Returns:
- X position
- Throws:
IllegalStateException- if this driver has been closed
-
getYPositionMeters
public double getYPositionMeters()Returns the tracked Y position.- Returns:
- Y position in meters
- Throws:
IllegalStateException- if this driver has been closed
-
getYPosition
Returns the tracked Y position.- Returns:
- Y position
- Throws:
IllegalStateException- if this driver has been closed
-
getHeadingRadians
public double getHeadingRadians()Returns the continuous tracked heading.- Returns:
- heading in radians, not constrained to one rotation
- Throws:
IllegalStateException- if this driver has been closed
-
getHeading
Returns the continuous tracked heading.- Returns:
- heading, not constrained to one rotation
- Throws:
IllegalStateException- if this driver has been closed
-
getXVelocityMetersPerSecond
public double getXVelocityMetersPerSecond()Returns the tracked X velocity.- Returns:
- X velocity in meters per second
- Throws:
IllegalStateException- if this driver has been closed
-
getXVelocity
Returns the tracked X velocity.- Returns:
- X velocity
- Throws:
IllegalStateException- if this driver has been closed
-
getYVelocityMetersPerSecond
public double getYVelocityMetersPerSecond()Returns the tracked Y velocity.- Returns:
- Y velocity in meters per second
- Throws:
IllegalStateException- if this driver has been closed
-
getYVelocity
Returns the tracked Y velocity.- Returns:
- Y velocity
- Throws:
IllegalStateException- if this driver has been closed
-
getHeadingVelocityRadiansPerSecond
public double getHeadingVelocityRadiansPerSecond()Returns the heading velocity.- Returns:
- heading velocity in radians per second
- Throws:
IllegalStateException- if this driver has been closed
-
getHeadingVelocity
Returns the heading velocity.- Returns:
- heading velocity
- Throws:
IllegalStateException- if this driver has been closed
-
getXOffsetMeters
public double getXOffsetMeters()Returns the X pod offset.- Returns:
- X pod offset in meters
- Throws:
IllegalStateException- if this driver has been closed
-
getXOffset
Returns the X pod offset.- Returns:
- X pod offset
- Throws:
IllegalStateException- if this driver has been closed
-
getYOffsetMeters
public double getYOffsetMeters()Returns the Y pod offset.- Returns:
- Y pod offset in meters
- Throws:
IllegalStateException- if this driver has been closed
-
getYOffset
Returns the Y pod offset.- Returns:
- Y pod offset
- Throws:
IllegalStateException- if this driver has been closed
-
getPose
Returns the tracked pose. Translation is in meters; heading is normalized byRotation2d.If the configured bulk-read scope does not contain all three pose registers, this reads X, Y, and heading together so the returned components are from the same device snapshot.
- Returns:
- tracked pose
- Throws:
IllegalStateException- if this driver has been closed
-
getQuaternion
Returns the device orientation quaternion. Requires v3 or newer firmware. If the configured bulk-read scope does not contain all four quaternion registers, this reads all four components together so they come from the same device snapshot.- Returns:
- orientation quaternion
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-
getRotation3d
Returns the device orientation as a 3D rotation. Requires v3 or newer firmware.- Returns:
- 3D orientation
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-
getPitchRadians
public double getPitchRadians()Returns the pitch. Requires v3 or newer firmware.- Returns:
- pitch in radians
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-
getPitch
Returns the pitch. Requires v3 or newer firmware.- Returns:
- pitch
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-
getRollRadians
public double getRollRadians()Returns the roll. Requires v3 or newer firmware.- Returns:
- roll in radians
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-
getRoll
Returns the roll. Requires v3 or newer firmware.- Returns:
- roll
- Throws:
IllegalStateException- if this driver has been closedUnsupportedOperationException- if the firmware is older than v3
-