CTRE_Phoenix 5.20.2
com.ctre.phoenix.motorcontrol.SensorCollection Class Reference

Public Member Functions

 SensorCollection (BaseTalon motorController)
 
int getAnalogIn ()
 
ErrorCode setAnalogPosition (int newPosition, int timeoutMs)
 
int getAnalogInRaw ()
 
int getAnalogInVel ()
 
int getQuadraturePosition ()
 
ErrorCode setQuadraturePosition (int newPosition, int timeoutMs)
 
ErrorCode syncQuadratureWithPulseWidth (int bookend0, int bookend1, boolean bCrossZeroOnInterval, int offset, int timeoutMs)
 
ErrorCode syncQuadratureWithPulseWidth (int bookend0, int bookend1, boolean bCrossZeroOnInterval)
 
int getQuadratureVelocity ()
 
int getPulseWidthPosition ()
 
ErrorCode setPulseWidthPosition (int newPosition, int timeoutMs)
 
int getPulseWidthVelocity ()
 
int getPulseWidthRiseToFallUs ()
 
int getPulseWidthRiseToRiseUs ()
 
boolean getPinStateQuadA ()
 
boolean getPinStateQuadB ()
 
boolean getPinStateQuadIdx ()
 
boolean isFwdLimitSwitchClosed ()
 
boolean isRevLimitSwitchClosed ()
 

Detailed Description

Collection of sensors available to a motor controller.

For best performance and update-rate, we recommend using the configSelectedFeedbackSensor() and getSelectedSensor*() routines. However there are occasions where accessing raw sensor values may be useful or convenient. Particularly if you are seeding one sensor based on another, or need to circumvent sensor-phase.

Use the getSensorCollection() routine inside your motor controller to create a sensor collection.

Constructor & Destructor Documentation

◆ SensorCollection()

com.ctre.phoenix.motorcontrol.SensorCollection.SensorCollection ( BaseTalon  motorController)
inline

Constructor for SensorCollection

Parameters
motorControllerMotor Controller to connect Collection to

Member Function Documentation

◆ getAnalogIn()

int com.ctre.phoenix.motorcontrol.SensorCollection.getAnalogIn ( )
inline

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

This method relies on the Status 4 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the 24bit analog value. The bottom ten bits is the ADC (0 - 1023) on the analog pin of the Talon. The upper 14 bits tracks the overflows and underflows (continuous sensor).

◆ getAnalogInRaw()

int com.ctre.phoenix.motorcontrol.SensorCollection.getAnalogInRaw ( )
inline

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

This method relies on the Status 4 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the ADC (0 - 1023) on analog pin of the Talon.

◆ getAnalogInVel()

int com.ctre.phoenix.motorcontrol.SensorCollection.getAnalogInVel ( )
inline

Get the velocity of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

This method relies on the Status 4 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the speed in units per 100ms where 1024 units is one rotation.

◆ getPinStateQuadA()

boolean com.ctre.phoenix.motorcontrol.SensorCollection.getPinStateQuadA ( )
inline

Gets pin state quad a.

This method relies on the Status 3 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the pin state of quad a (1 if asserted, 0 if not asserted).

◆ getPinStateQuadB()

boolean com.ctre.phoenix.motorcontrol.SensorCollection.getPinStateQuadB ( )
inline

Gets pin state quad b.

This method relies on the Status 3 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
Digital level of QUADB pin (1 if asserted, 0 if not asserted).

◆ getPinStateQuadIdx()

boolean com.ctre.phoenix.motorcontrol.SensorCollection.getPinStateQuadIdx ( )
inline

Gets pin state quad index.

This method relies on the Status 3 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
Digital level of QUAD Index pin (1 if asserted, 0 if not asserted).

◆ getPulseWidthPosition()

int com.ctre.phoenix.motorcontrol.SensorCollection.getPulseWidthPosition ( )
inline

Gets pulse width position, regardless of whether it is actually being used for feedback.

This method relies on the Status 8 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the pulse width position.

◆ getPulseWidthRiseToFallUs()

int com.ctre.phoenix.motorcontrol.SensorCollection.getPulseWidthRiseToFallUs ( )
inline

Gets pulse width rise to fall time.

This method relies on the Status 8 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the pulse width rise to fall time in microseconds.

◆ getPulseWidthRiseToRiseUs()

int com.ctre.phoenix.motorcontrol.SensorCollection.getPulseWidthRiseToRiseUs ( )
inline

Gets pulse width rise to rise time.

This method relies on the Status 8 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the pulse width rise to rise time in microseconds.

◆ getPulseWidthVelocity()

int com.ctre.phoenix.motorcontrol.SensorCollection.getPulseWidthVelocity ( )
inline

Gets pulse width velocity, regardless of whether it is actually being used for feedback.

