From 7815248d623e6e19822aa8e868340ae318882cce Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 17 Mar 2026 16:40:35 -0700 Subject: [PATCH] [wpilib] Rename MotorType constants to all caps --- .../src/main/native/cpp/drive/MecanumDrive.cpp | 14 ++++++++------ .../native/include/wpi/drive/RobotDriveBase.hpp | 16 ++++++++-------- .../main/java/org/wpilib/drive/MecanumDrive.java | 16 ++++++++-------- .../java/org/wpilib/drive/RobotDriveBase.java | 14 +++++++------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp index 9adf543d0d..7b7f48df60 100644 --- a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp @@ -113,19 +113,21 @@ MecanumDrive::WheelVelocities MecanumDrive::DriveCartesianIK( .RotateBy(-gyroAngle); double wheelVelocities[4]; - wheelVelocities[kFrontLeft] = + wheelVelocities[static_cast(MotorType::FRONT_LEFT)] = input.X().value() + input.Y().value() + zRotation; - wheelVelocities[kFrontRight] = + wheelVelocities[static_cast(MotorType::FRONT_RIGHT)] = input.X().value() - input.Y().value() - zRotation; - wheelVelocities[kRearLeft] = + wheelVelocities[static_cast(MotorType::REAR_LEFT)] = input.X().value() - input.Y().value() + zRotation; - wheelVelocities[kRearRight] = + wheelVelocities[static_cast(MotorType::REAR_RIGHT)] = input.X().value() + input.Y().value() - zRotation; Desaturate(wheelVelocities); - return {wheelVelocities[kFrontLeft], wheelVelocities[kFrontRight], - wheelVelocities[kRearLeft], wheelVelocities[kRearRight]}; + return {wheelVelocities[static_cast(MotorType::FRONT_LEFT)], + wheelVelocities[static_cast(MotorType::FRONT_RIGHT)], + wheelVelocities[static_cast(MotorType::REAR_LEFT)], + wheelVelocities[static_cast(MotorType::REAR_RIGHT)]}; } std::string MecanumDrive::GetDescription() const { diff --git a/wpilibc/src/main/native/include/wpi/drive/RobotDriveBase.hpp b/wpilibc/src/main/native/include/wpi/drive/RobotDriveBase.hpp index e7f532dc2a..6177dc3951 100644 --- a/wpilibc/src/main/native/include/wpi/drive/RobotDriveBase.hpp +++ b/wpilibc/src/main/native/include/wpi/drive/RobotDriveBase.hpp @@ -22,21 +22,21 @@ class RobotDriveBase : public MotorSafety { /** * The location of a motor on the robot for the purpose of driving. */ - enum MotorType { + enum class MotorType { /// Front-left motor. - kFrontLeft = 0, + FRONT_LEFT = 0, /// Front-right motor. - kFrontRight = 1, + FRONT_RIGHT = 1, /// Rear-left motor. - kRearLeft = 2, + REAR_LEFT = 2, /// Rear-right motor. - kRearRight = 3, + REAR_RIGHT = 3, /// Left motor. - kLeft = 0, + LEFT = 0, /// Right motor. - kRight = 1, + RIGHT = 1, /// Back motor. - kBack = 2 + BACK = 2 }; RobotDriveBase(); diff --git a/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java b/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java index 1d26afff49..9bf1fcb406 100644 --- a/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java +++ b/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java @@ -278,18 +278,18 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea var input = new Translation2d(xVelocity, yVelocity).rotateBy(gyroAngle.unaryMinus()); double[] wheelVelocities = new double[4]; - wheelVelocities[MotorType.kFrontLeft.value] = input.getX() + input.getY() + zRotation; - wheelVelocities[MotorType.kFrontRight.value] = input.getX() - input.getY() - zRotation; - wheelVelocities[MotorType.kRearLeft.value] = input.getX() - input.getY() + zRotation; - wheelVelocities[MotorType.kRearRight.value] = input.getX() + input.getY() - zRotation; + wheelVelocities[MotorType.FRONT_LEFT.value] = input.getX() + input.getY() + zRotation; + wheelVelocities[MotorType.FRONT_RIGHT.value] = input.getX() - input.getY() - zRotation; + wheelVelocities[MotorType.REAR_LEFT.value] = input.getX() - input.getY() + zRotation; + wheelVelocities[MotorType.REAR_RIGHT.value] = input.getX() + input.getY() - zRotation; normalize(wheelVelocities); return new WheelVelocities( - wheelVelocities[MotorType.kFrontLeft.value], - wheelVelocities[MotorType.kFrontRight.value], - wheelVelocities[MotorType.kRearLeft.value], - wheelVelocities[MotorType.kRearRight.value]); + wheelVelocities[MotorType.FRONT_LEFT.value], + wheelVelocities[MotorType.FRONT_RIGHT.value], + wheelVelocities[MotorType.REAR_LEFT.value], + wheelVelocities[MotorType.REAR_RIGHT.value]); } @Override diff --git a/wpilibj/src/main/java/org/wpilib/drive/RobotDriveBase.java b/wpilibj/src/main/java/org/wpilib/drive/RobotDriveBase.java index b101c0a2e0..4170b6a536 100644 --- a/wpilibj/src/main/java/org/wpilib/drive/RobotDriveBase.java +++ b/wpilibj/src/main/java/org/wpilib/drive/RobotDriveBase.java @@ -27,19 +27,19 @@ public abstract class RobotDriveBase extends MotorSafety { /** The location of a motor on the robot for the purpose of driving. */ public enum MotorType { /** Front left motor. */ - kFrontLeft(0), + FRONT_LEFT(0), /** Front right motor. */ - kFrontRight(1), + FRONT_RIGHT(1), /** Rear left motor. */ - kRearLeft(2), + REAR_LEFT(2), /** Rear right motor. */ - kRearRight(3), + REAR_RIGHT(3), /** Left motor. */ - kLeft(0), + LEFT(0), /** Right motor. */ - kRight(1), + RIGHT(1), /** Back motor. */ - kBack(2); + BACK(2); /** MotorType value. */ public final int value;