Follower motor still not working

Hello,

I made a post while ago about followers not working. Our team implemented the changes in the post, such as setting the control of the follower motor in the constructor and not setting any control in moving the motor. In our code, we currently use the same TalonFX config for the leader motor as the follower motor. We have also tried using a completely new TalonFX configuration for the follower motor (with the same setup and also with zero setup) but that did not work (not shown here).

public class PivotSubsystem extends SubsystemBase {
  private final CANcoder pivotEncoder;

  private final TalonFX leaderPivotMotor;
  private final TalonFX followerPivotMotor;
  private final Follower follower;
  public PivotSubsystem() {
    leaderPivotMotor = new TalonFX(PivotConstants.LEADER_PIVOT_MOTOR_ID);
    followerPivotMotor = new TalonFX(PivotConstants.FOLLOWER_PIVOT_MOTOR_ID);
    mmRequest = new MotionMagicVoltage(0);

    follower = new Follower(leaderPivotMotor.getDeviceID(), true);

    speakerAngleLookupValues = new SingleLinearInterpolator(PivotConstants.SPEAKER_PIVOT_POSITION);

    TalonFXConfiguration pivotConfig = new TalonFXConfiguration();
    pivotConfig.Slot0.kP = PivotConstants.PIVOT_P;
    pivotConfig.Slot0.kI = PivotConstants.PIVOT_I;
    pivotConfig.Slot0.kD = PivotConstants.PIVOT_D;
    pivotConfig.Slot0.kG = PivotConstants.PIVOT_G;

    pivotConfig.MotionMagic.MotionMagicAcceleration = 4;
    pivotConfig.MotionMagic.MotionMagicCruiseVelocity = 10;

    pivotConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake;
    pivotConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; 
    pivotConfig.MotorOutput.DutyCycleNeutralDeadband = HardwareConstants.MIN_FALCON_DEADBAND;

    pivotConfig.Feedback.FeedbackSensorSource = FeedbackSensorSourceValue.RemoteCANcoder;
    // pivotConfig.Feedback.FeedbackRemoteSensorID = pivotEncoder.getDeviceID();
    
    pivotConfig.SoftwareLimitSwitch.ForwardSoftLimitThreshold = PivotConstants.MAX_ANGLE;
    pivotConfig.SoftwareLimitSwitch.ReverseSoftLimitThreshold = PivotConstants.MIN_ANGLE;
    pivotConfig.SoftwareLimitSwitch.ForwardSoftLimitEnable = true;
    pivotConfig.SoftwareLimitSwitch.ReverseSoftLimitEnable = true;
    leaderPivotMotor.getConfigurator().apply(pivotConfig, HardwareConstants.TIMEOUT_S);
    followerPivotMotor.getConfigurator().apply(pivotConfig, HardwareConstants.TIMEOUT_S);
    followerPivotMotor.setControl(follower);
}
public void setPivot(double angle) {
    leaderPivotMotor.setControl(mmRequest.withPosition(angle));
  }

Use this

The example is what we tried already but have struggled to get working with both falcon 500s and krakens. As you can see in the setPivot method, we only setthe control of the leader pivot motor. In our constructor, we set the follower pivot motor as the control of the follower

I am sorry. I didn’t see your .setControl the first time and just quickly assumed that was the issue.

The code I can see looks correct (looks like you keep this year’s code private so there is lots we can’t help with there).

When you run the leader what are the lights on the follower doing? If you go into TunerX and do a self test on the follower both before and during the leader movement what do you see? Does it show in the follower mode the entire time? Can the motor be run individually in Tuner?

What happens if you swap leader and follower?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.