Skip to content

Commit

Permalink
[wpilib] Deprecate MotorController
Browse files Browse the repository at this point in the history
The drive classes no longer need this interface, and it rigidly couples
us to motor controller vendors who only update and do a major release of
their vendordep once per year.

We were originally going to do this in wpilibsuite#6053, but we wanted to gather
feedback on the alternate approach during a season first (as far as I
know, we received none).
  • Loading branch information
calcmogul committed Dec 22, 2024
1 parent 469bb32 commit f22b0a9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class DifferentialDrive : public RobotDriveBase,
*
* @param leftMotor Left motor.
* @param rightMotor Right motor.
* @deprecated Use DifferentialDrive constructor with function arguments.
*/
[[deprecated("Use DifferentialDrive constructor with function arguments")]]
DifferentialDrive(MotorController& leftMotor, MotorController& rightMotor);

WPI_UNIGNORE_DEPRECATED
Expand Down
2 changes: 2 additions & 0 deletions wpilibc/src/main/native/include/frc/drive/MecanumDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class MecanumDrive : public RobotDriveBase,
* @param rearLeftMotor Rear-left motor.
* @param frontRightMotor Front-right motor.
* @param rearRightMotor Rear-right motor.
* @deprecated Use MecanumDrive constructor with function arguments.
*/
[[deprecated("Use MecanumDrive constructor with function arguments")]]
MecanumDrive(MotorController& frontLeftMotor, MotorController& rearLeftMotor,
MotorController& frontRightMotor,
MotorController& rearRightMotor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace frc {
/**
* Interface for motor controlling devices.
*/
class MotorController {
class [[deprecated("Use the derived class instead")]] MotorController {
public:
virtual ~MotorController() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public WheelSpeeds(double left, double right) {
*
* @param leftMotor Left motor.
* @param rightMotor Right motor.
* @deprecated Use DifferentialDrive constructor with function arguments.
*/
@Deprecated(forRemoval = true, since = "2025")
@SuppressWarnings({"removal", "this-escape"})
public DifferentialDrive(MotorController leftMotor, MotorController rightMotor) {
this((double output) -> leftMotor.set(output), (double output) -> rightMotor.set(output));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public WheelSpeeds(double frontLeft, double frontRight, double rearLeft, double
* @param rearLeftMotor The motor on the rear-left corner.
* @param frontRightMotor The motor on the front-right corner.
* @param rearRightMotor The motor on the rear-right corner.
* @deprecated Use MecanumDrive constructor with function arguments.
*/
@Deprecated(forRemoval = true, since = "2025")
@SuppressWarnings({"removal", "this-escape"})
public MecanumDrive(
MotorController frontLeftMotor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
import edu.wpi.first.units.measure.Voltage;
import edu.wpi.first.wpilibj.RobotController;

/** Interface for motor controlling devices. */
/**
* Interface for motor controlling devices.
*
* @deprecated Use the derived class instead.
*/
@Deprecated(forRemoval = true, since = "2025")
public interface MotorController {
/**
* Common interface for setting the speed of a motor controller.
Expand Down

0 comments on commit f22b0a9

Please sign in to comment.