Package frclib.sensor
Class FrcCanandmag
java.lang.Object
com.reduxrobotics.canand.CanandDevice
com.reduxrobotics.sensors.canandmag.Canandmag
frclib.sensor.FrcCanandmag
- All Implemented Interfaces:
AutoCloseable
,TrcEncoder
public class FrcCanandmag
extends com.reduxrobotics.sensors.canandmag.Canandmag
implements TrcEncoder
This class extends Canandmag and implements the FrcEncoder interface to allow compatibility to other types of
encoders.
-
Field Summary
Fields inherited from class com.reduxrobotics.sensors.canandmag.Canandmag
absPosition, kCountsPerRotation, kCountsPerRotationPerSecond, position, status, velocity
Fields inherited from class com.reduxrobotics.canand.CanandDevice
lastMessageTs
-
Constructor Summary
ConstructorsConstructorDescriptionFrcCanandmag
(String instanceName, int canId) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
This method reads the absolute position of the encoder.double
This method reads the raw encoder velocity in encoder units per second.double
This method returns the encoder position adjusted by scale and offset.double
This method returns the encoder velocity adjusted by scale.boolean
This method checks if the encoder direction is inverted.void
reset()
This method resets the encoder position.void
setInverted
(boolean inverted) This method reverses the direction of the encoder.void
setScaleAndOffset
(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.toString()
This method returns the instance name.Methods inherited from class com.reduxrobotics.sensors.canandmag.Canandmag
clearStickyFaults, getAbsPosition, getAbsPositionFrame, getActiveFaults, getAddress, getInternalSettingsManager, getMinimumFirmwareVersion, getPosition, getPositionFrame, getSettings, getSettings, getSettings, getSettingsAsync, getStatus, getStatusFrame, getStickyFaults, getTemperature, getVelocity, getVelocityFrame, handleMessage, magnetInRange, resetFactoryDefaults, resetFactoryDefaults, setAbsPosition, setAbsPosition, setAbsPosition, setPartyMode, setPosition, setPosition, setSettings, setSettings, setSettings, startFetchSettings, zeroAll, zeroAll
Methods inherited from class com.reduxrobotics.canand.CanandDevice
checkReceivedFirmwareVersion, close, getFirmwareVersion, isConnected, isConnected, preHandleMessage, sendCANMessage, sendCANMessage
-
Constructor Details
-
FrcCanandmag
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.canId
- specifies the CAN ID of the encoder.
-
-
Method Details
-
toString
This method returns the instance name.- Overrides:
toString
in classcom.reduxrobotics.canand.CanandDevice
- Returns:
- instance name.
-
reset
public void reset()This method resets the encoder position.- Specified by:
reset
in interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method reads the absolute position of the encoder.- Specified by:
getRawPosition
in interfaceTrcEncoder
- Returns:
- absolute position of the encoder in the range of [0.0, 1.0).
-
getScaledPosition
public double getScaledPosition()This method returns the encoder position adjusted by scale and offset.- Specified by:
getScaledPosition
in interfaceTrcEncoder
- Returns:
- encoder position adjusted by scale and offset.
-
getRawVelocity
public double getRawVelocity()This method reads the raw encoder velocity in encoder units per second.- Specified by:
getRawVelocity
in interfaceTrcEncoder
- Returns:
- raw encoder velocity in encoder units per second.
-
getScaledVelocity
public double getScaledVelocity()This method returns the encoder velocity adjusted by scale.- Specified by:
getScaledVelocity
in interfaceTrcEncoder
- Returns:
- encoder velocity adjusted by scale.
-
setInverted
public void setInverted(boolean inverted) This method reverses the direction of the encoder.- Specified by:
setInverted
in interfaceTrcEncoder
- Parameters:
inverted
- specifies true to reverse the encoder direction, false otherwise.
-
isInverted
public boolean isInverted()This method checks if the encoder direction is inverted.- Specified by:
isInverted
in interfaceTrcEncoder
- Returns:
- true if encoder direction is rerversed, false otherwise.
-
setScaleAndOffset
public void setScaleAndOffset(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.- Specified by:
setScaleAndOffset
in interfaceTrcEncoder
- Parameters:
scale
- specifies the scale value.offset
- specifies the offset value.zeroOffset
- specifies the zero offset for absolute encoder.
-