Actuator Limits#

CTR Electronics actuators, such as the TalonFX, support various kinds of hardware and software limits.


The TalonFX + Kraken X60 does not support hardware limit switches. Instead, control request limit overrides can be used, or a CANcoder can be used a remote limit switch.

Documentation on wiring limit switches can be found here.

Retrieving Limit Switch State#

The state of the forward or reverse limit switch can be retrieved from the API via getForwardLimit() and getReverseLimit().

var forwardLimit = m_motor.getForwardLimit();

if (forwardLimit.getValue() == ForwardLimitValue.ClosedToGround) {
   // do action when forward limit is closed
auto& forwardLimit = m_motor.GetForwardLimit();

if (forwardLimit.GetValue() == signals::ForwardLimitValue::ClosedToGround) {
   // do action when forward limit is closed
forward_limit = self.motor.get_forward_limit()

if forward_limit.value is signals.ForwardLimitValue.CLOSED_TO_GROUND:
   # do action when forward limit is closed

Control Request Limits#

Many control requests support overriding the limit switch values using LimitForwardMotion and LimitReverseMotion parameters (Java, C++, Python). These allow users to use other limit switch sensors connected to the robot controller.

final DigitalInput m_forwardLimit = new DigitalInput(0);
final DigitalInput m_reverseLimit = new DigitalInput(1);

final DutyCycleOut m_dutyCycle = new DutyCycleOut(0.0);

frc::DigitalInput m_forwardLimit{0};
frc::DigitalInput m_reverseLimit{1};

controls::DutyCycleOut m_dutyCycle{0.0};

self.forward_limit = wpilib.DigitalInput(0)
self.reverse_limit = wpilib.DigitalInput(1)

self.duty_cycle = controls.DutyCycleOut(0.0)


Remote Limit Switches#

Supported devices (TalonFX, CANcoder, CANifier) can be utilized as a remote limit switch, disabling actuator outputs when triggers. When utilizing a CANcoder as a remote sensor, the limit will trigger when the magnet strength changes from BAD (red) to ADEQUATE (orange) or GOOD (green).

The remote limit switch can be selected using the LimitSource and LimitRemoteSensorID configs.

var limitConfigs = new HardwareLimitSwitchConfigs();
limitConfigs.ForwardLimitSource = ForwardLimitSourceValue.RemoteCANcoder;
limitConfigs.ForwardLimitRemoteSensorID = m_cancoder.getDeviceID();

configs::HardwareLimitSwitchConfigs limitConfigs{};
limitConfigs.ForwardLimitSource = signals::ForwardLimitSourceValue::RemoteCANcoder;
limitConfigs.ForwardLimitRemoteSensorID = m_cancoder.GetDeviceID();

limit_configs = configs.HardwareLimitSwitchConfigs()
limit_configs.forward_limit_source = signals.ForwardLimitSourceValue.REMOTE_CANCODER
limit_configs.forward_limit_remote_sensor_id = self.cancoder.device_id