CTRE_Phoenix 5.20.2
com.ctre.phoenix.sensors.CANCoder Class Reference

Inherited by com.ctre.phoenix.sensors.WPI_CANCoder.

Public Member Functions

 CANCoder (int deviceNumber, String canbus)
 
 CANCoder (int deviceNumber)
 
ErrorCode DestroyObject ()
 
int getDeviceID ()
 
CANCoderSimCollection getSimCollection ()
 
double getPosition ()
 
ErrorCode setPosition (double newPosition, int timeoutMs)
 
ErrorCode setPosition (double newPosition)
 
ErrorCode setPositionToAbsolute (int timeoutMs)
 
ErrorCode setPositionToAbsolute ()
 
double getVelocity ()
 
double getAbsolutePosition ()
 
ErrorCode configVelocityMeasurementPeriod (SensorVelocityMeasPeriod period, int timeoutMs)
 
ErrorCode configVelocityMeasurementPeriod (SensorVelocityMeasPeriod period)
 
ErrorCode configVelocityMeasurementWindow (int windowSize, int timeoutMs)
 
ErrorCode configVelocityMeasurementWindow (int windowSize)
 
ErrorCode configAbsoluteSensorRange (AbsoluteSensorRange absoluteSensorRange, int timeoutMs)
 
ErrorCode configAbsoluteSensorRange (AbsoluteSensorRange absoluteSensorRange)
 
ErrorCode configMagnetOffset (double offsetDegrees, int timeoutMs)
 
ErrorCode configMagnetOffset (double offsetDegrees)
 
ErrorCode configSensorInitializationStrategy (SensorInitializationStrategy initializationStrategy, int timeoutMs)
 
ErrorCode configSensorInitializationStrategy (SensorInitializationStrategy initializationStrategy)
 
ErrorCode configFeedbackCoefficient (double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase, int timeoutMs)
 
ErrorCode configFeedbackCoefficient (double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase)
 
double getBusVoltage ()
 
MagnetFieldStrength getMagnetFieldStrength ()
 
ErrorCode configSensorDirection (boolean bSensorDirection, int timeoutMs)
 
ErrorCode configSensorDirection (boolean bSensorDirection)
 
ErrorCode getLastError ()
 
String getLastUnitString ()
 
double getLastTimestamp ()
 
ErrorCode configSetCustomParam (int newValue, int paramIndex, int timeoutMs)
 
ErrorCode configSetCustomParam (int newValue, int paramIndex)
 
int configGetCustomParam (int paramIndex, int timeoutMs)
 
int configGetCustomParam (int paramIndex)
 
ErrorCode configSetParameter (ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)
 
ErrorCode configSetParameter (ParamEnum param, double value, int subValue, int ordinal)
 
double configGetParameter (ParamEnum param, int ordinal, int timeoutMs)
 
double configGetParameter (ParamEnum param, int ordinal)
 
ErrorCode setStatusFramePeriod (CANCoderStatusFrame statusFrame, int periodMs, int timeoutMs)
 
ErrorCode setStatusFramePeriod (CANCoderStatusFrame statusFrame, int periodMs)
 
int getStatusFramePeriod (CANCoderStatusFrame frame, int timeoutMs)
 
int getStatusFramePeriod (CANCoderStatusFrame frame)
 
int getFirmwareVersion ()
 
boolean hasResetOccurred ()
 
ErrorCode getFaults (CANCoderFaults toFill)
 
ErrorCode getStickyFaults (CANCoderStickyFaults toFill)
 
ErrorCode clearStickyFaults (int timeoutMs)
 
ErrorCode clearStickyFaults ()
 
SensorVelocityMeasPeriod configGetVelocityMeasurementPeriod (int timeoutMs)
 
SensorVelocityMeasPeriod configGetVelocityMeasurementPeriod ()
 
int configGetVelocityMeasurementWindow (int timeoutMs)
 
int configGetVelocityMeasurementWindow ()
 
AbsoluteSensorRange configGetAbsoluteSensorRange (int timeoutMs)
 
AbsoluteSensorRange configGetAbsoluteSensorRange ()
 
double configGetMagnetOffset (int timeoutMs)
 
double configGetMagnetOffset ()
 
boolean configGetSensorDirection (int timeoutMs)
 
boolean configGetSensorDirection ()
 
SensorInitializationStrategy configGetSensorInitializationStrategy (int timeoutMs)
 
