Following CANSparkMax PID Control

Hello, I am currently working with a robot, and am relatively new to controlling CANSparkMax motors through a PID loop. I was wondering if I can control two motors with a follow command, while still using a PID loop. I am wondering this because it seems like a separate thing to the set command, and I don’t know if it will work with other motors in the same way.

Basically I am wondering if this:

backLeftMotor.follow(frontLeftMotor);
SparkPIDController frontLeftPID = frontLeftMotor.getPIDController();
frontLeftPID.setReference(speed, ControlType.kVelocity);

Works the same as this:

backLeftMotor.follow(frontLeftMotor);
frontLeftMotor.set(speed);

This does indeed work. Make sure that if the follower is inverted you do backLeftMotor.follow(frontleftMotor, true);

Great, thanks! I just didn’t want to break some motors testing it.

1 Like

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