Class BaseMotorController
java.lang.Object
com.ctre.phoenix.motorcontrol.can.BaseMotorController
- All Implemented Interfaces:
IFollower
,IMotorController
,IInvertable
,IOutputSignal
public abstract class BaseMotorController extends Object implements IMotorController
Base motor controller features for all CTRE CAN motor controllers.
-
Field Summary
Fields Modifier and Type Field Description protected long
m_handle
Device handle -
Constructor Summary
Constructors Constructor Description BaseMotorController(int arbId, String model)
Constructor for motor controllers.BaseMotorController(int arbId, String model, String canbus)
Constructor for motor controllers. -
Method Summary
Modifier and Type Method Description protected ErrorCode
baseConfigAllSettings(BaseMotorControllerConfiguration allConfigs, int timeoutMs)
Configures all base persistant settings.protected ErrorCode
baseConfigurePID(BasePIDSetConfiguration pid, int pidIdx, int timeoutMs)
Configures all base PID set persistant settings.protected void
baseGetAllConfigs(BaseMotorControllerConfiguration allConfigs, int timeoutMs)
Gets all base persistant settings.protected void
baseGetPIDConfigs(BasePIDSetConfiguration pid, int pidIdx, int timeoutMs)
Gets all base PID set persistant settings.ErrorCode
changeMotionControlFramePeriod(int periodMs)
Calling application can opt to speed up the handshaking between the robot API and the controller to increase the download rate of the controller's Motion Profile.ErrorCode
clearMotionProfileHasUnderrun()
Clear the "Has Underrun" flag.ErrorCode
clearMotionProfileHasUnderrun(int timeoutMs)
Clear the "Has Underrun" flag.ErrorCode
clearMotionProfileTrajectories()
Clear the buffered motion profile in both controller's RAM (bottom), and in the API (top).ErrorCode
clearStickyFaults()
Clears all sticky faults.ErrorCode
clearStickyFaults(int timeoutMs)
Clears all sticky faults.ErrorCode
config_IntegralZone(int slotIdx, double izone)
Sets the Integral Zone constant in the given parameter slot.ErrorCode
config_IntegralZone(int slotIdx, double izone, int timeoutMs)
Sets the Integral Zone constant in the given parameter slot.ErrorCode
config_kD(int slotIdx, double value)
Sets the 'D' constant in the given parameter slot.ErrorCode
config_kD(int slotIdx, double value, int timeoutMs)
Sets the 'D' constant in the given parameter slot.ErrorCode
config_kF(int slotIdx, double value)
Sets the 'F' constant in the given parameter slot.ErrorCode
config_kF(int slotIdx, double value, int timeoutMs)
Sets the 'F' constant in the given parameter slot.ErrorCode
config_kI(int slotIdx, double value)
Sets the 'I' constant in the given parameter slot.ErrorCode
config_kI(int slotIdx, double value, int timeoutMs)
Sets the 'I' constant in the given parameter slot.ErrorCode
config_kP(int slotIdx, double value)
Sets the 'P' constant in the given parameter slot.ErrorCode
config_kP(int slotIdx, double value, int timeoutMs)
Sets the 'P' constant in the given parameter slot.ErrorCode
configAllowableClosedloopError(int slotIdx, double allowableClosedLoopError)
Sets the allowable closed-loop error in the given parameter slot.ErrorCode
configAllowableClosedloopError(int slotIdx, double allowableClosedLoopError, int timeoutMs)
Sets the allowable closed-loop error in the given parameter slot.ErrorCode
configAuxPIDPolarity(boolean invert)
Configures the Polarity of the Auxiliary PID (PID1).ErrorCode
configAuxPIDPolarity(boolean invert, int timeoutMs)
Configures the Polarity of the Auxiliary PID (PID1).ErrorCode
configClearPositionOnLimitF(boolean clearPositionOnLimitF, int timeoutMs)
Enables clearing the position of the feedback sensor when the forward limit switch is triggered.ErrorCode
configClearPositionOnLimitR(boolean clearPositionOnLimitR, int timeoutMs)
Enables clearing the position of the feedback sensor when the reverse limit switch is triggeredErrorCode
configClearPositionOnQuadIdx(boolean clearPositionOnQuadIdx, int timeoutMs)
Enables clearing the position of the feedback sensor when the quadrature index signal is detectedErrorCode
configClosedLoopPeakOutput(int slotIdx, double percentOut)
Sets the peak closed-loop output.ErrorCode
configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs)
Sets the peak closed-loop output.ErrorCode
configClosedLoopPeriod(int slotIdx, int loopTimeMs)
Sets the loop time (in milliseconds) of the PID closed-loop calculations.ErrorCode
configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs)
Sets the loop time (in milliseconds) of the PID closed-loop calculations.ErrorCode
configClosedloopRamp(double secondsFromNeutralToFull)
Configures the closed-loop ramp rate of throttle output.ErrorCode
configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs)
Configures the closed-loop ramp rate of throttle output.ErrorCode
configFactoryDefault()
Revert all configurations to factory default values.ErrorCode
configFactoryDefault(int timeoutMs)
Revert all configurations to factory default values.ErrorCode
configFeedbackNotContinuous(boolean feedbackNotContinuous, int timeoutMs)
Disables continuous tracking of the position for analog and pulse-width.protected ErrorCode
configForwardLimitSwitchSource(int typeValue, int normalOpenOrCloseValue, int deviceID, int timeoutMs)
Configures a limit switch for a local/remote source.ErrorCode
configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose)
Configures a limit switch for a local/remote source.ErrorCode
configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs)
Configures a limit switch for a local/remote source.ErrorCode
configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID)
Configures the forward limit switch for a remote source.ErrorCode
configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs)
Configures the forward limit switch for a remote source.ErrorCode
configForwardSoftLimitEnable(boolean enable)
Configures the forward soft limit enable.ErrorCode
configForwardSoftLimitEnable(boolean enable, int timeoutMs)
Configures the forward soft limit enable.ErrorCode
configForwardSoftLimitThreshold(double forwardSensorLimit)
Configures the forward soft limit threhold.ErrorCode
configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs)
Configures the forward soft limit threhold.int
configGetCustomParam(int paramIndex)
Gets the value of a custom parameter.int
configGetCustomParam(int paramIndex, int timeoutMs)
Gets the value of a custom parameter.double
configGetParameter(int param, int ordinal)
Gets a parameter.double
configGetParameter(int param, int ordinal, int timeoutMs)
Gets a parameter.double
configGetParameter(ParamEnum param, int ordinal)
Gets a parameter.double
configGetParameter(ParamEnum param, int ordinal, int timeoutMs)
Gets a parameter.ErrorCode
configLimitSwitchDisableNeutralOnLOS(boolean limitSwitchDisableNeutralOnLOS, int timeoutMs)
Disables limit switches triggering (if enabled) when the sensor is no longer detected.ErrorCode
configMaxIntegralAccumulator(int slotIdx, double iaccum)
Sets the maximum integral accumulator in the given parameter slot.ErrorCode
configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs)
Sets the maximum integral accumulator in the given parameter slot.ErrorCode
configMotionAcceleration(double sensorUnitsPer100msPerSec)
Sets the Motion Magic Acceleration.ErrorCode
configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs)
Sets the Motion Magic Acceleration.ErrorCode
configMotionCruiseVelocity(double sensorUnitsPer100ms)
Sets the Motion Magic Cruise Velocity.ErrorCode
configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs)
Sets the Motion Magic Cruise Velocity.ErrorCode
configMotionProfileTrajectoryInterpolationEnable(boolean enable)
When trajectory points are processed in the buffer, the motor controller can linearly interpolate additional trajectory points between the buffered points.ErrorCode
configMotionProfileTrajectoryInterpolationEnable(boolean enable, int timeoutMs)
When trajectory points are processed in the buffer, the motor controller can linearly interpolate additional trajectory points between the buffered points.ErrorCode
configMotionProfileTrajectoryPeriod(int baseTrajDurationMs)
When trajectory points are processed in the motion profile executer, the MPE determines how long to apply the active trajectory point by summing baseTrajDurationMs with the timeDur of the trajectory point (see TrajectoryPoint).ErrorCode
configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs)
When trajectory points are processed in the motion profile executer, the MPE determines how long to apply the active trajectory point by summing baseTrajDurationMs with the timeDur of the trajectory point (see TrajectoryPoint).ErrorCode
configMotionSCurveStrength(int curveStrength)
Sets the Motion Magic S Curve Strength.ErrorCode
configMotionSCurveStrength(int curveStrength, int timeoutMs)
Sets the Motion Magic S Curve Strength.ErrorCode
configNeutralDeadband(double percentDeadband)
Configures the output deadband percentage.ErrorCode
configNeutralDeadband(double percentDeadband, int timeoutMs)
Configures the output deadband percentage.ErrorCode
configNominalOutputForward(double percentOut)
Configures the forward nominal output percentage.ErrorCode
configNominalOutputForward(double percentOut, int timeoutMs)
Configures the forward nominal output percentage.ErrorCode
configNominalOutputReverse(double percentOut)
Configures the reverse nominal output percentage.ErrorCode
configNominalOutputReverse(double percentOut, int timeoutMs)
Configures the reverse nominal output percentage.ErrorCode
configOpenloopRamp(double secondsFromNeutralToFull)
Configures the open-loop ramp rate of throttle output.ErrorCode
configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs)
Configures the open-loop ramp rate of throttle output.ErrorCode
configPeakOutputForward(double percentOut)
Configures the forward peak output percentage.ErrorCode
configPeakOutputForward(double percentOut, int timeoutMs)
Configures the forward peak output percentage.ErrorCode
configPeakOutputReverse(double percentOut)
Configures the reverse peak output percentage.ErrorCode
configPeakOutputReverse(double percentOut, int timeoutMs)
Configures the reverse peak output percentage.ErrorCode
configPulseWidthPeriod_EdgesPerRot(int pulseWidthPeriod_EdgesPerRot, int timeoutMs)
Sets the edges per rotation of a pulse width sensor.ErrorCode
configPulseWidthPeriod_FilterWindowSz(int pulseWidthPeriod_FilterWindowSz, int timeoutMs)
Sets the number of samples to use in smoothing a pulse width sensor with a rolling average.ErrorCode
configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, int timeoutMs)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs)
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.ErrorCode
configRemoteSensorClosedLoopDisableNeutralOnLOS(boolean remoteSensorClosedLoopDisableNeutralOnLOS, int timeoutMs)
Disables going to neutral (brake/coast) when a remote sensor is no longer detected.protected ErrorCode
configReverseLimitSwitchSource(int typeValue, int normalOpenOrCloseValue, int deviceID, int timeoutMs)
Configures a limit switch for a local/remote source.ErrorCode
configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID)
Configures the reverse limit switch for a remote source.ErrorCode
configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs)
Configures the reverse limit switch for a remote source.ErrorCode
configReverseSoftLimitEnable(boolean enable)
Configures the reverse soft limit enable.ErrorCode
configReverseSoftLimitEnable(boolean enable, int timeoutMs)
Configures the reverse soft limit enable.ErrorCode
configReverseSoftLimitThreshold(double reverseSensorLimit)
Configures the reverse soft limit threshold.ErrorCode
configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs)
Configures the reverse soft limit threshold.ErrorCode
configSelectedFeedbackCoefficient(double coefficient)
The Feedback Coefficient is a scalar applied to the value of the feedback sensor.ErrorCode
configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs)
The Feedback Coefficient is a scalar applied to the value of the feedback sensor.ErrorCode
configSelectedFeedbackSensor(FeedbackDevice feedbackDevice)
Select the feedback device for the motor controller.ErrorCode
configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs)
Select the feedback device for the motor controller.ErrorCode
configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice)
Select the remote feedback device for the motor controller.ErrorCode
configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs)
Select the remote feedback device for the motor controller.ErrorCode
configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice)
Select what sensor term should be bound to switch feedback device.ErrorCode
configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs)
Select what sensor term should be bound to switch feedback device.ErrorCode
configSensorTerm(SensorTerm sensorTerm, RemoteFeedbackDevice feedbackDevice)
Select what sensor term should be bound to switch feedback device.ErrorCode
configSensorTerm(SensorTerm sensorTerm, RemoteFeedbackDevice feedbackDevice, int timeoutMs)
Select what sensor term should be bound to switch feedback device.ErrorCode
configSetCustomParam(int newValue, int paramIndex)
Sets the value of a custom parameter.ErrorCode
configSetCustomParam(int newValue, int paramIndex, int timeoutMs)
Sets the value of a custom parameter.ErrorCode
configSetParameter(int param, double value, int subValue, int ordinal)
Sets a parameter.ErrorCode
configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs)
Sets a parameter.ErrorCode
configSetParameter(ParamEnum param, double value, int subValue, int ordinal)
Sets a parameter.ErrorCode
configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)
Sets a parameter.ErrorCode
configSoftLimitDisableNeutralOnLOS(boolean softLimitDisableNeutralOnLOS, int timeoutMs)
Disables soft limits triggering (if enabled) when the sensor is no longer detected.ErrorCode
configureFilter(FilterConfiguration filter)
Deprecated.Use configAll instead.ErrorCode
configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs)
Deprecated.Use configAll instead.ErrorCode
configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs, boolean enableOptimizations)
Deprecated.Use the 3-parameter configureFilter.ErrorCode
configureSlot(SlotConfiguration slot)
Configures all slot persistant settings (overloaded so timeoutMs is 50 ms and slotIdx is 0ErrorCode
configureSlot(SlotConfiguration slot, int slotIdx, int timeoutMs)
Configures all slot persistant settingsErrorCode
configVelocityMeasurementPeriod(VelocityMeasPeriod period)
Deprecated.Use the overload with SensorVelocityMeasPeriod instead.ErrorCode
configVelocityMeasurementPeriod(VelocityMeasPeriod period, int timeoutMs)
Deprecated.Use the overload with SensorVelocityMeasPeriod instead.ErrorCode
configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period)
Sets the period over which velocity measurements are taken.ErrorCode
configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs)
Sets the period over which velocity measurements are taken.ErrorCode
configVelocityMeasurementWindow(int windowSize)
Sets the number of velocity samples used in the rolling average velocity measurement.ErrorCode
configVelocityMeasurementWindow(int windowSize, int timeoutMs)
Sets the number of velocity samples used in the rolling average velocity measurement.ErrorCode
configVoltageCompSaturation(double voltage)
Configures the Voltage Compensation saturation voltage.ErrorCode
configVoltageCompSaturation(double voltage, int timeoutMs)
Configures the Voltage Compensation saturation voltage.ErrorCode
configVoltageMeasurementFilter(int filterWindowSamples)
Configures the voltage measurement filter.ErrorCode
configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs)
Configures the voltage measurement filter.ErrorCode
DestroyObject()
Destructor for motor controllersvoid
enableVoltageCompensation(boolean enable)
Enables voltage compensation.void
follow(IMotorController masterToFollow)
Set the control mode and output value so that this motor controller will follow another motor controller.void
follow(IMotorController masterToFollow, FollowerType followerType)
Set the control mode and output value so that this motor controller will follow another motor controller.double
getActiveTrajectoryArbFeedFwd()
Gets the active trajectory arbitrary feedforward for pid0 using MotionMagic/MotionProfile control modes.double
getActiveTrajectoryArbFeedFwd(int pidIdx)
Gets the active trajectory arbitrary feedforward using MotionMagic/MotionProfile control modes.double
getActiveTrajectoryPosition()
Gets the active trajectory target position for pid0 using MotionMagic/MotionProfile control modes.double
getActiveTrajectoryPosition(int pidIdx)
Gets the active trajectory target position using MotionMagic/MotionProfile control modes.double
getActiveTrajectoryVelocity()
Gets the active trajectory target velocity for pid0 using MotionMagic/MotionProfile control modes.double
getActiveTrajectoryVelocity(int pidIdx)
Gets the active trajectory target velocity using MotionMagic/MotionProfile control modes.int
getBaseID()
double
getBusVoltage()
Gets the bus voltage seen by the device.double
getClosedLoopError()
Gets the closed-loop error.double
getClosedLoopError(int pidIdx)
Gets the closed-loop error.double
getClosedLoopTarget()
Gets the current target of a given closed loop.double
getClosedLoopTarget(int pidIdx)
Gets the current target of a given closed loop.ControlMode
getControlMode()
int
getDeviceID()
Returns the Device IDdouble
getErrorDerivative()
Gets the derivative of the closed-loop error.double
getErrorDerivative(int pidIdx)
Gets the derivative of the closed-loop error.ErrorCode
getFaults(Faults toFill)
Polls the various fault flags.void
getFilterConfigs(FilterConfiguration filter)
Gets all filter persistant settings (overloaded so timeoutMs is 50 ms and ordinal is 0).void
getFilterConfigs(FilterConfiguration filter, int ordinal, int timeoutMs)
Gets all filter persistant settings.int
getFirmwareVersion()
Gets the firmware version of the device.long
getHandle()
double
getIntegralAccumulator()
Gets the iaccum value.double
getIntegralAccumulator(int pidIdx)
Gets the iaccum value.boolean
getInverted()
ErrorCode
getLastError()
Gets the last error generated by this object.ErrorCode
getMotionProfileStatus(MotionProfileStatus statusToFill)
Retrieve all status information.int
getMotionProfileTopLevelBufferCount()
Retrieve just the buffer count for the api-level (top) buffer.double
getMotorOutputPercent()
Gets the output percentage of the motor controller.double
getMotorOutputVoltage()
protected double
getOutputCurrent()
Deprecated.Use getStatorCurrent/getSupplyCurrent instead.double
getSelectedSensorPosition()
Get the selected sensor position (in raw sensor units).double
getSelectedSensorPosition(int pidIdx)
Get the selected sensor position (in raw sensor units).double
getSelectedSensorVelocity()
Get the selected sensor velocity.double
getSelectedSensorVelocity(int pidIdx)
Get the selected sensor velocity.void
getSlotConfigs(SlotConfiguration slot)
Gets all slot persistant settings (overloaded so timeoutMs is 50 ms and slotIdx is 0void
getSlotConfigs(SlotConfiguration slot, int slotIdx, int timeoutMs)
Gets all slot persistant settings.int
getStatusFramePeriod(int frame)
Gets the period of the given status frame.int
getStatusFramePeriod(int frame, int timeoutMs)
Gets the period of the given status frame.int
getStatusFramePeriod(StatusFrame frame)
Gets the period of the given status frame.int
getStatusFramePeriod(StatusFrameEnhanced frame)
Gets the period of the given status frame.int
getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs)
Gets the period of the given status frame.int
getStatusFramePeriod(StatusFrame frame, int timeoutMs)
Gets the period of the given status frame.ErrorCode
getStickyFaults(StickyFaults toFill)
Polls the various sticky fault flags.double
getTemperature()
Gets the temperature of the motor controller.protected VictorSPXSimCollection
getVictorSPXSimCollection()
boolean
hasResetOccurred()
Returns true if the device has reset since last call.boolean
isMotionProfileFinished()
Determine if running MP is complete.boolean
isMotionProfileTopLevelBufferFull()
Retrieve just the buffer full for the api-level (top) buffer.boolean
isVoltageCompensationEnabled()
Returns the enable state of Voltage Compensation that the caller has set.void
neutralOutput()
Neutral the motor output by setting control mode to disabled.void
overrideLimitSwitchesEnable(boolean enable)
Sets the enable state for limit switches.void
overrideSoftLimitsEnable(boolean enable)
Can be used to override-disable the soft limits.void
processMotionProfileBuffer()
This must be called periodically to funnel the trajectory points from the API's top level buffer to the controller's bottom level buffer.ErrorCode
pushMotionProfileTrajectory(TrajectoryPoint trajPt)
Push another trajectory point into the top level buffer (which is emptied into the motor controller's bottom buffer as room allows).void
selectProfileSlot(int slotIdx, int pidIdx)
Selects which profile slot to use for closed-loop control.void
set(ControlMode mode, double outputValue)
Sets the appropriate output on the talon, depending on the mode.void
set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
ErrorCode
setControlFramePeriod(int frame, int periodMs)
Sets the period of the given status frame.ErrorCode
setControlFramePeriod(ControlFrame frame, int periodMs)
Sets the period of the given control frame.ErrorCode
setIntegralAccumulator(double iaccum)
Sets the integral accumulator.ErrorCode
setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs)
Sets the integral accumulator.void
setInverted(boolean invert)
Inverts the hbridge output of the motor controller.void
setInverted(InvertType invertType)
Inverts the hbridge output of the motor controller in relation to the master if present This does not impact sensor phase and should not be used to correct sensor polarity.void
setNeutralMode(NeutralMode neutralMode)
Sets the mode of operation during neutral throttle output.ErrorCode
setSelectedSensorPosition(double sensorPos)
Sets the sensor position to the given value.ErrorCode
setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs)
Sets the sensor position to the given value.void
setSensorPhase(boolean PhaseSensor)
Sets the phase of the sensor.ErrorCode
setStatusFramePeriod(int frameValue, int periodMs)
Sets the period of the given status frame.ErrorCode
setStatusFramePeriod(int frameValue, int periodMs, int timeoutMs)
Sets the period of the given status frame.ErrorCode
setStatusFramePeriod(StatusFrame frame, int periodMs)
Sets the period of the given status frame.ErrorCode
setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs)
Sets the period of the given status frame.ErrorCode
startMotionProfile(BufferedTrajectoryPointStream stream, int minBufferedPts, ControlMode motionProfControlMode)
Simple one-shot firing of a complete MP.void
valueUpdated()
When master makes a device, this routine is called to signal the update.
-
Field Details
-
m_handle
Device handle
-
-
Constructor Details
-
BaseMotorController
Constructor for motor controllers.- Parameters:
arbId
- Device ID [0,62]model
- String specifying device model
-
BaseMotorController
Constructor for motor controllers.- Parameters:
arbId
- Device ID [0,62]model
- String specifying device model
-
-
Method Details
-
getVictorSPXSimCollection
-
DestroyObject
Destructor for motor controllers- Returns:
- Error Code generated by function. 0 indicates no error.
-
getHandle
- Returns:
- CCI handle for child classes.
-
getDeviceID
Returns the Device ID- Specified by:
getDeviceID
in interfaceIMotorController
- Returns:
- Device number.
-
set
Sets the appropriate output on the talon, depending on the mode.- Specified by:
set
in interfaceIMotorController
- Parameters:
mode
- The output mode to apply. In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped. In Current mode, output value is in amperes. In Velocity mode, output value is in position change / 100ms. In Position mode, output value is in encoder ticks or an analog value, depending on the sensor. In Follower mode, the output value is the integer device ID of the talon to duplicate.outputValue
- The setpoint value, as described above. Standard Driving Example: _talonLeft.set(ControlMode.PercentOutput, leftJoy); _talonRght.set(ControlMode.PercentOutput, rghtJoy);
-
set
- Specified by:
set
in interfaceIMotorController
- Parameters:
mode
- Sets the appropriate output on the talon, depending on the mode.demand0
- The output value to apply. such as advanced feed forward and/or auxiliary close-looping in firmware. In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped. In Current mode, output value is in amperes. In Velocity mode, output value is in position change / 100ms. In Position mode, output value is in encoder ticks or an analog value, depending on the sensor. See In Follower mode, the output value is the integer device ID of the talon to duplicate.demand1Type
- The demand type for demand1. Neutral: Ignore demand1 and apply no change to the demand0 output. AuxPID: Use demand1 to set the target for the auxiliary PID 1. Auxiliary PID is always executed as standard Position PID control. ArbitraryFeedForward: Use demand1 as an arbitrary additive value to the demand0 output. In PercentOutput the demand0 output is the motor output, and in closed-loop modes the demand0 output is the output of PID0.demand1
- Supplmental output value. AuxPID: Target position in Sensor Units ArbitraryFeedForward: Percent Output between -1.0 and 1.0 Arcade Drive Example: _talonLeft.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, +joyTurn); _talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, -joyTurn); Drive Straight Example: Note: Selected Sensor Configuration is necessary for both PID0 and PID1. _talonLeft.follow(_talonRght, FollwerType.AuxOutput1); _talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.AuxPID, desiredRobotHeading); Drive Straight to a Distance Example: Note: Other configurations (sensor selection, PID gains, etc.) need to be set. _talonLeft.follow(_talonRght, FollwerType.AuxOutput1); _talonRght.set(ControlMode.MotionMagic, targetDistance, DemandType.AuxPID, desiredRobotHeading);
-
neutralOutput
Neutral the motor output by setting control mode to disabled.- Specified by:
neutralOutput
in interfaceIMotorController
-
setNeutralMode
Sets the mode of operation during neutral throttle output.- Specified by:
setNeutralMode
in interfaceIMotorController
- Parameters:
neutralMode
- The desired mode of operation when the Controller output throttle is neutral (ie brake/coast)
-
setSensorPhase
Sets the phase of the sensor. Use when controller forward/reverse output doesn't correlate to appropriate forward/reverse reading of sensor. Pick a value so that positive PercentOutput yields a positive change in sensor. After setting this, user can freely call SetInverted() with any value.- Specified by:
setSensorPhase
in interfaceIMotorController
- Parameters:
PhaseSensor
- Indicates whether to invert the phase of the sensor.
-
setInverted
Inverts the hbridge output of the motor controller. This does not impact sensor phase and should not be used to correct sensor polarity. This will invert the hbridge output but NOT the LEDs. This ensures.... - Green LEDs always represents positive request from robot-controller/closed-looping mode. - Green LEDs correlates to forward limit switch. - Green LEDs correlates to forward soft limit.- Specified by:
setInverted
in interfaceIInvertable
- Specified by:
setInverted
in interfaceIMotorController
- Parameters:
invert
- Invert state to set.
-
setInverted
Inverts the hbridge output of the motor controller in relation to the master if present This does not impact sensor phase and should not be used to correct sensor polarity. This will allow you to either: - Not invert the motor - Invert the motor - Always follow the master regardless of master's inversion - Always oppose the master regardless of master's inversion- Specified by:
setInverted
in interfaceIMotorController
- Parameters:
invertType
- Invert state to set.
-
getInverted
- Specified by:
getInverted
in interfaceIInvertable
- Specified by:
getInverted
in interfaceIMotorController
- Returns:
- invert setting of motor output.
-
configFactoryDefault
Revert all configurations to factory default values. Use this before your individual config* calls to avoid having to config every single param. Alternatively you can use the configAllSettings routine.- Parameters:
timeoutMs
- Timeout value in ms. Function will generate error if config is not successful within timeout.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configFactoryDefault
Revert all configurations to factory default values. Use this before your individual config* calls to avoid having to config every single param. Alternatively you can use the configAllSettings routine.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configOpenloopRamp
Configures the open-loop ramp rate of throttle output.- Specified by:
configOpenloopRamp
in interfaceIMotorController
- Parameters:
secondsFromNeutralToFull
- Minimum desired time to go from neutral to full throttle. A value of '0' will disable the ramp.timeoutMs
- Timeout 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.
-
configOpenloopRamp
Configures the open-loop ramp rate of throttle output.- Parameters:
secondsFromNeutralToFull
- Minimum desired time to go from neutral to full throttle. A value of '0' will disable the ramp.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configClosedloopRamp
Configures the closed-loop ramp rate of throttle output.- Specified by:
configClosedloopRamp
in interfaceIMotorController
- Parameters:
secondsFromNeutralToFull
- Minimum desired time to go from neutral to full throttle. A value of '0' will disable the ramp.timeoutMs
- Timeout 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.
-
configClosedloopRamp
Configures the closed-loop ramp rate of throttle output.- Parameters:
secondsFromNeutralToFull
- Minimum desired time to go from neutral to full throttle. A value of '0' will disable the ramp.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configPeakOutputForward
Configures the forward peak output percentage.- Specified by:
configPeakOutputForward
in interfaceIMotorController
- Parameters:
percentOut
- Desired peak output percentage. [0,1]timeoutMs
- Timeout 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.
-
configPeakOutputForward
Configures the forward peak output percentage.- Parameters:
percentOut
- Desired peak output percentage. [0,1]- Returns:
- Error Code generated by function. 0 indicates no error.
-
configPeakOutputReverse
Configures the reverse peak output percentage.- Specified by:
configPeakOutputReverse
in interfaceIMotorController
- Parameters:
percentOut
- Desired peak output percentage.timeoutMs
- Timeout 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.
-
configPeakOutputReverse
Configures the reverse peak output percentage.- Parameters:
percentOut
- Desired peak output percentage.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configNominalOutputForward
Configures the forward nominal output percentage.- Specified by:
configNominalOutputForward
in interfaceIMotorController
- Parameters:
percentOut
- Nominal (minimum) percent output. [0,+1]timeoutMs
- Timeout 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.
-
configNominalOutputForward
Configures the forward nominal output percentage.- Parameters:
percentOut
- Nominal (minimum) percent output. [0,+1]- Returns:
- Error Code generated by function. 0 indicates no error.
-
configNominalOutputReverse
Configures the reverse nominal output percentage.- Specified by:
configNominalOutputReverse
in interfaceIMotorController
- Parameters:
percentOut
- Nominal (minimum) percent output. [-1,0]timeoutMs
- Timeout 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.
-
configNominalOutputReverse
Configures the reverse nominal output percentage.- Parameters:
percentOut
- Nominal (minimum) percent output. [-1,0]- Returns:
- Error Code generated by function. 0 indicates no error.
-
configNeutralDeadband
Configures the output deadband percentage.- Specified by:
configNeutralDeadband
in interfaceIMotorController
- Parameters:
percentDeadband
- Desired deadband percentage. Minimum is 0.1%, Maximum is 25%. Pass 0.04 for 4% (factory default).timeoutMs
- Timeout 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.
-
configNeutralDeadband
Configures the output deadband percentage.- Parameters:
percentDeadband
- Desired deadband percentage. Minimum is 0.1%, Maximum is 25%. Pass 0.04 for 4% (factory default).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configVoltageCompSaturation
Configures the Voltage Compensation saturation voltage.- Specified by:
configVoltageCompSaturation
in interfaceIMotorController
- Parameters:
voltage
- This is the max voltage to apply to the hbridge when voltage compensation is enabled. For example, if 10 (volts) is specified and a TalonSRX is commanded to 0.5 (PercentOutput, closed-loop, etc) then the TalonSRX will attempt to apply a duty-cycle to produce 5V.timeoutMs
- Timeout 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.
-
configVoltageCompSaturation
Configures the Voltage Compensation saturation voltage.- Parameters:
voltage
- This is the max voltage to apply to the hbridge when voltage compensation is enabled. For example, if 10 (volts) is specified and a TalonSRX is commanded to 0.5 (PercentOutput, closed-loop, etc) then the TalonSRX will attempt to apply a duty-cycle to produce 5V.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configVoltageMeasurementFilter
Configures the voltage measurement filter.- Specified by:
configVoltageMeasurementFilter
in interfaceIMotorController
- Parameters:
filterWindowSamples
- Number of samples in the rolling average of voltage measurement.timeoutMs
- Timeout 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.
-
configVoltageMeasurementFilter
Configures the voltage measurement filter.- Parameters:
filterWindowSamples
- Number of samples in the rolling average of voltage measurement.- Returns:
- Error Code generated by function. 0 indicates no error.
-
enableVoltageCompensation
Enables voltage compensation. If enabled, voltage compensation works in all control modes. Be sure to configure the saturation voltage before enabling this.- Specified by:
enableVoltageCompensation
in interfaceIMotorController
- Parameters:
enable
- Enable state of voltage compensation.
-
isVoltageCompensationEnabled
Returns the enable state of Voltage Compensation that the caller has set.- Returns:
- TRUE if voltage compensation is enabled.
-
getBusVoltage
Gets the bus voltage seen by the device.- Specified by:
getBusVoltage
in interfaceIMotorController
- Returns:
- The bus voltage value (in volts).
-
getMotorOutputPercent
Gets the output percentage of the motor controller.- Specified by:
getMotorOutputPercent
in interfaceIMotorController
- Returns:
- Output of the motor controller (in percent).
-
getMotorOutputVoltage
- Specified by:
getMotorOutputVoltage
in interfaceIMotorController
- Returns:
- applied voltage to motor in volts.
-
getOutputCurrent
Deprecated.Use getStatorCurrent/getSupplyCurrent instead.Gets the output current of the motor controller. In the case of TalonSRX class, this routine returns supply current for legacy reasons. In order to get the "true" output current, call GetStatorCurrent(). In the case of TalonFX class, this routine returns the true output stator current.- Returns:
- The output current (in amps).
-
getTemperature
Gets the temperature of the motor controller.- Specified by:
getTemperature
in interfaceIMotorController
- Returns:
- Temperature of the motor controller (in 'C)
-
configSelectedFeedbackSensor
public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs)Select the remote feedback device for the motor controller. Most CTRE CAN motor controllers will support remote sensors over CAN.- Specified by:
configSelectedFeedbackSensor
in interfaceIMotorController
- Parameters:
feedbackDevice
- Remote Feedback Device to select.pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
configSelectedFeedbackSensor
Select the remote feedback device for the motor controller. Most CTRE CAN motor controllers will support remote sensors over CAN.- Parameters:
feedbackDevice
- Remote Feedback Device to select.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configSelectedFeedbackSensor
public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs)Select the feedback device for the motor controller.- Parameters:
feedbackDevice
- Feedback Device to select.pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
configSelectedFeedbackSensor
Select the feedback device for the motor controller.- Parameters:
feedbackDevice
- Feedback Device to select.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configSelectedFeedbackCoefficient
The Feedback Coefficient is a scalar applied to the value of the feedback sensor. Useful when you need to scale your sensor values within the closed-loop calculations. Default value is 1. Selected Feedback Sensor register in firmware is the decoded sensor value multiplied by the Feedback Coefficient.- Specified by:
configSelectedFeedbackCoefficient
in interfaceIMotorController
- Parameters:
coefficient
- Feedback Coefficient value. Maximum value of 1. Resolution is 1/(2^16). Cannot be 0.pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
configSelectedFeedbackCoefficient
The Feedback Coefficient is a scalar applied to the value of the feedback sensor. Useful when you need to scale your sensor values within the closed-loop calculations. Default value is 1. Selected Feedback Sensor register in firmware is the decoded sensor value multiplied by the Feedback Coefficient.- Parameters:
coefficient
- Feedback Coefficient value. Maximum value of 1. Resolution is 1/(2^16). Cannot be 0.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configRemoteFeedbackFilter
public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, int timeoutMs)Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Specified by:
configRemoteFeedbackFilter
in interfaceIMotorController
- Parameters:
deviceID
- The device ID of the remote sensor device.remoteSensorSource
- The remote sensor device and signal type to bind.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1timeoutMs
- Timeout 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.
-
configRemoteFeedbackFilter
public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal)Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Parameters:
deviceID
- The device ID of the remote sensor device.remoteSensorSource
- The remote sensor device and signal type to bind.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1- Returns:
- Error Code generated by function. 0 indicates no error.
-
configRemoteFeedbackFilter
public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs)Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Specified by:
configRemoteFeedbackFilter
in interfaceIMotorController
- Parameters:
canCoderRef
- CANCoder device reference to use.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1timeoutMs
- Timeout 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.
-
configRemoteFeedbackFilter
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Parameters:
canCoderRef
- CANCoder device reference to use.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1- Returns:
- Error Code generated by function. 0 indicates no error.
-
configRemoteFeedbackFilter
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Specified by:
configRemoteFeedbackFilter
in interfaceIMotorController
- Parameters:
talonRef
- Talon device reference to use.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1timeoutMs
- Timeout 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.
-
configRemoteFeedbackFilter
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1. After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X as a PID source for closed-loop features.- Parameters:
talonRef
- Talon device reference to use.remoteOrdinal
- 0 for configuring Remote Sensor 0, 1 for configuring Remote Sensor 1- Returns:
- Error Code generated by function. 0 indicates no error.
-
configSensorTerm
public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs)Select what sensor term should be bound to switch feedback device. Sensor Sum = Sensor Sum Term 0 - Sensor Sum Term 1 Sensor Difference = Sensor Diff Term 0 - Sensor Diff Term 1 The four terms are specified with this routine. Then Sensor Sum/Difference can be selected for closed-looping.- Specified by:
configSensorTerm
in interfaceIMotorController
- Parameters:
sensorTerm
- Which sensor term to bind to a feedback source.feedbackDevice
- The sensor signal to attach to sensorTerm.timeoutMs
- Timeout 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.
-
configSensorTerm
Select what sensor term should be bound to switch feedback device. Sensor Sum = Sensor Sum Term 0 - Sensor Sum Term 1 Sensor Difference = Sensor Diff Term 0 - Sensor Diff Term 1 The four terms are specified with this routine. Then Sensor Sum/Difference can be selected for closed-looping.- Parameters:
sensorTerm
- Which sensor term to bind to a feedback source.feedbackDevice
- The sensor signal to attach to sensorTerm.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configSensorTerm
public ErrorCode configSensorTerm(SensorTerm sensorTerm, RemoteFeedbackDevice feedbackDevice, int timeoutMs)Select what sensor term should be bound to switch feedback device. Sensor Sum = Sensor Sum Term 0 - Sensor Sum Term 1 Sensor Difference = Sensor Diff Term 0 - Sensor Diff Term 1 The four terms are specified with this routine. Then Sensor Sum/Difference can be selected for closed-looping.- Parameters:
sensorTerm
- Which sensor term to bind to a feedback source.feedbackDevice
- The sensor signal to attach to sensorTerm.timeoutMs
- Timeout 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.
-
configSensorTerm
Select what sensor term should be bound to switch feedback device. Sensor Sum = Sensor Sum Term 0 - Sensor Sum Term 1 Sensor Difference = Sensor Diff Term 0 - Sensor Diff Term 1 The four terms are specified with this routine. Then Sensor Sum/Difference can be selected for closed-looping.- Parameters:
sensorTerm
- Which sensor term to bind to a feedback source.feedbackDevice
- The sensor signal to attach to sensorTerm.- Returns:
- Error Code generated by function. 0 indicates no error.
-
getSelectedSensorPosition
Get the selected sensor position (in raw sensor units).- Specified by:
getSelectedSensorPosition
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop. See Phoenix-Documentation for how to interpret.- Returns:
- Position of selected sensor (in raw sensor units).
-
getSelectedSensorPosition
Get the selected sensor position (in raw sensor units).- Returns:
- Position of selected sensor (in raw sensor units).
-
getSelectedSensorVelocity
Get the selected sensor velocity.- Specified by:
getSelectedSensorVelocity
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- selected sensor (in raw sensor units) per 100ms. See Phoenix-Documentation for how to interpret.
-
getSelectedSensorVelocity
Get the selected sensor velocity.- Returns:
- selected sensor (in raw sensor units) per 100ms. See Phoenix-Documentation for how to interpret.
-
setSelectedSensorPosition
Sets the sensor position to the given value.- Specified by:
setSelectedSensorPosition
in interfaceIMotorController
- Parameters:
sensorPos
- Position to set for the selected sensor (in raw sensor units).pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
setSelectedSensorPosition
Sets the sensor position to the given value.- Parameters:
sensorPos
- Position to set for the selected sensor (in raw sensor units).- Returns:
- Error Code generated by function. 0 indicates no error.
-
setControlFramePeriod
Sets the period of the given control frame.- Specified by:
setControlFramePeriod
in interfaceIMotorController
- Parameters:
frame
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.- Returns:
- Error Code generated by function. 0 indicates no error.
-
setControlFramePeriod
Sets the period of the given status frame. User ensure CAN Bus utilization is not high. This setting is not persistent and is lost when device is reset. If this is a concern, calling application can use hasResetOccurred() to determine if the status frame needs to be reconfigured.- Parameters:
frame
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.- Returns:
- Error Code generated by function. 0 indicates no error.
-
setStatusFramePeriod
Sets the period of the given status frame. User ensure CAN Bus utilization is not high. This setting is not persistent and is lost when device is reset. If this is a concern, calling application can use hasResetOccurred() to determine if the status frame needs to be reconfigured.- Parameters:
frameValue
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.timeoutMs
- Timeout 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.
-
setStatusFramePeriod
Sets the period of the given status frame. User ensure CAN Bus utilization is not high. This setting is not persistent and is lost when device is reset. If this is a concern, calling application can use hasResetOccurred() to determine if the status frame needs to be reconfigured.- Parameters:
frameValue
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.- Returns:
- Error Code generated by function. 0 indicates no error.
-
setStatusFramePeriod
Sets the period of the given status frame.- Specified by:
setStatusFramePeriod
in interfaceIMotorController
- Parameters:
frame
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.timeoutMs
- Timeout 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.
-
setStatusFramePeriod
Sets the period of the given status frame.- Parameters:
frame
- Frame whose period is to be changed.periodMs
- Period in ms for the given frame.- Returns:
- Error Code generated by function. 0 indicates no error.
-
getStatusFramePeriod
Gets the period of the given status frame.- Parameters:
frame
- Frame to get the period of.timeoutMs
- Timeout 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.
-
getStatusFramePeriod
Gets the period of the given status frame.- Parameters:
frame
- Frame to get the period of.- Returns:
- Period of the given status frame.
-
getStatusFramePeriod
Gets the period of the given status frame.- Specified by:
getStatusFramePeriod
in interfaceIMotorController
- Parameters:
frame
- Frame to get the period of.timeoutMs
- Timeout 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.
-
getStatusFramePeriod
Gets the period of the given status frame.- Parameters:
frame
- Frame to get the period of.- Returns:
- Period of the given status frame.
-
getStatusFramePeriod
Gets the period of the given status frame.- Parameters:
frame
- Frame to get the period of.timeoutMs
- Timeout 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.
-
getStatusFramePeriod
Gets the period of the given status frame.- Parameters:
frame
- Frame to get the period of.- Returns:
- Period of the given status frame.
-
configVelocityMeasurementPeriod
Sets the period over which velocity measurements are taken.- Parameters:
period
- Desired period for the velocity measurement. @see com.ctre.phoenix.sensors.SensorVelocityMeasPeriodtimeoutMs
- Timeout 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
@Deprecated public ErrorCode configVelocityMeasurementPeriod(VelocityMeasPeriod period, int timeoutMs)Deprecated.Use the overload with SensorVelocityMeasPeriod instead.Sets the period over which velocity measurements are taken.- Parameters:
period
- Desired period for the velocity measurement. @see com.ctre.phoenix.motorcontrol.VelocityMeasPeriodtimeoutMs
- Timeout 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
Sets the period over which velocity measurements are taken.- Parameters:
period
- Desired period for the velocity measurement. @see com.ctre.phoenix.sensors.SensorVelocityMeasPeriod- Returns:
- Error Code generated by function. 0 indicates no error.
-
configVelocityMeasurementPeriod
Deprecated.Use the overload with SensorVelocityMeasPeriod instead.Sets the period over which velocity measurements are taken.- Parameters:
period
- Desired period for the velocity measurement. @see com.ctre.phoenix.motorcontrol.VelocityMeasPeriod- Returns:
- Error Code generated by function. 0 indicates no error.
-
configVelocityMeasurementWindow
Sets the number of velocity samples used in the rolling average velocity measurement.- Parameters:
windowSize
- Number 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.timeoutMs
- Timeout 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
Sets the number of velocity samples used in the rolling average velocity measurement.- Parameters:
windowSize
- Number 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.
-
configForwardLimitSwitchSource
public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs)Configures the forward limit switch for a remote source. For example, a CAN motor controller may need to monitor the Limit-F pin of another Talon or CANifier.- Specified by:
configForwardLimitSwitchSource
in interfaceIMotorController
- Parameters:
type
- Remote limit switch source. User can choose between a remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- Device ID of remote source (Talon SRX or CANifier device ID).timeoutMs
- Timeout 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.
-
configForwardLimitSwitchSource
public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID)Configures the forward limit switch for a remote source. For example, a CAN motor controller may need to monitor the Limit-F pin of another Talon or CANifier.- Parameters:
type
- Remote limit switch source. User can choose between a remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- Device ID of remote source (Talon SRX or CANifier device ID).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configReverseLimitSwitchSource
public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs)Configures the reverse limit switch for a remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon or CANifier.- Specified by:
configReverseLimitSwitchSource
in interfaceIMotorController
- Parameters:
type
- Remote limit switch source. User can choose between a remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- Device ID of remote source (Talon SRX or CANifier device ID).timeoutMs
- Timeout 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.
-
configReverseLimitSwitchSource
public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID)Configures the reverse limit switch for a remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon or CANifier.- Parameters:
type
- Remote limit switch source. User can choose between a remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- Device ID of remote source (Talon SRX or CANifier device ID).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configForwardLimitSwitchSource
public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs)Configures a limit switch for a local/remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon, CANifier, or local Gadgeteer feedback connector. If the sensor is remote, a device ID of zero is assumed. If that's not desired, use the four parameter version of this function.- Parameters:
type
- Limit switch source. @see com.ctre.phoenix.motorcontrol.LimitSwitchSource User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.timeoutMs
- Timeout 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.
-
configForwardLimitSwitchSource
public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose)Configures a limit switch for a local/remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon, CANifier, or local Gadgeteer feedback connector. If the sensor is remote, a device ID of zero is assumed. If that's not desired, use the four parameter version of this function.- Parameters:
type
- Limit switch source. @see com.ctre.phoenix.motorcontrol.LimitSwitchSource User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrClose
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configForwardLimitSwitchSource
protected ErrorCode configForwardLimitSwitchSource(int typeValue, int normalOpenOrCloseValue, int deviceID, int timeoutMs)Configures a limit switch for a local/remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon, CANifier, or local Gadgeteer feedback connector. If the sensor is remote, a device ID of zero is assumed. If that's not desired, use the four parameter version of this function.- Parameters:
typeValue
- Limit switch source. @see com.ctre.phoenix.motorcontrol.LimitSwitchSource User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrCloseValue
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- Device ID of remote source (Talon SRX or CANifier device ID).timeoutMs
- Timeout 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.
-
configReverseLimitSwitchSource
protected ErrorCode configReverseLimitSwitchSource(int typeValue, int normalOpenOrCloseValue, int deviceID, int timeoutMs)Configures a limit switch for a local/remote source. For example, a CAN motor controller may need to monitor the Limit-R pin of another Talon, CANifier, or local Gadgeteer feedback connector. If the sensor is remote, a device ID of zero is assumed. If that's not desired, use the four parameter version of this function.- Parameters:
typeValue
- Limit switch source. @see com.ctre.phoenix.motorcontrol.LimitSwitchSource User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature.normalOpenOrCloseValue
- Setting for normally open, normally closed, or disabled. This setting matches the Phoenix Tuner drop down.deviceID
- The device ID of the remote sensor device.timeoutMs
- Timeout 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.
-
overrideLimitSwitchesEnable
Sets the enable state for limit switches.- Specified by:
overrideLimitSwitchesEnable
in interfaceIMotorController
- Parameters:
enable
- Enable state for limit switches.
-
configForwardSoftLimitThreshold
Configures the forward soft limit threhold.- Specified by:
configForwardSoftLimitThreshold
in interfaceIMotorController
- Parameters:
forwardSensorLimit
- Forward Sensor Position Limit (in raw sensor units).timeoutMs
- Timeout 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.
-
configForwardSoftLimitThreshold
Configures the forward soft limit threhold.- Parameters:
forwardSensorLimit
- Forward Sensor Position Limit (in raw sensor units).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configReverseSoftLimitThreshold
Configures the reverse soft limit threshold.- Specified by:
configReverseSoftLimitThreshold
in interfaceIMotorController
- Parameters:
reverseSensorLimit
- Reverse Sensor Position Limit (in raw sensor units).timeoutMs
- Timeout 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.
-
configReverseSoftLimitThreshold
Configures the reverse soft limit threshold.- Parameters:
reverseSensorLimit
- Reverse Sensor Position Limit (in raw sensor units).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configForwardSoftLimitEnable
Configures the forward soft limit enable.- Specified by:
configForwardSoftLimitEnable
in interfaceIMotorController
- Parameters:
enable
- Forward Sensor Position Limit Enable.timeoutMs
- Timeout 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.
-
configForwardSoftLimitEnable
Configures the forward soft limit enable.- Parameters:
enable
- Forward Sensor Position Limit Enable.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configReverseSoftLimitEnable
Configures the reverse soft limit enable.- Specified by:
configReverseSoftLimitEnable
in interfaceIMotorController
- Parameters:
enable
- Reverse Sensor Position Limit Enable.timeoutMs
- Timeout 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.
-
configReverseSoftLimitEnable
Configures the reverse soft limit enable.- Parameters:
enable
- Reverse Sensor Position Limit Enable.- Returns:
- Error Code generated by function. 0 indicates no error.
-
overrideSoftLimitsEnable
Can be used to override-disable the soft limits. This function can be used to quickly disable soft limits without having to modify the persistent configuration.- Specified by:
overrideSoftLimitsEnable
in interfaceIMotorController
- Parameters:
enable
- Enable state for soft limit switches.
-
config_kP
Sets the 'P' constant in the given parameter slot. This is multiplied by closed loop error in sensor units. Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '0.25' to get full output if err is 4096u (Mag Encoder 1 rotation)- Specified by:
config_kP
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the P constant.timeoutMs
- Timeout 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.
-
config_kP
Sets the 'P' constant in the given parameter slot. This is multiplied by closed loop error in sensor units. Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '0.25' to get full output if err is 4096u (Mag Encoder 1 rotation)- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the P constant.- Returns:
- Error Code generated by function. 0 indicates no error.
-
config_kI
Sets the 'I' constant in the given parameter slot. This is multiplied by accumulated closed loop error in sensor units every PID Loop. Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '0.00025' to get full output if err is 4096u for 1000 loops (accumulater holds 4,096,000), [which is equivalent to one CTRE mag encoder rotation for 1000 milliseconds].- Specified by:
config_kI
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the I constant.timeoutMs
- Timeout 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.
-
config_kI
Sets the 'I' constant in the given parameter slot. This is multiplied by accumulated closed loop error in sensor units every PID Loop. Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '0.00025' to get full output if err is 4096u for 1000 loops (accumulater holds 4,096,000), [which is equivalent to one CTRE mag encoder rotation for 1000 milliseconds].- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the I constant.- Returns:
- Error Code generated by function. 0 indicates no error.
-
config_kD
Sets the 'D' constant in the given parameter slot. This is multiplied by derivative error (sensor units per PID loop, typically 1ms). Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '250' to get full output if derr is 4096u (Mag Encoder 1 rotation) per 1000 loops (typ 1 sec)- Specified by:
config_kD
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the D constant.timeoutMs
- Timeout 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.
-
config_kD
Sets the 'D' constant in the given parameter slot. This is multiplied by derivative error (sensor units per PID loop, typically 1ms). Note the closed loop output interprets a final value of 1023 as full output. So use a gain of '250' to get full output if derr is 4096u (Mag Encoder 1 rotation) per 1000 loops (typ 1 sec)- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the D constant.- Returns:
- Error Code generated by function. 0 indicates no error.
-
config_kF
Sets the 'F' constant in the given parameter slot. See documentation for calculation details. If using velocity, motion magic, or motion profile, use (1023 * duty-cycle / sensor-velocity-sensor-units-per-100ms).- Specified by:
config_kF
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the F constant.timeoutMs
- Timeout 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.
-
config_kF
Sets the 'F' constant in the given parameter slot. See documentation for calculation details. If using velocity, motion magic, or motion profile, use (1023 * duty-cycle / sensor-velocity-sensor-units-per-100ms).- Parameters:
slotIdx
- Parameter slot for the constant.value
- Value of the F constant.- Returns:
- Error Code generated by function. 0 indicates no error.
-
config_IntegralZone
Sets the Integral Zone constant in the given parameter slot. If the (absolute) closed-loop error is outside of this zone, integral accumulator is automatically cleared. This ensures than integral wind up events will stop after the sensor gets far enough from its target.- Specified by:
config_IntegralZone
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.izone
- Value of the Integral Zone constant (closed loop error units X 1ms).timeoutMs
- Timeout 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.
-
config_IntegralZone
Sets the Integral Zone constant in the given parameter slot. If the (absolute) closed-loop error is outside of this zone, integral accumulator is automatically cleared. This ensures than integral wind up events will stop after the sensor gets far enough from its target.- Parameters:
slotIdx
- Parameter slot for the constant.izone
- Value of the Integral Zone constant (closed loop error units X 1ms).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configAllowableClosedloopError
public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableClosedLoopError, int timeoutMs)Sets the allowable closed-loop error in the given parameter slot.- Specified by:
configAllowableClosedloopError
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.allowableClosedLoopError
- Value of the allowable closed-loop error in sensor units (or sensor units per 100ms for velocity).timeoutMs
- Timeout 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.
-
configAllowableClosedloopError
Sets the allowable closed-loop error in the given parameter slot.- Parameters:
slotIdx
- Parameter slot for the constant.allowableClosedLoopError
- Value of the allowable closed-loop error in sensor units (or sensor units per 100ms for velocity).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configMaxIntegralAccumulator
Sets the maximum integral accumulator in the given parameter slot.- Specified by:
configMaxIntegralAccumulator
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.iaccum
- Value of the maximum integral accumulator (closed loop error units X 1ms).timeoutMs
- Timeout 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.
-
configMaxIntegralAccumulator
Sets the maximum integral accumulator in the given parameter slot.- Parameters:
slotIdx
- Parameter slot for the constant.iaccum
- Value of the maximum integral accumulator (closed loop error units X 1ms).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configClosedLoopPeakOutput
Sets the peak closed-loop output. This peak output is slot-specific and is applied to the output of the associated PID loop. This setting is seperate from the generic Peak Output setting.- Specified by:
configClosedLoopPeakOutput
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.percentOut
- Peak Percent Output from 0 to 1. This value is absolute and the magnitude will apply in both forward and reverse directions.timeoutMs
- Timeout 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.
-
configClosedLoopPeakOutput
Sets the peak closed-loop output. This peak output is slot-specific and is applied to the output of the associated PID loop. This setting is seperate from the generic Peak Output setting.- Parameters:
slotIdx
- Parameter slot for the constant.percentOut
- Peak Percent Output from 0 to 1. This value is absolute and the magnitude will apply in both forward and reverse directions.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configClosedLoopPeriod
Sets the loop time (in milliseconds) of the PID closed-loop calculations. Default value is 1 ms.- Specified by:
configClosedLoopPeriod
in interfaceIMotorController
- Parameters:
slotIdx
- Parameter slot for the constant.loopTimeMs
- Loop timing of the closed-loop calculations. Minimum value of 1 ms, maximum of 64 ms.timeoutMs
- Timeout 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.
-
configClosedLoopPeriod
Sets the loop time (in milliseconds) of the PID closed-loop calculations. Default value is 1 ms.- Parameters:
slotIdx
- Parameter slot for the constant.loopTimeMs
- Loop timing of the closed-loop calculations. Minimum value of 1 ms, maximum of 64 ms.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configAuxPIDPolarity
Configures the Polarity of the Auxiliary PID (PID1). Standard Polarity: Primary Output = PID0 + PID1, Auxiliary Output = PID0 - PID1, Inverted Polarity: Primary Output = PID0 - PID1, Auxiliary Output = PID0 + PID1,- Specified by:
configAuxPIDPolarity
in interfaceIMotorController
- Parameters:
invert
- If true, use inverted PID1 output polarity.timeoutMs
- Timeout 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
-
configAuxPIDPolarity
Configures the Polarity of the Auxiliary PID (PID1). Standard Polarity: Primary Output = PID0 + PID1, Auxiliary Output = PID0 - PID1, Inverted Polarity: Primary Output = PID0 - PID1, Auxiliary Output = PID0 + PID1,- Parameters:
invert
- If true, use inverted PID1 output polarity.- Returns:
- Error Code
-
setIntegralAccumulator
Sets the integral accumulator. Typically this is used to clear/zero the integral accumulator, however some use cases may require seeding the accumulator for a faster response.- Specified by:
setIntegralAccumulator
in interfaceIMotorController
- Parameters:
iaccum
- Value to set for the integral accumulator (closed loop error units X 1ms).pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
setIntegralAccumulator
Sets the integral accumulator. Typically this is used to clear/zero the integral accumulator, however some use cases may require seeding the accumulator for a faster response.- Parameters:
iaccum
- Value to set for the integral accumulator (closed loop error units X 1ms).- Returns:
- Error Code generated by function. 0 indicates no error.
-
getClosedLoopError
Gets the closed-loop error. The units depend on which control mode is in use. If closed-loop is seeking a target sensor position, closed-loop error is the difference between target and current sensor value (in sensor units. Example 4096 units per rotation for CTRE Mag Encoder). If closed-loop is seeking a target sensor velocity, closed-loop error is the difference between target and current sensor value (in sensor units per 100ms). If using motion profiling or Motion Magic, closed loop error is calculated against the current target, and not the "final" target at the end of the profile/movement. See Phoenix-Documentation information on units.- Specified by:
getClosedLoopError
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- Closed-loop error value.
-
getClosedLoopError
Gets the closed-loop error. The units depend on which control mode is in use. If closed-loop is seeking a target sensor position, closed-loop error is the difference between target and current sensor value (in sensor units. Example 4096 units per rotation for CTRE Mag Encoder). If closed-loop is seeking a target sensor velocity, closed-loop error is the difference between target and current sensor value (in sensor units per 100ms). If using motion profiling or Motion Magic, closed loop error is calculated against the current target, and not the "final" target at the end of the profile/movement. See Phoenix-Documentation information on units.- Returns:
- Closed-loop error value.
-
getIntegralAccumulator
Gets the iaccum value.- Specified by:
getIntegralAccumulator
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- Integral accumulator value (Closed-loop error X 1ms).
-
getIntegralAccumulator
Gets the iaccum value.- Returns:
- Integral accumulator value (Closed-loop error X 1ms).
-
getErrorDerivative
Gets the derivative of the closed-loop error.- Specified by:
getErrorDerivative
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- The error derivative value.
-
getErrorDerivative
Gets the derivative of the closed-loop error.- Returns:
- The error derivative value.
-
selectProfileSlot
Selects which profile slot to use for closed-loop control.- Specified by:
selectProfileSlot
in interfaceIMotorController
- Parameters:
slotIdx
- Profile slot to select.pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.
-
getClosedLoopTarget
Gets the current target of a given closed loop.- Specified by:
getClosedLoopTarget
in interfaceIMotorController
- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- The closed loop target.
-
getClosedLoopTarget
Gets the current target of a given closed loop.- Returns:
- The closed loop target.
-
getActiveTrajectoryPosition
Gets the active trajectory target position for pid0 using MotionMagic/MotionProfile control modes.- Specified by:
getActiveTrajectoryPosition
in interfaceIMotorController
- Returns:
- The Active Trajectory Position in sensor units.
-
getActiveTrajectoryPosition
Gets the active trajectory target position using MotionMagic/MotionProfile control modes.- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- The Active Trajectory Position in sensor units.
-
getActiveTrajectoryVelocity
Gets the active trajectory target velocity for pid0 using MotionMagic/MotionProfile control modes.- Specified by:
getActiveTrajectoryVelocity
in interfaceIMotorController
- Returns:
- The Active Trajectory Velocity in sensor units per 100ms.
-
getActiveTrajectoryVelocity
Gets the active trajectory target velocity using MotionMagic/MotionProfile control modes.- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- The Active Trajectory Velocity in sensor units per 100ms.
-
getActiveTrajectoryArbFeedFwd
Gets the active trajectory arbitrary feedforward for pid0 using MotionMagic/MotionProfile control modes.- Returns:
- The Active Trajectory ArbFeedFwd in units of percent output (where 0.01 is 1%).
-
getActiveTrajectoryArbFeedFwd
Gets the active trajectory arbitrary feedforward using MotionMagic/MotionProfile control modes.- Parameters:
pidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.- Returns:
- The Active Trajectory ArbFeedFwd in units of percent output (where 0.01 is 1%).
-
configMotionCruiseVelocity
Sets the Motion Magic Cruise Velocity. This is the peak target velocity that the motion magic curve generator can use.- Specified by:
configMotionCruiseVelocity
in interfaceIMotorController
- Parameters:
sensorUnitsPer100ms
- Motion Magic Cruise Velocity (in raw sensor units per 100 ms).timeoutMs
- Timeout 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.
-
configMotionCruiseVelocity
Sets the Motion Magic Cruise Velocity. This is the peak target velocity that the motion magic curve generator can use.- Parameters:
sensorUnitsPer100ms
- Motion Magic Cruise Velocity (in raw sensor units per 100 ms).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configMotionAcceleration
Sets the Motion Magic Acceleration. This is the target acceleration that the motion magic curve generator can use.- Specified by:
configMotionAcceleration
in interfaceIMotorController
- Parameters:
sensorUnitsPer100msPerSec
- Motion Magic Acceleration (in raw sensor units per 100 ms per second).timeoutMs
- Timeout 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.
-
configMotionAcceleration
Sets the Motion Magic Acceleration. This is the target acceleration that the motion magic curve generator can use.- Parameters:
sensorUnitsPer100msPerSec
- Motion Magic Acceleration (in raw sensor units per 100 ms per second).- Returns:
- Error Code generated by function. 0 indicates no error.
-
configMotionSCurveStrength
Sets the Motion Magic S Curve Strength. Call this before using Motion Magic. Modifying this during a Motion Magic action should be avoided.- Specified by:
configMotionSCurveStrength
in interfaceIMotorController
- Parameters:
curveStrength
- 0 to use Trapezoidal Motion Profile. [1,8] for S-Curve (greater value yields greater smoothing).timeoutMs
- Timeout 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.
-
configMotionSCurveStrength
Sets the Motion Magic S Curve Strength. Call this before using Motion Magic. Modifying this during a Motion Magic action should be avoided.- Parameters:
curveStrength
- 0 to use Trapezoidal Motion Profile. [1,8] for S-Curve (greater value yields greater smoothing).- Returns:
- Error Code generated by function. 0 indicates no error.
-
clearMotionProfileTrajectories
Clear the buffered motion profile in both controller's RAM (bottom), and in the API (top).- Specified by:
clearMotionProfileTrajectories
in interfaceIMotorController
- Returns:
- Error Code generated by function. 0 indicates no error.
-
getMotionProfileTopLevelBufferCount
Retrieve just the buffer count for the api-level (top) buffer. This routine performs no CAN or data structure lookups, so its fast and ideal if caller needs to quickly poll the progress of trajectory points being emptied into controller's RAM. Otherwise just use GetMotionProfileStatus.- Specified by:
getMotionProfileTopLevelBufferCount
in interfaceIMotorController
- Returns:
- number of trajectory points in the top buffer.
-
pushMotionProfileTrajectory
Push another trajectory point into the top level buffer (which is emptied into the motor controller's bottom buffer as room allows).- Specified by:
pushMotionProfileTrajectory
in interfaceIMotorController
- Parameters:
trajPt
- to push into buffer. The members should be filled in with these values... targPos: servo position in sensor units. targVel: velocity to feed-forward in sensor units per 100ms. 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 the a particular slot, but you are free 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]. isLastPoint set to nonzero to signal motor controller to keep processing this trajectory point, instead of jumping to the next one when timeDurMs expires. Otherwise MP executer will eventually see an empty buffer after the last point expires, causing it to assert the IsUnderRun flag. However this may be desired if calling application never wants to terminate the MP. zeroPos set to nonzero to signal motor controller to "zero" the selected position sensor before executing this trajectory point. Typically the first point should have this set only thus allowing the remainder of the MP positions to be relative to zero. timeDur Duration to apply this trajectory pt. This time unit is ADDED to the exising base time set by configMotionProfileTrajectoryPeriod().- Returns:
- CTR_OKAY if trajectory point push ok. ErrorCode if buffer is full due to kMotionProfileTopBufferCapacity.
-
startMotionProfile
public ErrorCode startMotionProfile(BufferedTrajectoryPointStream stream, int minBufferedPts, ControlMode motionProfControlMode)Simple one-shot firing of a complete MP. Starting in 2019, MPs can be fired by building a Buffered Trajectory Point Stream, and calling this routine. Once called, the motor controller software will automatically ... [1] Clear the firmware buffer of trajectory points. [2] Clear the underrun flags [3] Reset an index within the Buffered Trajectory Point Stream (so that the same profile can be run again and again). [4] Start a background thread to manage MP streaming (if not already running). [5a] If current control mode already matches motionProfControlMode, set MPE Output to "Hold". [5b] If current control mode does not matches motionProfControlMode, apply motionProfControlMode and set MPE Output to "Disable". [6] Stream the trajectory points into the device's firmware buffer. [7] Once motor controller has at least minBufferedPts worth in the firmware buffer, MP will automatically start (MPE Output set to "Enable"). [8] Wait until MP finishes, then transitions the Motion Profile Executor's output to "Hold". [9] IsMotionProfileFinished() will now return true. Calling application can use IsMotionProfileFinished() to determine when internal state machine reaches [7]. Calling application can cancel MP by calling set(). Otherwise do not call set() until MP has completed. The legacy API from previous years requires the calling application to pass points via the ProcessMotionProfileBuffer and PushMotionProfileTrajectory. This is no longer required if using this StartMotionProfile/IsMotionProfileFinished API.- Parameters:
stream
- A buffer that will be used to stream the trajectory points. Caller can fill this container with the entire trajectory point, regardless of size.minBufferedPts
- Minimum number of firmware buffered points before starting MP. Do not exceed device's firmware buffer capacity or MP will never fire (120 for Motion Profile, or 60 for Motion Profile Arc). Recommendation value for this would be five to ten samples depending on timeDur of the trajectory point.motionProfControlMode
- Pass MotionProfile or MotionProfileArc.- Returns:
- nonzero error code if operation fails.
-
isMotionProfileFinished
Determine if running MP is complete. This requires using the StartMotionProfile routine to start the MP. That is because managing the trajectory points is now done in a background thread (if StartMotionProfile is called). If calling application uses the legacy API (more-complex buffering API) from previous years, than this API will not return true.- Returns:
- true if MP was started using StartMotionProfile, and it has completed execution (MPE is now in "hold").
-
isMotionProfileTopLevelBufferFull
Retrieve just the buffer full for the api-level (top) buffer. This routine performs no CAN or data structure lookups, so its fast and ideal if caller needs to quickly poll. Otherwise just use GetMotionProfileStatus.- Specified by:
isMotionProfileTopLevelBufferFull
in interfaceIMotorController
- Returns:
- number of trajectory points in the top buffer.
-
processMotionProfileBuffer
This must be called periodically to funnel the trajectory points from the API's top level buffer to the controller's bottom level buffer. Recommendation is to call this twice as fast as the execution rate of the motion profile. So if MP is running with 20ms trajectory points, try calling this routine every 10ms. All motion profile functions are thread-safe through the use of a mutex, so there is no harm in having the caller utilize threading.- Specified by:
processMotionProfileBuffer
in interfaceIMotorController
-
getMotionProfileStatus
Retrieve all status information. For best performance, Caller can snapshot all status information regarding the motion profile executer.- Specified by:
getMotionProfileStatus
in interfaceIMotorController
- Parameters:
statusToFill
- Caller supplied object to fill. The members are filled, as follows... 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 low-level buffer, allowing the motor controller to act on them. topBufferRem: The number of points in the top trajectory buffer. btmBufferCnt: The number of points in the low level controller buffer. hasUnderrun: Set if isUnderrun ever gets set. Can be manually cleared by clearMotionProfileHasUnderrun() or automatically cleared by startMotionProfile(). isUnderrun: This is set if controller 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. activePointValid: True if the active trajectory point is not empty, false otherwise. The members in activePoint are only valid if this signal is set. 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. profileSlotSelect: The currently processed trajectory point's selected slot. This can differ in the currently selected slot used for Position and Velocity servo modes 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.- Returns:
- Error Code generated by function. 0 indicates no error.
-
clearMotionProfileHasUnderrun
Clear the "Has Underrun" flag. Typically this is called after application has confirmed an underrun had occured.- Specified by:
clearMotionProfileHasUnderrun
in interfaceIMotorController
- Parameters:
timeoutMs
- Timeout 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.
-
clearMotionProfileHasUnderrun
Clear the "Has Underrun" flag. Typically this is called after application has confirmed an underrun had occured.- Returns:
- Error Code generated by function. 0 indicates no error.
-
changeMotionControlFramePeriod
Calling application can opt to speed up the handshaking between the robot API and the controller to increase the download rate of the controller's Motion Profile. Ideally the period should be no more than half the period of a trajectory point.- Specified by:
changeMotionControlFramePeriod
in interfaceIMotorController
- Parameters:
periodMs
- The transmit period in ms.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configMotionProfileTrajectoryPeriod
When trajectory points are processed in the motion profile executer, the MPE determines how long to apply the active trajectory point by summing baseTrajDurationMs with the timeDur of the trajectory point (see TrajectoryPoint). This allows general selection of the execution rate of the points with 1ms resolution, while allowing some degree of change from point to point.- Specified by:
configMotionProfileTrajectoryPeriod
in interfaceIMotorController
- Parameters:
baseTrajDurationMs
- The base duration time of every trajectory point. This is summed with the trajectory points unique timeDur.timeoutMs
- Timeout 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.
-
configMotionProfileTrajectoryPeriod
When trajectory points are processed in the motion profile executer, the MPE determines how long to apply the active trajectory point by summing baseTrajDurationMs with the timeDur of the trajectory point (see TrajectoryPoint). This allows general selection of the execution rate of the points with 1ms resolution, while allowing some degree of change from point to point.- Parameters:
baseTrajDurationMs
- The base duration time of every trajectory point. This is summed with the trajectory points unique timeDur.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configMotionProfileTrajectoryInterpolationEnable
When trajectory points are processed in the buffer, the motor controller can linearly interpolate additional trajectory points between the buffered points. The time delta between these interpolated points is 1 ms. By default this feature is enabled.- Parameters:
enable
- Whether to enable the trajectory point interpolation feature.timeoutMs
- Timeout 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.
-
configMotionProfileTrajectoryInterpolationEnable
When trajectory points are processed in the buffer, the motor controller can linearly interpolate additional trajectory points between the buffered points. The time delta between these interpolated points is 1 ms. By default this feature is enabled.- Parameters:
enable
- Whether to enable the trajectory point interpolation feature.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configFeedbackNotContinuous
Disables continuous tracking of the position for analog and pulse-width. If the signal goes from 4095 to 0 (pulse-width) a motor controller will continue to read 4096 by default. If overflow tracking is disabled, it will wrap to 0 (not continuous) If using pulse-width on CTRE Mag Encoder (within one rotation) or absolute analog sensor (within one rotation), setting feedbackNotContinuous to true is recommended, to prevent intermittent connections from causing sensor "jumps" of 4096 (or 1024 for analog) units.- Parameters:
feedbackNotContinuous
- True to disable the overflow tracking.timeoutMs
- Timeout 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.
-
configRemoteSensorClosedLoopDisableNeutralOnLOS
public ErrorCode configRemoteSensorClosedLoopDisableNeutralOnLOS(boolean remoteSensorClosedLoopDisableNeutralOnLOS, int timeoutMs)Disables going to neutral (brake/coast) when a remote sensor is no longer detected.- Parameters:
remoteSensorClosedLoopDisableNeutralOnLOS
- disable going to neutraltimeoutMs
- Timeout 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.
-
configClearPositionOnLimitF
Enables clearing the position of the feedback sensor when the forward limit switch is triggered.- Parameters:
clearPositionOnLimitF
- Whether clearing is enabled, defaults falsetimeoutMs
- Timeout 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.
-
configClearPositionOnLimitR
Enables clearing the position of the feedback sensor when the reverse limit switch is triggered- Parameters:
clearPositionOnLimitR
- Whether clearing is enabled, defaults falsetimeoutMs
- Timeout 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.
-
configClearPositionOnQuadIdx
Enables clearing the position of the feedback sensor when the quadrature index signal is detected- Parameters:
clearPositionOnQuadIdx
- Whether clearing is enabled, defaults falsetimeoutMs
- Timeout 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.
-
configLimitSwitchDisableNeutralOnLOS
public ErrorCode configLimitSwitchDisableNeutralOnLOS(boolean limitSwitchDisableNeutralOnLOS, int timeoutMs)Disables limit switches triggering (if enabled) when the sensor is no longer detected.- Parameters:
limitSwitchDisableNeutralOnLOS
- disable triggeringtimeoutMs
- Timeout 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.
-
configSoftLimitDisableNeutralOnLOS
public ErrorCode configSoftLimitDisableNeutralOnLOS(boolean softLimitDisableNeutralOnLOS, int timeoutMs)Disables soft limits triggering (if enabled) when the sensor is no longer detected.- Parameters:
softLimitDisableNeutralOnLOS
- disable triggeringtimeoutMs
- Timeout 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.
-
configPulseWidthPeriod_EdgesPerRot
public ErrorCode configPulseWidthPeriod_EdgesPerRot(int pulseWidthPeriod_EdgesPerRot, int timeoutMs)Sets the edges per rotation of a pulse width sensor. (This should be set for tachometer use).- Parameters:
pulseWidthPeriod_EdgesPerRot
- edges per rotationtimeoutMs
- Timeout 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.
-
configPulseWidthPeriod_FilterWindowSz
public ErrorCode configPulseWidthPeriod_FilterWindowSz(int pulseWidthPeriod_FilterWindowSz, int timeoutMs)Sets the number of samples to use in smoothing a pulse width sensor with a rolling average. Default is 1 (no smoothing).- Parameters:
pulseWidthPeriod_FilterWindowSz
- samples for rolling avgtimeoutMs
- Timeout 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.
-
getLastError
Gets the last error 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.- Specified by:
getLastError
in interfaceIMotorController
- Returns:
- Last Error Code generated by a function.
-
getFaults
Polls the various fault flags.- Specified by:
getFaults
in interfaceIMotorController
- Parameters:
toFill
- Caller's object to fill with latest fault flags.- Returns:
- Last Error Code generated by a function.
-
getStickyFaults
Polls the various sticky fault flags.- Specified by:
getStickyFaults
in interfaceIMotorController
- Parameters:
toFill
- Caller's object to fill with latest sticky fault flags.- Returns:
- Last Error Code generated by a function.
-
clearStickyFaults
Clears all sticky faults.- Specified by:
clearStickyFaults
in interfaceIMotorController
- Parameters:
timeoutMs
- Timeout 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:
- Last Error Code generated by a function.
-
clearStickyFaults
Clears all sticky faults.- Returns:
- Last Error Code generated by a function.
-
getFirmwareVersion
Gets the firmware version of the device.- Specified by:
getFirmwareVersion
in interfaceIMotorController
- Returns:
- Firmware version of device. For example: version 1-dot-2 is 0x0102.
-
hasResetOccurred
Returns true if the device has reset since last call.- Specified by:
hasResetOccurred
in interfaceIMotorController
- Returns:
- Has a Device Reset Occurred?
-
configSetCustomParam
Sets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/limit/target information in the device. Particularly if the device is part of a subsystem that can be replaced.- Specified by:
configSetCustomParam
in interfaceIMotorController
- Parameters:
newValue
- Value for custom parameter.paramIndex
- Index of custom parameter [0,1]timeoutMs
- Timeout 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
Sets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/limit/target information in the device. Particularly if the device is part of a subsystem that can be replaced.- Parameters:
newValue
- Value for custom parameter.paramIndex
- Index of custom parameter [0,1]- Returns:
- Error Code generated by function. 0 indicates no error.
-
configGetCustomParam
Gets the value of a custom parameter.- Specified by:
configGetCustomParam
in interfaceIMotorController
- Parameters:
paramIndex
- Index of custom parameter [0,1].timeoutMs
- Timeout 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.
-
configGetCustomParam
Gets the value of a custom parameter.- Parameters:
paramIndex
- Index of custom parameter [0,1].- Returns:
- Value of the custom param.
-
configSetParameter
public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)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.- Specified by:
configSetParameter
in interfaceIMotorController
- Parameters:
param
- Parameter enumeration.value
- Value of parameter.subValue
- Subvalue for parameter. Maximum value of 255.ordinal
- Ordinal of parameter.timeoutMs
- Timeout 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
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:
param
- Parameter enumeration.value
- Value of parameter.subValue
- Subvalue for parameter. Maximum value of 255.ordinal
- Ordinal of parameter.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configSetParameter
public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs)Sets a parameter.- Specified by:
configSetParameter
in interfaceIMotorController
- Parameters:
param
- Parameter enumeration.value
- Value of parameter.subValue
- Subvalue for parameter. Maximum value of 255.ordinal
- Ordinal of parameter.timeoutMs
- Timeout 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
Sets a parameter.- Parameters:
param
- Parameter enumeration.value
- Value of parameter.subValue
- Subvalue for parameter. Maximum value of 255.ordinal
- Ordinal of parameter.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configGetParameter
Gets a parameter.- Specified by:
configGetParameter
in interfaceIMotorController
- Parameters:
param
- Parameter enumeration.ordinal
- Ordinal of parameter.timeoutMs
- Timeout 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.
-
configGetParameter
Gets a parameter.- Parameters:
param
- Parameter enumeration.ordinal
- Ordinal of parameter.- Returns:
- Value of parameter.
-
configGetParameter
Gets a parameter.- Specified by:
configGetParameter
in interfaceIMotorController
- Parameters:
param
- Parameter enumeration.ordinal
- Ordinal of parameter.timeoutMs
- Timeout 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.
-
configGetParameter
Gets a parameter.- Parameters:
param
- Parameter enumeration.ordinal
- Ordinal of parameter.- Returns:
- Value of parameter.
-
getBaseID
- Specified by:
getBaseID
in interfaceIMotorController
- Returns:
- BaseID of device
-
getControlMode
- Specified by:
getControlMode
in interfaceIMotorController
- Returns:
- control mode motor controller is in
-
follow
Set the control mode and output value so that this motor controller will follow another motor controller. Currently supports following Victor SPX, Talon SRX, and Talon FX.- Parameters:
masterToFollow
- Motor Controller object to follow.followerType
- Type of following control. Use AuxOutput1 to follow the master device's auxiliary output 1. Use PercentOutput for standard follower mode.
-
follow
Set the control mode and output value so that this motor controller will follow another motor controller. Currently supports following Victor SPX, Talon SRX, and Talon FX. -
valueUpdated
When master makes a device, this routine is called to signal the update.- Specified by:
valueUpdated
in interfaceIFollower
-
baseConfigAllSettings
protected ErrorCode baseConfigAllSettings(BaseMotorControllerConfiguration allConfigs, int timeoutMs)Configures all base persistant settings.- Parameters:
allConfigs
- Object with all of the base persistant settingstimeoutMs
- Timeout 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.
-
configureSlot
Configures all slot persistant settings (overloaded so timeoutMs is 50 ms and slotIdx is 0- Parameters:
slot
- Object with all of the slot persistant settings- Returns:
- Error Code generated by function. 0 indicates no error.
-
configureSlot
Configures all slot persistant settings- Parameters:
slot
- Object with all of the slot persistant settingsslotIdx
- Index of slot to configuretimeoutMs
- Timeout 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.
-
getSlotConfigs
Gets all slot persistant settings.- Parameters:
slot
- Object with all of the slot persistant settingsslotIdx
- Parameter slot for the constant.timeoutMs
- Timeout 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.
-
getSlotConfigs
Gets all slot persistant settings (overloaded so timeoutMs is 50 ms and slotIdx is 0- Parameters:
slot
- Object with all of the slot persistant settings
-
configureFilter
@Deprecated public ErrorCode configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs, boolean enableOptimizations)Deprecated.Use the 3-parameter configureFilter. 4-param version is deprecated and will be removed.Configures all filter persistant settings.- Parameters:
filter
- Object with all of the filter persistant settingsordinal
- 0 for remote sensor 0 and 1 for remote sensor 1.timeoutMs
- Timeout 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.enableOptimizations
- Enable the optimization technique- Returns:
- Error Code generated by function. 0 indicates no error.
-
configureFilter
@Deprecated public ErrorCode configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs)Deprecated.Use configAll instead.Configures all filter persistant settings.- Parameters:
filter
- Object with all of the filter persistant settingsordinal
- 0 for remote sensor 0 and 1 for remote sensor 1.timeoutMs
- Timeout 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.
-
configureFilter
Deprecated.Use configAll instead.Configures all filter persistant settings (overloaded so timeoutMs is 50 ms and ordinal is 0).- Parameters:
filter
- Object with all of the filter persistant settings- Returns:
- Error Code generated by function. 0 indicates no error.
-
getFilterConfigs
Gets all filter persistant settings.- Parameters:
filter
- Object with all of the filter persistant settingsordinal
- 0 for remote sensor 0 and 1 for remote sensor 1.timeoutMs
- Timeout 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.
-
getFilterConfigs
Gets all filter persistant settings (overloaded so timeoutMs is 50 ms and ordinal is 0).- Parameters:
filter
- Object with all of the filter persistant settings
-
baseConfigurePID
Configures all base PID set persistant settings.- Parameters:
pid
- Object with all of the base PID set persistant settingspidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
baseGetPIDConfigs
Gets all base PID set persistant settings.- Parameters:
pid
- Object with all of the base PID set persistant settingspidIdx
- 0 for Primary closed-loop. 1 for auxiliary closed-loop.timeoutMs
- Timeout 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.
-
baseGetAllConfigs
Gets all base persistant settings.- Parameters:
allConfigs
- Object with all of the base persistant settingstimeoutMs
- Timeout 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.
-