SensorInitializationStrategy configGetSensorInitializationStrategy ()
 
double configGetFeedbackCoefficient (int timeoutMs)
 
double configGetFeedbackCoefficient ()
 
String configGetFeedbackUnitString (int timeoutMs)
 
String configGetFeedbackUnitString ()
 
SensorTimeBase configGetFeedbackTimeBase (int timeoutMs)
 
SensorTimeBase configGetFeedbackTimeBase ()
 
ErrorCode configAllSettings (CANCoderConfiguration allConfigs, int timeoutMs)
 
ErrorCode configAllSettings (CANCoderConfiguration allConfigs)
 
void getAllConfigs (CANCoderConfiguration allConfigs, int timeoutMs)
 
void getAllConfigs (CANCoderConfiguration allConfigs)
 
ErrorCode configFactoryDefault (int timeoutMs)
 
ErrorCode configFactoryDefault ()
 

Detailed Description

CTRE CANCoder.


// Example usage of a CANCoder
CANCoder cancoder = new CANCoder(0); // creates a new CANCoder with ID 0

CANCoderConfiguration config = new CANCoderConfiguration();
// set units of the CANCoder to radians, with velocity being radians per second
config.sensorCoefficient = 2 * Math.PI / 4096.0;
config.unitString = "rad";
config.sensorTimeBase = SensorTimeBase.PerSecond;
cancoder.configAllSettings(config);

System.out.println(cancoder.getPosition()); // prints the position of the CANCoder
System.out.println(cancoder.getVelocity()); // prints the velocity recorded by the CANCoder

ErrorCode error = cancoder.getLastError(); // gets the last error generated by the CANCoder
CANCoderFaults faults = new CANCoderFaults();
ErrorCode faultsError = cancoder.getFaults(faults); // fills faults with the current CANCoder faults; returns the last error generated

cancoder.setStatusFramePeriod(CANCoderStatusFrame.SensorData, 10); // changes the period of the sensor data frame to 10ms

Constructor & Destructor Documentation

◆ CANCoder() [1/2]

com.ctre.phoenix.sensors.CANCoder.CANCoder ( int  deviceNumber,
String  canbus 
)
inline

Constructor.

Parameters
deviceNumberThe CAN Device ID of the CANCoder.
canbusName of the CANbus; can be a SocketCAN interface (on Linux), or a CANivore device name or serial number

◆ CANCoder() [2/2]

com.ctre.phoenix.sensors.CANCoder.CANCoder ( int  deviceNumber)
inline

Constructor.

Parameters
deviceNumberThe CAN Device ID of the CANCoder.

Member Function Documentation

◆ clearStickyFaults() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.clearStickyFaults ( )
inline

Clears the Sticky Faults

Returns
Error Code generated by function. 0 indicates no error.

◆ clearStickyFaults() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.clearStickyFaults ( int  timeoutMs)
inline

Clears the Sticky Faults

Returns
Error Code generated by function. 0 indicates no error.

◆ configAbsoluteSensorRange() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configAbsoluteSensorRange ( AbsoluteSensorRange  absoluteSensorRange)
inline

Sets the signage and range of the "Absolute Position" signal. Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc... Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...

Parameters
absoluteSensorRangeDesired Sign/Range for the absolute position register.
Returns
Error Code generated by function. 0 indicates no error.

◆ configAbsoluteSensorRange() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configAbsoluteSensorRange ( AbsoluteSensorRange  absoluteSensorRange,
int  timeoutMs 
)
inline

Sets the signage and range of the "Absolute Position" signal. Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc... Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...

Parameters
absoluteSensorRangeDesired Sign/Range for the absolute position register.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configAllSettings() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configAllSettings ( CANCoderConfiguration  allConfigs)
inline

Configures all persistent settings (overloaded so timeoutMs is 50 ms).

Parameters
allConfigsObject with all of the persistant settings
Returns
Error Code generated by function. 0 indicates no error.

◆ configAllSettings() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configAllSettings ( CANCoderConfiguration  allConfigs,
int  timeoutMs 
)
inline

Configures all persistent settings.

Parameters
allConfigsObject with all of the persistant settings
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configFactoryDefault() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configFactoryDefault ( )
inline

Configures all persistent settings to defaults.

Returns
Error Code generated by function. 0 indicates no error.

◆ configFactoryDefault() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configFactoryDefault ( int  timeoutMs)
inline

