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, velocityFields 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 TypeMethodDescriptiondoubleThis method reads the absolute position of the encoder.doubleThis method reads the raw encoder velocity in encoder units per second.doubleThis method returns the encoder position adjusted by scale and offset.doubleThis method returns the encoder velocity adjusted by scale.booleanThis method checks if the encoder direction is inverted.voidreset()This method resets the encoder position.voidsetInverted(boolean inverted) This method reverses the direction of the encoder.voidsetScaleAndOffset(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, zeroAllMethods 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:
toStringin classcom.reduxrobotics.canand.CanandDevice- Returns:
- instance name.
-
reset
public void reset()This method resets the encoder position.- Specified by:
resetin interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method reads the absolute position of the encoder.- Specified by:
getRawPositionin 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:
getScaledPositionin 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:
getRawVelocityin 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:
getScaledVelocityin interfaceTrcEncoder- Returns:
- encoder velocity adjusted by scale.
-
setInverted
public void setInverted(boolean inverted) This method reverses the direction of the encoder.- Specified by:
setInvertedin 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:
isInvertedin 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:
setScaleAndOffsetin interfaceTrcEncoder- Parameters:
scale- specifies the scale value.offset- specifies the offset value.zeroOffset- specifies the zero offset for absolute encoder.
-