Class WPI_TalonSRX
java.lang.Object
com.ctre.phoenix.motorcontrol.can.BaseMotorController
com.ctre.phoenix.motorcontrol.can.BaseTalon
com.ctre.phoenix.motorcontrol.can.TalonSRX
com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX
- All Implemented Interfaces:
IFollower
,IMotorController
,IMotorControllerEnhanced
,IInvertable
,IOutputSignal
,Sendable
,MotorController
,AutoCloseable
public class WPI_TalonSRX extends TalonSRX implements MotorController, Sendable, AutoCloseable
CTRE Talon SRX Motor Controller when used on CAN Bus.
-
Field Summary
Fields Modifier and Type Field Description static double
kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature. -
Constructor Summary
Constructors Constructor Description WPI_TalonSRX(int deviceNumber)
Constructor for motor controller -
Method Summary
Modifier and Type Method Description void
close()
void
disable()
Common interface for disabling a motor.void
feed()
Feed the motor safety object.double
get()
Common interface for getting the current set speed of a speed controller.String
getDescription()
double
getExpiration()
Retrieve the timeout value for the corresponding motor safety object.boolean
getInverted()
Common interface for returning the inversion state of a speed controller.void
initSendable(SendableBuilder builder)
Initialize sendableboolean
isAlive()
Determine of the motor is still operating or has timed out.boolean
isSafetyEnabled()
Return the state of the motor safety enabled flag.void
set(double speed)
Common interface for setting the speed of a simple speed controller.void
set(ControlMode mode, double value)
Sets the appropriate output on the talon, depending on the mode.void
set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
void
setExpiration(double expirationTime)
Set the expiration time for the corresponding motor safety object.void
setInverted(boolean isInverted)
Common interface for inverting direction of a speed controller.void
setSafetyEnabled(boolean enabled)
Enable/disable motor safety for this device.void
setVoltage(double outputVolts)
Sets the voltage output of the SpeedController.void
stopMotor()
Common interface to stop the motor until Set is called again.Methods inherited from class com.ctre.phoenix.motorcontrol.can.TalonSRX
configAllSettings, configAllSettings, configContinuousCurrentLimit, configContinuousCurrentLimit, configPeakCurrentDuration, configPeakCurrentDuration, configPeakCurrentLimit, configPeakCurrentLimit, configSelectedFeedbackSensor, configSupplyCurrentLimit, configSupplyCurrentLimit, configurePID, configurePID, enableCurrentLimit, getAllConfigs, getAllConfigs, getPIDConfigs, getPIDConfigs, getSensorCollection, getSimCollection, set, set
Methods inherited from class com.ctre.phoenix.motorcontrol.can.BaseTalon
configAllSettings, configAllSettings, configForwardLimitSwitchSource, configForwardLimitSwitchSource, configReverseLimitSwitchSource, configReverseLimitSwitchSource, configurePID, configurePID, configVelocityMeasurementPeriod, configVelocityMeasurementPeriod, configVelocityMeasurementPeriod, configVelocityMeasurementPeriod, configVelocityMeasurementWindow, configVelocityMeasurementWindow, getAllConfigs, getAllConfigs, getOutputCurrent, getPIDConfigs, getPIDConfigs, getStatorCurrent, getStatusFramePeriod, getStatusFramePeriod, getSupplyCurrent, getTalonFXSensorCollection, getTalonFXSimCollection, getTalonSRXSensorCollection, getTalonSRXSimCollection, isFwdLimitSwitchClosed, isRevLimitSwitchClosed, setStatusFramePeriod, setStatusFramePeriod
Methods inherited from class com.ctre.phoenix.motorcontrol.can.BaseMotorController
baseConfigAllSettings, baseConfigurePID, baseGetAllConfigs, baseGetPIDConfigs, changeMotionControlFramePeriod, clearMotionProfileHasUnderrun, clearMotionProfileHasUnderrun, clearMotionProfileTrajectories, clearStickyFaults, clearStickyFaults, config_IntegralZone, config_IntegralZone, config_kD, config_kD, config_kF, config_kF, config_kI, config_kI, config_kP, config_kP, configAllowableClosedloopError, configAllowableClosedloopError, configAuxPIDPolarity, configAuxPIDPolarity, configClearPositionOnLimitF, configClearPositionOnLimitR, configClearPositionOnQuadIdx, configClosedLoopPeakOutput, configClosedLoopPeakOutput, configClosedLoopPeriod, configClosedLoopPeriod, configClosedloopRamp, configClosedloopRamp, configFactoryDefault, configFactoryDefault, configFeedbackNotContinuous, configForwardLimitSwitchSource, configForwardLimitSwitchSource, configForwardLimitSwitchSource, configForwardSoftLimitEnable, configForwardSoftLimitEnable, configForwardSoftLimitThreshold, configForwardSoftLimitThreshold, configGetCustomParam, configGetCustomParam, configGetParameter, configGetParameter, configGetParameter, configGetParameter, configLimitSwitchDisableNeutralOnLOS, configMaxIntegralAccumulator, configMaxIntegralAccumulator, configMotionAcceleration, configMotionAcceleration, configMotionCruiseVelocity, configMotionCruiseVelocity, configMotionProfileTrajectoryInterpolationEnable, configMotionProfileTrajectoryInterpolationEnable, configMotionProfileTrajectoryPeriod, configMotionProfileTrajectoryPeriod, configMotionSCurveStrength, configMotionSCurveStrength, configNeutralDeadband, configNeutralDeadband, configNominalOutputForward, configNominalOutputForward, configNominalOutputReverse, configNominalOutputReverse, configOpenloopRamp, configOpenloopRamp, configPeakOutputForward, configPeakOutputForward, configPeakOutputReverse, configPeakOutputReverse, configPulseWidthPeriod_EdgesPerRot, configPulseWidthPeriod_FilterWindowSz, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteSensorClosedLoopDisableNeutralOnLOS, configReverseLimitSwitchSource, configReverseLimitSwitchSource, configReverseLimitSwitchSource, configReverseSoftLimitEnable, configReverseSoftLimitEnable, configReverseSoftLimitThreshold, configReverseSoftLimitThreshold, configSelectedFeedbackCoefficient, configSelectedFeedbackCoefficient, configSelectedFeedbackSensor, configSelectedFeedbackSensor, configSelectedFeedbackSensor, configSelectedFeedbackSensor, configSensorTerm, configSensorTerm, configSensorTerm, configSensorTerm, configSetCustomParam, configSetCustomParam, configSetParameter, configSetParameter, configSetParameter, configSetParameter, configSoftLimitDisableNeutralOnLOS, configureFilter, configureFilter, configureFilter, configureSlot, configureSlot, configVoltageCompSaturation, configVoltageCompSaturation, configVoltageMeasurementFilter, configVoltageMeasurementFilter, DestroyObject, enableVoltageCompensation, follow, follow, getActiveTrajectoryArbFeedFwd, getActiveTrajectoryArbFeedFwd, getActiveTrajectoryPosition, getActiveTrajectoryPosition, getActiveTrajectoryVelocity, getActiveTrajectoryVelocity, getBaseID, getBusVoltage, getClosedLoopError, getClosedLoopError, getClosedLoopTarget, getClosedLoopTarget, getControlMode, getDeviceID, getErrorDerivative, getErrorDerivative, getFaults, getFilterConfigs, getFilterConfigs, getFirmwareVersion, getHandle, getIntegralAccumulator, getIntegralAccumulator, getLastError, getMotionProfileStatus, getMotionProfileTopLevelBufferCount, getMotorOutputPercent, getMotorOutputVoltage, getSelectedSensorPosition, getSelectedSensorPosition, getSelectedSensorVelocity, getSelectedSensorVelocity, getSlotConfigs, getSlotConfigs, getStatusFramePeriod, getStatusFramePeriod, getStatusFramePeriod, getStatusFramePeriod, getStickyFaults, getTemperature, getVictorSPXSimCollection, hasResetOccurred, isMotionProfileFinished, isMotionProfileTopLevelBufferFull, isVoltageCompensationEnabled, neutralOutput, overrideLimitSwitchesEnable, overrideSoftLimitsEnable, processMotionProfileBuffer, pushMotionProfileTrajectory, selectProfileSlot, setControlFramePeriod, setControlFramePeriod, setIntegralAccumulator, setIntegralAccumulator, setInverted, setNeutralMode, setSelectedSensorPosition, setSelectedSensorPosition, setSensorPhase, setStatusFramePeriod, setStatusFramePeriod, setStatusFramePeriod, setStatusFramePeriod, startMotionProfile, valueUpdated
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.ctre.phoenix.motorcontrol.IMotorController
changeMotionControlFramePeriod, clearMotionProfileHasUnderrun, clearMotionProfileTrajectories, clearStickyFaults, config_IntegralZone, config_kD, config_kF, config_kI, config_kP, configAllowableClosedloopError, configAuxPIDPolarity, configClosedLoopPeakOutput, configClosedLoopPeriod, configClosedloopRamp, configForwardLimitSwitchSource, configForwardSoftLimitEnable, configForwardSoftLimitThreshold, configGetCustomParam, configGetParameter, configGetParameter, configMaxIntegralAccumulator, configMotionAcceleration, configMotionCruiseVelocity, configMotionProfileTrajectoryPeriod, configMotionSCurveStrength, configNeutralDeadband, configNominalOutputForward, configNominalOutputReverse, configOpenloopRamp, configPeakOutputForward, configPeakOutputReverse, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configRemoteFeedbackFilter, configReverseLimitSwitchSource, configReverseSoftLimitEnable, configReverseSoftLimitThreshold, configSelectedFeedbackCoefficient, configSelectedFeedbackSensor, configSensorTerm, configSetCustomParam, configSetParameter, configSetParameter, configVoltageCompSaturation, configVoltageMeasurementFilter, enableVoltageCompensation, getActiveTrajectoryPosition, getActiveTrajectoryVelocity, getBaseID, getBusVoltage, getClosedLoopError, getClosedLoopTarget, getControlMode, getDeviceID, getErrorDerivative, getFaults, getFirmwareVersion, getIntegralAccumulator, getLastError, getMotionProfileStatus, getMotionProfileTopLevelBufferCount, getMotorOutputPercent, getMotorOutputVoltage, getSelectedSensorPosition, getSelectedSensorVelocity, getStatusFramePeriod, getStickyFaults, getTemperature, hasResetOccurred, isMotionProfileTopLevelBufferFull, neutralOutput, overrideLimitSwitchesEnable, overrideSoftLimitsEnable, processMotionProfileBuffer, pushMotionProfileTrajectory, selectProfileSlot, setControlFramePeriod, setIntegralAccumulator, setInverted, setNeutralMode, setSelectedSensorPosition, setSensorPhase, setStatusFramePeriod
Methods inherited from interface com.ctre.phoenix.motorcontrol.IMotorControllerEnhanced
configSelectedFeedbackSensor
-
Field Details
-
kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature.- See Also:
- Constant Field Values
-
-
Constructor Details
-
WPI_TalonSRX
Constructor for motor controller- Parameters:
deviceNumber
- device ID of motor controller
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
set
Common interface for setting the speed of a simple speed controller.- Specified by:
set
in interfaceMotorController
- Parameters:
speed
- The speed to set. Value should be between -1.0 and 1.0. Value is also saved for Get().
-
get
Common interface for getting the current set speed of a speed controller.- Specified by:
get
in interfaceMotorController
- Returns:
- The current set speed. Value is between -1.0 and 1.0.
-
set
Sets the appropriate output on the talon, depending on the mode.- Specified by:
set
in interfaceIMotorController
- Overrides:
set
in classBaseMotorController
- 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.value
- 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
- Overrides:
set
in classBaseMotorController
- 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. 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. Units match the set mode. 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);
-
setVoltage
Sets the voltage output of the SpeedController. Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are "meaningful" (e.g. they come from a feedforward calculation).NOTE: This function *must* be called regularly in order for voltage compensation to work properly - unlike the ordinary set function, it is not "set it and forget it."
- Specified by:
setVoltage
in interfaceMotorController
- Parameters:
outputVolts
- The voltage to output.
-
setInverted
Common interface for inverting direction of a speed controller.- Specified by:
setInverted
in interfaceIInvertable
- Specified by:
setInverted
in interfaceIMotorController
- Specified by:
setInverted
in interfaceMotorController
- Overrides:
setInverted
in classBaseMotorController
- Parameters:
isInverted
- The state of inversion, true is inverted.
-
getInverted
Common interface for returning the inversion state of a speed controller.- Specified by:
getInverted
in interfaceIInvertable
- Specified by:
getInverted
in interfaceIMotorController
- Specified by:
getInverted
in interfaceMotorController
- Overrides:
getInverted
in classBaseMotorController
- Returns:
- The state of inversion, true is inverted.
-
disable
Common interface for disabling a motor.- Specified by:
disable
in interfaceMotorController
-
stopMotor
Common interface to stop the motor until Set is called again.- Specified by:
stopMotor
in interfaceMotorController
-
initSendable
Initialize sendable- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- Base sendable to build on
-
getDescription
- Returns:
- description of controller
-
feed
Feed the motor safety object.Resets the timer on this object that is used to do the timeouts.
-
setExpiration
Set the expiration time for the corresponding motor safety object.- Parameters:
expirationTime
- The timeout value in seconds.
-
getExpiration
Retrieve the timeout value for the corresponding motor safety object.- Returns:
- the timeout value in seconds.
-
isAlive
Determine of the motor is still operating or has timed out.- Returns:
- a true value if the motor is still operating normally and hasn't timed out.
-
setSafetyEnabled
Enable/disable motor safety for this device.Turn on and off the motor safety option for this PWM object.
- Parameters:
enabled
- True if motor safety is enforced for this object
-
isSafetyEnabled
Return the state of the motor safety enabled flag.Return if the motor safety is currently enabled for this device.
- Returns:
- True if motor safety is enforced for this device
-