Configures all persistent settings to defaults.

Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configFeedbackCoefficient() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configFeedbackCoefficient ( double  sensorCoefficient,
String  unitString,
SensorTimeBase  sensorTimeBase 
)
inline

Choose what units you want the API to get/set. This also impacts the units displayed in Self-Test in Tuner. Depending on your mechanism, you may want to scale rotational units (deg, radians, rotations), or scale to a distance (inches, centimeters).

Parameters
sensorCoefficientScalar to multiply the CANCoder's native 12-bit resolute sensor. Defaults to 0.087890625 to produce degrees.
unitStringString holding the unit to report in. This impacts all routines (except for ConfigMagnetOffset) and the self-test in Tuner. The string value itself is arbitrary. The max number of letters will depend on firmware versioning, but generally CANCoder supports up to eight letters. However, common units such as "centimeters" are supported explicitly despite exceeding the eight-letter limit. Default is "deg"
sensorTimeBaseDesired denominator to report velocity in. This impacts GetVelocity and the reported velocity in self-test in Tuner. Default is "Per Second".
Returns
Error Code generated by function. 0 indicates no error.

◆ configFeedbackCoefficient() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configFeedbackCoefficient ( double  sensorCoefficient,
String  unitString,
SensorTimeBase  sensorTimeBase,
int  timeoutMs 
)
inline

Choose what units you want the API to get/set. This also impacts the units displayed in Self-Test in Tuner. Depending on your mechanism, you may want to scale rotational units (deg, radians, rotations), or scale to a distance (inches, centimeters).

Parameters
sensorCoefficientScalar to multiply the CANCoder's native 12-bit resolute sensor. Defaults to 0.087890625 to produce degrees.
unitStringString holding the unit to report in. This impacts all routines (except for ConfigMagnetOffset) and the self-test in Tuner. The string value itself is arbitrary. The max number of letters will depend on firmware versioning, but generally CANCoder supports up to eight letters. However, common units such as "centimeters" are supported explicitly despite exceeding the eight-letter limit. Default is "deg"
sensorTimeBaseDesired denominator to report velocity in. This impacts GetVelocity and the reported velocity in self-test in Tuner. Default is "Per Second".
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configGetAbsoluteSensorRange() [1/2]

AbsoluteSensorRange com.ctre.phoenix.sensors.CANCoder.configGetAbsoluteSensorRange ( )
inline
Returns
Read value of the config param.

◆ configGetAbsoluteSensorRange() [2/2]

AbsoluteSensorRange com.ctre.phoenix.sensors.CANCoder.configGetAbsoluteSensorRange ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetCustomParam() [1/2]

int com.ctre.phoenix.sensors.CANCoder.configGetCustomParam ( int  paramIndex)
inline

Gets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
Returns
Value of the custom param.

◆ configGetCustomParam() [2/2]

int com.ctre.phoenix.sensors.CANCoder.configGetCustomParam ( int  paramIndex,
int  timeoutMs 
)
inline

Gets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Value of the custom param.

◆ configGetFeedbackCoefficient() [1/2]

double com.ctre.phoenix.sensors.CANCoder.configGetFeedbackCoefficient ( )
inline
Returns
Read value of the config param.

◆ configGetFeedbackCoefficient() [2/2]

double com.ctre.phoenix.sensors.CANCoder.configGetFeedbackCoefficient ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetFeedbackTimeBase() [1/2]

SensorTimeBase com.ctre.phoenix.sensors.CANCoder.configGetFeedbackTimeBase ( )
inline
Returns
Read value of the config param.

◆ configGetFeedbackTimeBase() [2/2]

SensorTimeBase com.ctre.phoenix.sensors.CANCoder.configGetFeedbackTimeBase ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetFeedbackUnitString() [1/2]

String com.ctre.phoenix.sensors.CANCoder.configGetFeedbackUnitString ( )
inline
Returns
Read value of the config param.

◆ configGetFeedbackUnitString() [2/2]

String com.ctre.phoenix.sensors.CANCoder.configGetFeedbackUnitString ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetMagnetOffset() [1/2]

double com.ctre.phoenix.sensors.CANCoder.configGetMagnetOffset ( )
inline
Returns
Read value of the config param.

◆ configGetMagnetOffset() [2/2]

double com.ctre.phoenix.sensors.CANCoder.configGetMagnetOffset ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetParameter() [1/2]