This method relies on the Status 8 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the pulse width velocity in units per 100ms (where 4096 units is 1 rotation).

◆ getQuadraturePosition()

int com.ctre.phoenix.motorcontrol.SensorCollection.getQuadraturePosition ( )
inline

Get the quadrature position of the Talon, regardless of whether it is actually being used for feedback.

This method relies on the Status 3 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the quadrature position.

◆ getQuadratureVelocity()

int com.ctre.phoenix.motorcontrol.SensorCollection.getQuadratureVelocity ( )
inline

Get the quadrature velocity, regardless of whether it is actually being used for feedback.

This method relies on the Status 3 message, which has a default period of 150ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
the quadrature velocity in units per 100ms.

◆ isFwdLimitSwitchClosed()

boolean com.ctre.phoenix.motorcontrol.SensorCollection.isFwdLimitSwitchClosed ( )
inline

Is forward limit switch closed.

This method relies on the Status 1 message, which has a default period of 10ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
'1' iff forward limit switch is closed, 0 iff switch is open. This function works regardless if limit switch feature is enabled. Remote limit features do not impact this routine.

◆ isRevLimitSwitchClosed()

boolean com.ctre.phoenix.motorcontrol.SensorCollection.isRevLimitSwitchClosed ( )
inline

Is reverse limit switch closed.

This method relies on the Status 1 message, which has a default period of 10ms. For more information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html

Returns
'1' iff reverse limit switch is closed, 0 iff switch is open. This function works regardless if limit switch feature is enabled. Remote limit features do not impact this routine.

◆ setAnalogPosition()

ErrorCode com.ctre.phoenix.motorcontrol.SensorCollection.setAnalogPosition ( int  newPosition,
int  timeoutMs 
)
inline

Sets analog position.

Parameters
newPositionThe new position.
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
an ErrorCode.

◆ setPulseWidthPosition()

ErrorCode com.ctre.phoenix.motorcontrol.SensorCollection.setPulseWidthPosition ( int  newPosition,
int  timeoutMs 
)
inline

Sets pulse width position.

Parameters
newPositionThe position value to apply to the sensor.
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
an ErrErrorCode

◆ setQuadraturePosition()

ErrorCode com.ctre.phoenix.motorcontrol.SensorCollection.setQuadraturePosition ( int  newPosition,
int  timeoutMs 
)
inline

Change the quadrature reported position. Typically this is used to "zero" the sensor. This only works with Quadrature sensor. To set the selected sensor position regardless of what type it is, see SetSelectedSensorPosition in the motor controller class.

Parameters
newPositionThe position value to apply to the sensor.
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.

◆ syncQuadratureWithPulseWidth() [1/2]

ErrorCode com.ctre.phoenix.motorcontrol.SensorCollection.syncQuadratureWithPulseWidth ( int  bookend0,
int  bookend1,
boolean  bCrossZeroOnInterval 
)
inline

Change the quadrature reported position based on pulse width. This can be used to effectively make quadrature absolute. For rotary mechanisms with >360 movement (such as typical swerve modules) bookend0 and bookend1 can be both set to 0 and bCrossZeroOnInterval can be set to true. For mechanisms with less than 360 travel (such as arms), bookend0 and bookend1 should be set to the pulse width values at the two extremes. If the interval crosses over the pulse width value of 0 (or any multiple of 4096), bCrossZeroOnInterval should be true and otherwise should be false. An offset can also be set.

Parameters
bookend0value at extreme 0
bookend1value at extreme 1
bCrossZeroOnIntervalTrue iff zero/wrap-around cross occurs as mechanism moves from bookend0 to bookend1.
Returns
error code.

◆ syncQuadratureWithPulseWidth() [2/2]

ErrorCode com.ctre.phoenix.motorcontrol.SensorCollection.syncQuadratureWithPulseWidth ( int  bookend0,
int  bookend1,
boolean  bCrossZeroOnInterval,
int  offset,
int  timeoutMs 
)
inline

Change the quadrature reported position based on pulse width. This can be used to effectively make quadrature absolute. For rotary mechanisms with >360 movement (such as typical swerve modules) bookend0 and bookend1 can be both set to 0 and bCrossZeroOnInterval can be set to true. For mechanisms with less than 360 travel (such as arms), bookend0 and bookend1 should be set to the pulse width values at the two extremes. If the interval crosses over the pulse width value of 0 (or any multiple of 4096), bCrossZeroOnInterval should be true and otherwise should be false. An offset can also be set.

Parameters
bookend0value at extreme 0
bookend1value at extreme 1
bCrossZeroOnIntervalTrue iff zero/wrap-around cross occurs as mechanism moves from bookend0 to bookend1.
offset(Optional) Value to add to pulse width
timeoutMs(Optional) How long to wait for confirmation. Pass zero so that call does not block.
Returns
error code.

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