Miscellaneous objects

SensorCollection interface

class ctre.sensorcollection.SensorCollection(motorController)[source]

Bases: object

getAnalogIn()[source]
Return type:int
getAnalogInRaw()[source]
Return type:int
getAnalogInVel()[source]
Return type:int
getPinStateQuadA()[source]

Gets pin state quad a.

Return type:bool
Returns:the pin state quad a (1 if asserted, 0 if not asserted).
getPinStateQuadB()[source]

Gets pin state quad b.

Return type:bool
Returns:Digital level of QUADB pin (1 if asserted, 0 if not asserted).
getPinStateQuadIdx()[source]

Gets pin state quad index.

Return type:bool
Returns:Digital level of QUAD Index pin (1 if asserted, 0 if not asserted).
getPulseWidthPosition()[source]
Return type:int
getPulseWidthRiseToFallUs()[source]
Return type:int
getPulseWidthRiseToRiseUs()[source]
Return type:int
getPulseWidthVelocity()[source]
Return type:int
getQuadraturePosition()[source]
Return type:int
getQuadratureVelocity()[source]
Return type:int
handle
impl
isFwdLimitSwitchClosed()[source]

Is forward limit switch closed.

This function works regardless if limit switch feature is enabled.

Return type:bool
Returns:True iff forward limit switch is closed, False iff switch is open.
isRevLimitSwitchClosed()[source]

Is reverse limit switch closed.

This function works regardless if limit switch feature is enabled.

Return type:bool
Returns:True iff reverse limit switch is closed, False iff switch is open.
setAnalogPosition(newPosition, timeoutMs)[source]
setPulseWidthPosition(newPosition, timeoutMs)[source]
setQuadraturePosition(newPosition, timeoutMs)[source]

Motion Profile data transfer

class ctre.trajectorypoint.TrajectoryPoint(position, velocity, auxiliaryPos, profileSlotSelect0, profileSlotSelect1, isLastPoint, zeroPos, timeDur)

Bases: tuple

Motion Profile Trajectory Point. This is simply a data transfer object.

class TrajectoryDuration

Bases: enum.IntEnum

Duration to apply this trajectory pt. This time unit is ADDED to the existing base time set by configMotionProfileTrajectoryPeriod().

T0ms = 0
T100ms = 100
T10ms = 10
T20ms = 20
T30ms = 30
T40ms = 40
T50ms = 50
T5ms = 5
auxiliaryPos

The position for auxiliary PID to target.

isLastPoint

Set to true to signal Talon that this is the final point, so do not attempt to pop another trajectory point from out of the Talon buffer. Instead continue processing this way point. Typically the velocity member variable should be zero so that the motor doesn’t spin indefinitely.

position

The position to servo to.

profileSlotSelect0

Which slot to get PIDF gains. PID is used for position servo. F is used as the Kv constant for velocity feed-forward. Typically this is hardcoded to a particular slot, but you are free to gain schedule if need be. Choose from [0,3]

profileSlotSelect1

Which slot to get PIDF gains for auxiliary PID. This only has impact during MotionProfileArc Control mode. Choose from [0,1]

timeDur

Duration to apply this trajectory pt. This time unit is ADDED to the existing base time set by configMotionProfileTrajectoryPeriod().

velocity

The velocity to feed-forward.

zeroPos

Set to true to signal Talon to zero the selected sensor. When generating MPs, one simple method is to make the first target position zero, and the final target position the target distance from the current position. Then when you fire the MP, the current position gets set to zero. If this is the intent, you can set zeroPos on the first trajectory point.

Otherwise you can leave this false for all points, and offset the positions of all trajectory points so they are correct.

class ctre._impl.motionprofilestatus.MotionProfileStatus(topBufferRem, topBufferCnt, btmBufferCnt, hasUnderrun, isUnderrun, activePointValid, isLast, profileSlotSelect0, outputEnable, timeDurMs, profileSlotSelect1)

Bases: tuple

Motion Profile Status. This is simply a data transfer object.

activePointValid

True if the active trajectory point has not empty, false otherwise. The members in activePoint are only valid if this signal is set.

btmBufferCnt

The number of points in the low level Talon buffer.

hasUnderrun

Set if isUnderrun ever gets set. Only is cleared by clearMotionProfileHasUnderrun() to ensure robot logic can react or instrument it.

isLast

Is set/cleared based on the MP executer’s current trajectory point’s IsLast value. This assumes IsLast was set when PushMotionProfileTrajectory was used to insert the currently processed trajectory point.

isUnderrun

This is set if Talon needs to shift a point from its buffer into the active trajectory point however the buffer is empty. This gets cleared automatically when is resolved.

outputEnable

The current output mode of the motion profile executer (disabled, enabled, or hold). When changing the set() value in MP mode, it’s important to check this signal to confirm the change takes effect before interacting with the top buffer.

profileSlotSelect0

The currently processed trajectory point’s selected slot for PID Loop 0. This can differ in the currently selected slot used for Position and Velocity servo modes

profileSlotSelect1

Selected slot for PID Loop 0

timeDurMs

The applied duration of the active trajectory point

topBufferCnt

The number of points in the top trajectory buffer.

topBufferRem

The available empty slots in the trajectory buffer.

The robot API holds a “top buffer” of trajectory points, so your applicaion can dump several points at once. The API will then stream them into the Talon’s low-level buffer, allowing the Talon to act on them.

Error Codes

class ctre.ErrorCode[source]

Bases: enum.IntEnum

An enumeration.

AuxiliaryPIDNotSupportedYet = 107
BufferFull = 6
CAN_INVALID_PARAM = -2
CAN_MSG_NOT_FOUND = -3
CAN_MSG_STALE = 1
CAN_NO_MORE_TX_JOBS = -4
CAN_NO_SESSIONS_AVAIL = -5
CAN_OVERFLOW = -6
CAN_TX_FULL = -1
CascadedPIDNotSupporteYet = 107
ControlModeNotSupportedYet = 106
ControlModeNotValid = 105
CouldNotChangePeriod = -9
DistanceBetweenWheelsTooSmall = -502
FeatureNotSupported = 101
FeatureRequiresHigherFirm = -700
FeaturesNotAvailableYet = 104
FirmVersionCouldNotBeRetrieved = 103
FirmwareTooOld = -8
GENERAL_ERROR = -100
GEN_MODULE_ERROR = -400
GEN_PORT_ERROR = -300
GainsAreNotSet = -503
GeneralError = -100
GeneralWarning = 100
IncompatibleMode = -600
InvalidHandle = -601
InvalidParamValue = -2
MODULE_NOT_INIT_GET_ERROR = -402
MODULE_NOT_INIT_SET_ERROR = -401
MotProfFirmThreshold = 109
MotProfFirmThreshold2 = 110
NotAllPIDValuesUpdated = -201
NotImplemented = 102
OK = 0
OKAY = 0
PORT_MODULE_TYPE_MISMATCH = -301
PulseWidthSensorNotPresent = 10
RemoteSensorsNotSupportedYet = 108
RxTimeout = -3
SIG_NOT_UPDATED = -200
SensorNotPresent = -7
SigNotUpdated = -200
TalonFeatureRequiresHigherFirm = -701
TicksPerRevZero = -501
TxFailed = -1
TxTimeout = -4
UnexpectedArbId = -5
WheelRadiusTooSmall = -500