double com.ctre.phoenix.sensors.CANCoder.configGetParameter ( ParamEnum  param,
int  ordinal 
)
inline

Gets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
ordinalOrdinal of parameter.
Returns
Value of parameter.

◆ configGetParameter() [2/2]

double com.ctre.phoenix.sensors.CANCoder.configGetParameter ( ParamEnum  param,
int  ordinal,
int  timeoutMs 
)
inline

Gets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
ordinalOrdinal of parameter.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Value of parameter.

◆ configGetSensorDirection() [1/2]

boolean com.ctre.phoenix.sensors.CANCoder.configGetSensorDirection ( )
inline
Returns
Read value of the config param.

◆ configGetSensorDirection() [2/2]

boolean com.ctre.phoenix.sensors.CANCoder.configGetSensorDirection ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetSensorInitializationStrategy() [1/2]

SensorInitializationStrategy com.ctre.phoenix.sensors.CANCoder.configGetSensorInitializationStrategy ( )
inline
Returns
Read value of the config param.

◆ configGetSensorInitializationStrategy() [2/2]

SensorInitializationStrategy com.ctre.phoenix.sensors.CANCoder.configGetSensorInitializationStrategy ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetVelocityMeasurementPeriod() [1/2]

SensorVelocityMeasPeriod com.ctre.phoenix.sensors.CANCoder.configGetVelocityMeasurementPeriod ( )
inline
Returns
Read value of the config param.

◆ configGetVelocityMeasurementPeriod() [2/2]

SensorVelocityMeasPeriod com.ctre.phoenix.sensors.CANCoder.configGetVelocityMeasurementPeriod ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configGetVelocityMeasurementWindow() [1/2]

int com.ctre.phoenix.sensors.CANCoder.configGetVelocityMeasurementWindow ( )
inline
Returns
Read value of the config param.

◆ configGetVelocityMeasurementWindow() [2/2]

int com.ctre.phoenix.sensors.CANCoder.configGetVelocityMeasurementWindow ( int  timeoutMs)
inline
Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
Returns
Read value of the config param.

◆ configMagnetOffset() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configMagnetOffset ( double  offsetDegrees)
inline

Adjusts the zero point for the absolute position register. The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180) and a hard-limited mechanism may have such a discontinuity in its functional range. In which case use this config to move the discontinuity outside of the function range.

Parameters
offsetDegreesOffset in degrees (unit string and coefficient DO NOT apply for this config).
Returns
Error Code generated by function. 0 indicates no error.

◆ configMagnetOffset() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configMagnetOffset ( double  offsetDegrees,
int  timeoutMs 
)
inline

Adjusts the zero point for the absolute position register. The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180) and a hard-limited mechanism may have such a discontinuity in its functional range. In which case use this config to move the discontinuity outside of the function range.

Parameters
offsetDegreesOffset in degrees (unit string and coefficient DO NOT apply for this config).
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSensorDirection() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSensorDirection ( boolean  bSensorDirection)
inline

Choose which direction is interpreted as positive displacement. This affects both "Position" and "Absolute Position".

Parameters
bSensorDirectionFalse (default) means positive rotation occurs when magnet is spun counter-clockwise when observer is facing the LED side of CANCoder.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSensorDirection() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSensorDirection ( boolean  bSensorDirection,
int  timeoutMs 
)
inline

Choose which direction is interpreted as positive displacement. This affects both "Position" and "Absolute Position".

Parameters
bSensorDirectionFalse (default) means positive rotation occurs when magnet is spun counter-clockwise when observer is facing the LED side of CANCoder.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSensorInitializationStrategy() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSensorInitializationStrategy ( SensorInitializationStrategy  initializationStrategy)
inline

Pick the strategy on how to initialize the CANCoder's "Position" register. Depending on the mechanism, it may be desirable to auto set the Position register to match the Absolute Position (swerve for example). Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo).

TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the CANCoder is reset.

Parameters
initializationStrategyThe sensor initialization strategy to use. This will impact the behavior the next time CANCoder boots up.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSensorInitializationStrategy() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSensorInitializationStrategy ( SensorInitializationStrategy  initializationStrategy,
int  timeoutMs 
)
inline

Pick the strategy on how to initialize the CANCoder's "Position" register. Depending on the mechanism, it may be desirable to auto set the Position register to match the Absolute Position (swerve for example). Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo).

TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the CANCoder is reset.

