Package com.ctre.phoenix6.hardware
Class TalonFX
java.lang.Object
com.ctre.phoenix6.jni.CtreJniWrapper
com.ctre.phoenix6.hardware.ParentDevice
com.ctre.phoenix6.hardware.core.CoreTalonFX
com.ctre.phoenix6.hardware.TalonFX
- All Implemented Interfaces:
CommonDevice,CommonTalon,CommonTalonWithFOC,HasTalonControls,HasTalonSignals,SupportsFOC,SupportsMusic,Sendable,AutoCloseable
WPILib-integrated version of
CoreTalonFX.-
Nested Class Summary
Nested classes/interfaces inherited from class com.ctre.phoenix6.hardware.ParentDevice
ParentDevice.MapGenerator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default motor safety timeout IF calling application enables the feature.Fields inherited from class com.ctre.phoenix6.hardware.ParentDevice
_emptyControl, deviceIdentifier -
Constructor Summary
ConstructorsConstructorDescriptionTalonFX(int deviceId) Constructs a new Talon FX motor controller object.Constructs a new Talon FX motor controller object.Deprecated, for removal: This API element is subject to removal in a future version.Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final voiddisable()Common interface for disabling a motor controller.final voidfeed()Feed the motor safety object.final doubleget()Common interface for getting the current set speed of a motor controller.final doubleRetrieve the timeout value for the corresponding motor safety object.voidinitSendable(SendableBuilder builder) final booleanisAlive()Determine of the motor is still operating or has timed out.final booleanReturn the state of the motor safety enabled flag.final voidset(double speed) Common interface for setting the speed of a motor controller.protected StatusCodesetControlPrivate(ControlRequest request) final voidsetExpiration(double expirationTime) Set the expiration time for the corresponding motor safety object.final StatusCodesetNeutralMode(NeutralModeValue neutralMode) Sets the mode of operation when output is neutral or disabled.final StatusCodesetNeutralMode(NeutralModeValue neutralMode, double timeoutSeconds) Sets the mode of operation when output is neutral or disabled.final voidsetSafetyEnabled(boolean enabled) Enable/disable motor safety for this device.final voidsetVoltage(double volts) Common interface for seting the direct voltage output of a motor controller.final voidCommon interface to stop motor movement until set is called again.Methods inherited from class com.ctre.phoenix6.hardware.core.CoreTalonFX
clearStickyFault_BootDuringEnable, clearStickyFault_BootDuringEnable, clearStickyFault_BridgeBrownout, clearStickyFault_BridgeBrownout, clearStickyFault_DeviceTemp, clearStickyFault_DeviceTemp, clearStickyFault_ForwardHardLimit, clearStickyFault_ForwardHardLimit, clearStickyFault_ForwardSoftLimit, clearStickyFault_ForwardSoftLimit, clearStickyFault_FusedSensorOutOfSync, clearStickyFault_FusedSensorOutOfSync, clearStickyFault_Hardware, clearStickyFault_Hardware, clearStickyFault_MissingDifferentialFX, clearStickyFault_MissingDifferentialFX, clearStickyFault_MissingHardLimitRemote, clearStickyFault_MissingHardLimitRemote, clearStickyFault_MissingSoftLimitRemote, clearStickyFault_MissingSoftLimitRemote, clearStickyFault_OverSupplyV, clearStickyFault_OverSupplyV, clearStickyFault_ProcTemp, clearStickyFault_ProcTemp, clearStickyFault_RemoteSensorDataInvalid, clearStickyFault_RemoteSensorDataInvalid, clearStickyFault_RemoteSensorPosOverflow, clearStickyFault_RemoteSensorPosOverflow, clearStickyFault_RemoteSensorReset, clearStickyFault_RemoteSensorReset, clearStickyFault_ReverseHardLimit, clearStickyFault_ReverseHardLimit, clearStickyFault_ReverseSoftLimit, clearStickyFault_ReverseSoftLimit, clearStickyFault_StaticBrakeDisabled, clearStickyFault_StaticBrakeDisabled, clearStickyFault_StatorCurrLimit, clearStickyFault_StatorCurrLimit, clearStickyFault_SupplyCurrLimit, clearStickyFault_SupplyCurrLimit, clearStickyFault_Undervoltage, clearStickyFault_Undervoltage, clearStickyFault_UnlicensedFeatureInUse, clearStickyFault_UnlicensedFeatureInUse, clearStickyFault_UnstableSupplyV, clearStickyFault_UnstableSupplyV, clearStickyFault_UsingFusedCANcoderWhileUnlicensed, clearStickyFault_UsingFusedCANcoderWhileUnlicensed, clearStickyFaults, clearStickyFaults, getAcceleration, getAcceleration, getAncillaryDeviceTemp, getAncillaryDeviceTemp, getAppliedRotorPolarity, getAppliedRotorPolarity, getBridgeOutput, getBridgeOutput, getClosedLoopDerivativeOutput, getClosedLoopDerivativeOutput, getClosedLoopError, getClosedLoopError, getClosedLoopFeedForward, getClosedLoopFeedForward, getClosedLoopIntegratedOutput, getClosedLoopIntegratedOutput, getClosedLoopOutput, getClosedLoopOutput, getClosedLoopProportionalOutput, getClosedLoopProportionalOutput, getClosedLoopReference, getClosedLoopReference, getClosedLoopReferenceSlope, getClosedLoopReferenceSlope, getClosedLoopSlot, getClosedLoopSlot, getConfigurator, getConnectedMotor, getConnectedMotor, getControlMode, getControlMode, getDeviceEnable, getDeviceEnable, getDeviceTemp, getDeviceTemp, getDifferentialAveragePosition, getDifferentialAveragePosition, getDifferentialAverageVelocity, getDifferentialAverageVelocity, getDifferentialClosedLoopDerivativeOutput, getDifferentialClosedLoopDerivativeOutput, getDifferentialClosedLoopError, getDifferentialClosedLoopError, getDifferentialClosedLoopFeedForward, getDifferentialClosedLoopFeedForward, getDifferentialClosedLoopIntegratedOutput, getDifferentialClosedLoopIntegratedOutput, getDifferentialClosedLoopOutput, getDifferentialClosedLoopOutput, getDifferentialClosedLoopProportionalOutput, getDifferentialClosedLoopProportionalOutput, getDifferentialClosedLoopReference, getDifferentialClosedLoopReference, getDifferentialClosedLoopReferenceSlope, getDifferentialClosedLoopReferenceSlope, getDifferentialClosedLoopSlot, getDifferentialClosedLoopSlot, getDifferentialControlMode, getDifferentialControlMode, getDifferentialDifferencePosition, getDifferentialDifferencePosition, getDifferentialDifferenceVelocity, getDifferentialDifferenceVelocity, getDifferentialOutput, getDifferentialOutput, getDutyCycle, getDutyCycle, getFault_BootDuringEnable, getFault_BootDuringEnable, getFault_BridgeBrownout, getFault_BridgeBrownout, getFault_DeviceTemp, getFault_DeviceTemp, getFault_ForwardHardLimit, getFault_ForwardHardLimit, getFault_ForwardSoftLimit, getFault_ForwardSoftLimit, getFault_FusedSensorOutOfSync, getFault_FusedSensorOutOfSync, getFault_Hardware, getFault_Hardware, getFault_MissingDifferentialFX, getFault_MissingDifferentialFX, getFault_MissingHardLimitRemote, getFault_MissingHardLimitRemote, getFault_MissingSoftLimitRemote, getFault_MissingSoftLimitRemote, getFault_OverSupplyV, getFault_OverSupplyV, getFault_ProcTemp, getFault_ProcTemp, getFault_RemoteSensorDataInvalid, getFault_RemoteSensorDataInvalid, getFault_RemoteSensorPosOverflow, getFault_RemoteSensorPosOverflow, getFault_RemoteSensorReset, getFault_RemoteSensorReset, getFault_ReverseHardLimit, getFault_ReverseHardLimit, getFault_ReverseSoftLimit, getFault_ReverseSoftLimit, getFault_StaticBrakeDisabled, getFault_StaticBrakeDisabled, getFault_StatorCurrLimit, getFault_StatorCurrLimit, getFault_SupplyCurrLimit, getFault_SupplyCurrLimit, getFault_Undervoltage, getFault_Undervoltage, getFault_UnlicensedFeatureInUse, getFault_UnlicensedFeatureInUse, getFault_UnstableSupplyV, getFault_UnstableSupplyV, getFault_UsingFusedCANcoderWhileUnlicensed, getFault_UsingFusedCANcoderWhileUnlicensed, getFaultField, getFaultField, getForwardLimit, getForwardLimit, getIsProLicensed, getIsProLicensed, getMotionMagicAtTarget, getMotionMagicAtTarget, getMotionMagicIsRunning, getMotionMagicIsRunning, getMotorKT, getMotorKT, getMotorKV, getMotorKV, getMotorOutputStatus, getMotorOutputStatus, getMotorStallCurrent, getMotorStallCurrent, getMotorVoltage, getMotorVoltage, getPosition, getPosition, getProcessorTemp, getProcessorTemp, getReverseLimit, getReverseLimit, getRobotEnable, getRobotEnable, getRotorPosition, getRotorPosition, getRotorVelocity, getRotorVelocity, getSimState, getStatorCurrent, getStatorCurrent, getStickyFault_BootDuringEnable, getStickyFault_BootDuringEnable, getStickyFault_BridgeBrownout, getStickyFault_BridgeBrownout, getStickyFault_DeviceTemp, getStickyFault_DeviceTemp, getStickyFault_ForwardHardLimit, getStickyFault_ForwardHardLimit, getStickyFault_ForwardSoftLimit, getStickyFault_ForwardSoftLimit, getStickyFault_FusedSensorOutOfSync, getStickyFault_FusedSensorOutOfSync, getStickyFault_Hardware, getStickyFault_Hardware, getStickyFault_MissingDifferentialFX, getStickyFault_MissingDifferentialFX, getStickyFault_MissingHardLimitRemote, getStickyFault_MissingHardLimitRemote, getStickyFault_MissingSoftLimitRemote, getStickyFault_MissingSoftLimitRemote, getStickyFault_OverSupplyV, getStickyFault_OverSupplyV, getStickyFault_ProcTemp, getStickyFault_ProcTemp, getStickyFault_RemoteSensorDataInvalid, getStickyFault_RemoteSensorDataInvalid, getStickyFault_RemoteSensorPosOverflow, getStickyFault_RemoteSensorPosOverflow, getStickyFault_RemoteSensorReset, getStickyFault_RemoteSensorReset, getStickyFault_ReverseHardLimit, getStickyFault_ReverseHardLimit, getStickyFault_ReverseSoftLimit, getStickyFault_ReverseSoftLimit, getStickyFault_StaticBrakeDisabled, getStickyFault_StaticBrakeDisabled, getStickyFault_StatorCurrLimit, getStickyFault_StatorCurrLimit, getStickyFault_SupplyCurrLimit, getStickyFault_SupplyCurrLimit, getStickyFault_Undervoltage, getStickyFault_Undervoltage, getStickyFault_UnlicensedFeatureInUse, getStickyFault_UnlicensedFeatureInUse, getStickyFault_UnstableSupplyV, getStickyFault_UnstableSupplyV, getStickyFault_UsingFusedCANcoderWhileUnlicensed, getStickyFault_UsingFusedCANcoderWhileUnlicensed, getStickyFaultField, getStickyFaultField, getSupplyCurrent, getSupplyCurrent, getSupplyVoltage, getSupplyVoltage, getTorqueCurrent, getTorqueCurrent, getVelocity, getVelocity, getVersion, getVersion, getVersionBugfix, getVersionBugfix, getVersionBuild, getVersionBuild, getVersionMajor, getVersionMajor, getVersionMinor, getVersionMinor, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setControl, setPosition, setPosition, setPosition, setPositionMethods inherited from class com.ctre.phoenix6.hardware.ParentDevice
getAppliedControl, getDeviceHash, getDeviceID, getNetwork, getResetOccurredChecker, hasResetOccurred, isConnected, isConnected, lookupStatusSignal, lookupStatusSignal, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilizationForAll, optimizeBusUtilizationForAll, optimizeBusUtilizationForAll, resetSignalFrequencies, resetSignalFrequencies, resetSignalFrequenciesForAllMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ctre.phoenix6.hardware.traits.CommonDevice
getAppliedControl, getDeviceHash, getDeviceID, getNetwork, getResetOccurredChecker, hasResetOccurred, isConnected, isConnected, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, resetSignalFrequencies, resetSignalFrequencies
-
Field Details
-
kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature.- See Also:
-
-
Constructor Details
-
TalonFX
Constructs a new Talon FX motor controller object.Constructs the device using the default CAN bus for the system (see
CANBus()).- Parameters:
deviceId- ID of the device, as configured in Phoenix Tuner
-
TalonFX
Deprecated, for removal: This API element is subject to removal in a future version.Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using aCANBusinstance instead.Constructs a new Talon FX motor controller object.- Parameters:
deviceId- ID of the device, as configured in Phoenix Tunercanbus- Name of the CAN bus this device is on. Possible CAN bus strings are:- "rio" for the native roboRIO CAN bus
- CANivore name or serial number
- SocketCAN interface (non-FRC Linux only)
- "*" for any CANivore seen by the program
- empty string (default) to select the default for the
system:
- "rio" on roboRIO
- "can0" on Linux
- "*" on Windows
-
TalonFX
Constructs a new Talon FX motor controller object.- Parameters:
deviceId- ID of the device, as configured in Phoenix Tunercanbus- The CAN bus this device is on
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable
-
set
Common interface for setting the speed of a motor controller.- Parameters:
speed- The speed to set. Value should be between -1.0 and 1.0.
-
setVoltage
Common interface for seting the direct voltage output of a motor controller.- Parameters:
volts- The voltage to output.
-
get
Common interface for getting the current set speed of a motor controller.- Returns:
- The current set speed. Value is between -1.0 and 1.0.
-
setControlPrivate
- Overrides:
setControlPrivatein classParentDevice
-
disable
Common interface for disabling a motor controller. -
stopMotor
Common interface to stop motor movement until set is called again. -
setNeutralMode
Sets the mode of operation when output is neutral or disabled. This is equivalent to setting theMotorOutputConfigs.NeutralModewhen applying aTalonFXConfigurationto the motor.Since neutral mode is a config, this API is blocking. We recommend that users avoid calling this API periodically.
This will wait up to 0.100 seconds (100ms) by default.
- Parameters:
neutralMode- The state of the motor controller bridge when output is neutral or disabled- Returns:
- Status of refreshing and applying the neutral mode config
-
setNeutralMode
Sets the mode of operation when output is neutral or disabled.Since neutral mode is a config, this API is blocking. We recommend that users avoid calling this API periodically.
- Parameters:
neutralMode- The state of the motor controller bridge when output is neutral or disabledtimeoutSeconds- Maximum amount of time to wait when performing configuration- Returns:
- Status of refreshing and applying the neutral mode config
-
initSendable
- Specified by:
initSendablein interfaceSendable
-
getDescription
- Returns:
- Description of motor 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 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
-