Parameters
initializationStrategyThe sensor initialization strategy to use. This will impact the behavior the next time CANCoder boots up.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetCustomParam() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSetCustomParam ( int  newValue,
int  paramIndex 
)
inline

Sets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
newValueValue for custom parameter.
paramIndexIndex of custom parameter. [0-1]
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetCustomParam() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSetCustomParam ( int  newValue,
int  paramIndex,
int  timeoutMs 
)
inline

Sets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
newValueValue for custom parameter.
paramIndexIndex of custom parameter. [0-1]
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetParameter() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSetParameter ( ParamEnum  param,
double  value,
int  subValue,
int  ordinal 
)
inline

Sets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
valueValue of parameter.
subValueSubvalue for parameter. Maximum value of 255.
ordinalOrdinal of parameter.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetParameter() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configSetParameter ( ParamEnum  param,
double  value,
int  subValue,
int  ordinal,
int  timeoutMs 
)
inline

Sets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
valueValue of parameter.
subValueSubvalue for parameter. Maximum value of 255.
ordinalOrdinal of parameter.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configVelocityMeasurementPeriod() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configVelocityMeasurementPeriod ( SensorVelocityMeasPeriod  period)
inline

Configures the period of each velocity sample. Every 1ms a position value is sampled, and the delta between that sample and the position sampled kPeriod ms ago is inserted into a filter. kPeriod is configured with this function.

Parameters
periodDesired period for the velocity measurement.
Returns
Error Code generated by function. 0 indicates no error.

◆ configVelocityMeasurementPeriod() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configVelocityMeasurementPeriod ( SensorVelocityMeasPeriod  period,
int  timeoutMs 
)
inline

Configures the period of each velocity sample. Every 1ms a position value is sampled, and the delta between that sample and the position sampled kPeriod ms ago is inserted into a filter. kPeriod is configured with this function.

Parameters
periodDesired period for the velocity measurement.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configVelocityMeasurementWindow() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configVelocityMeasurementWindow ( int  windowSize)
inline

Sets the number of velocity samples used in the rolling average velocity measurement.

Parameters
windowSizeNumber of samples in the rolling average of velocity measurement. Valid values are 1,2,4,8,16,32. If another value is specified, it will truncate to nearest support value.
Returns
Error Code generated by function. 0 indicates no error.

◆ configVelocityMeasurementWindow() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.configVelocityMeasurementWindow ( int  windowSize,
int  timeoutMs 
)
inline

Sets the number of velocity samples used in the rolling average velocity measurement.

Parameters
windowSizeNumber of samples in the rolling average of velocity measurement. Valid values are 1,2,4,8,16,32. If another value is specified, it will truncate to nearest support value.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ getAbsolutePosition()

double com.ctre.phoenix.sensors.CANCoder.getAbsolutePosition ( )
inline

Gets the absolute position of the sensor. The absolute position may be unsigned (for example: [0,360) deg), or signed (for example: [-180,+180) deg). This is determined by a configuration. The default selection is unsigned. The units are determined by the coefficient and unit-string configuration params, default is degrees. Note: this signal is not affected by calls to SetPosition().

Returns
The position of the sensor.

◆ getAllConfigs() [1/2]

void com.ctre.phoenix.sensors.CANCoder.getAllConfigs ( CANCoderConfiguration  allConfigs)
inline

Gets all persistant settings (overloaded so timeoutMs is 50 ms).

Parameters
allConfigsObject with all of the persistant settings

◆ getAllConfigs() [2/2]

void com.ctre.phoenix.sensors.CANCoder.getAllConfigs ( CANCoderConfiguration  allConfigs,
int  timeoutMs 
)
inline

Gets all persistant settings.

Parameters
allConfigsObject with all of the persistant settings
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.

◆ getBusVoltage()

double com.ctre.phoenix.sensors.CANCoder.getBusVoltage ( )
inline

Gets the bus voltage seen by the device.

Returns
The bus voltage value (in volts).

◆ getFaults()

ErrorCode com.ctre.phoenix.sensors.CANCoder.getFaults ( CANCoderFaults  toFill)
inline

Gets the CANCoder fault status

Parameters
toFillContainer for fault statuses.
Returns
Error Code generated by function. 0 indicates no error.

◆ getFirmwareVersion()

int com.ctre.phoenix.sensors.CANCoder.getFirmwareVersion ( )
inline

Gets the firmware version of the device.

Returns
Firmware version of device.

◆ getLastError()

ErrorCode com.ctre.phoenix.sensors.CANCoder.getLastError ( )
inline

Call GetLastError() generated by this object. Not all functions return an error code but can potentially report errors.

This function can be used to retrieve those error codes.

Returns
The last ErrorCode generated.

◆ getLastTimestamp()

double com.ctre.phoenix.sensors.CANCoder.getLastTimestamp ( )
inline

Get the timestamp of the CAN frame retrieved in the last called get routine.

◆ getLastUnitString()

String com.ctre.phoenix.sensors.CANCoder.getLastUnitString ( )
inline

Get the units for the signal retrieved in the last called get routine.

◆ getMagnetFieldStrength()

MagnetFieldStrength com.ctre.phoenix.sensors.CANCoder.getMagnetFieldStrength ( )
inline

Gets the magnet's health.

Returns
The magnet health code (red/orange/green).

◆ getPosition()

double com.ctre.phoenix.sensors.CANCoder.getPosition ( )
inline

Gets the position of the sensor. This may be relative or absolute depending on configuration. The units are determined by the coefficient and unit-string configuration params, default is degrees.

Returns
The position of the sensor.

◆ getSimCollection()

CANCoderSimCollection com.ctre.phoenix.sensors.CANCoder.getSimCollection ( )
inline
Returns
object that can set simulation inputs.

◆ getStatusFramePeriod() [1/2]

int com.ctre.phoenix.sensors.CANCoder.getStatusFramePeriod ( CANCoderStatusFrame  frame)
inline

Gets the period of the given status frame.

Parameters
frameFrame to get the period of.
Returns
Period of the given status frame.

◆ getStatusFramePeriod() [2/2]

int com.ctre.phoenix.sensors.CANCoder.getStatusFramePeriod ( CANCoderStatusFrame  frame,
int  timeoutMs 
)
inline

Gets the period of the given status frame.

Parameters
frameFrame to get the period of.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Period of the given status frame.

◆ getStickyFaults()

ErrorCode com.ctre.phoenix.sensors.CANCoder.getStickyFaults ( CANCoderStickyFaults  toFill)
inline

Gets the CANCoder sticky fault status

Parameters
toFillContainer for sticky fault statuses.
Returns
Error Code generated by function. 0 indicates no error.

◆ getVelocity()

double com.ctre.phoenix.sensors.CANCoder.getVelocity ( )
inline

Gets the velocity of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees per second.

Returns
The Velocity of the sensor.

◆ hasResetOccurred()

boolean com.ctre.phoenix.sensors.CANCoder.hasResetOccurred ( )
inline

Returns true if the device has reset since last call.

Returns
Has a Device Reset Occurred?

◆ setPosition() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setPosition ( double  newPosition)
inline

Sets the position of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees.

Parameters
newPosition
Returns
ErrorCode generated by function. 0 indicates no error.

◆ setPosition() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setPosition ( double  newPosition,
int  timeoutMs 
)
inline

Sets the position of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees.

Parameters
newPosition
Returns
ErrorCode generated by function. 0 indicates no error.

◆ setPositionToAbsolute() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setPositionToAbsolute ( )
inline

Sets the position of the sensor to match the magnet's "Absolute Sensor". The units are determined by the coefficient and unit-string configuration params, default is degrees.

Returns
ErrorCode generated by function. 0 indicates no error.

◆ setPositionToAbsolute() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setPositionToAbsolute ( int  timeoutMs)
inline

Sets the position of the sensor to match the magnet's "Absolute Sensor". The units are determined by the coefficient and unit-string configuration params, default is degrees.

Returns
ErrorCode generated by function. 0 indicates no error.

◆ setStatusFramePeriod() [1/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setStatusFramePeriod ( CANCoderStatusFrame  statusFrame,
int  periodMs 
)
inline

Sets the period of the given status frame.

Parameters
statusFrameFrame whose period is to be changed.
periodMsPeriod in ms for the given frame.
Returns
Error Code generated by function. 0 indicates no error.

◆ setStatusFramePeriod() [2/2]

ErrorCode com.ctre.phoenix.sensors.CANCoder.setStatusFramePeriod ( CANCoderStatusFrame  statusFrame,
int  periodMs,
int  timeoutMs 
)
inline

Sets the period of the given status frame.

Parameters
statusFrameFrame whose period is to be changed.
periodMsPeriod in ms for the given frame.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

The documentation for this class was generated from the following file: