[wpilibcExamples] Add inline specifier to constexpr constants (#6049)

This commit is contained in:
ncorrea210
2023-12-14 23:52:02 -05:00
committed by GitHub
parent 85c9ae6eff
commit 8798700cec
20 changed files with 362 additions and 362 deletions

View File

@@ -29,80 +29,80 @@
*/
namespace DriveConstants {
constexpr int kFrontLeftDriveMotorPort = 0;
constexpr int kRearLeftDriveMotorPort = 2;
constexpr int kFrontRightDriveMotorPort = 4;
constexpr int kRearRightDriveMotorPort = 6;
inline constexpr int kFrontLeftDriveMotorPort = 0;
inline constexpr int kRearLeftDriveMotorPort = 2;
inline constexpr int kFrontRightDriveMotorPort = 4;
inline constexpr int kRearRightDriveMotorPort = 6;
constexpr int kFrontLeftTurningMotorPort = 1;
constexpr int kRearLeftTurningMotorPort = 3;
constexpr int kFrontRightTurningMotorPort = 5;
constexpr int kRearRightTurningMotorPort = 7;
inline constexpr int kFrontLeftTurningMotorPort = 1;
inline constexpr int kRearLeftTurningMotorPort = 3;
inline constexpr int kFrontRightTurningMotorPort = 5;
inline constexpr int kRearRightTurningMotorPort = 7;
constexpr int kFrontLeftTurningEncoderPorts[2]{0, 1};
constexpr int kRearLeftTurningEncoderPorts[2]{2, 3};
constexpr int kFrontRightTurningEncoderPorts[2]{4, 5};
constexpr int kRearRightTurningEncoderPorts[2]{6, 7};
inline constexpr int kFrontLeftTurningEncoderPorts[2]{0, 1};
inline constexpr int kRearLeftTurningEncoderPorts[2]{2, 3};
inline constexpr int kFrontRightTurningEncoderPorts[2]{4, 5};
inline constexpr int kRearRightTurningEncoderPorts[2]{6, 7};
constexpr bool kFrontLeftTurningEncoderReversed = false;
constexpr bool kRearLeftTurningEncoderReversed = true;
constexpr bool kFrontRightTurningEncoderReversed = false;
constexpr bool kRearRightTurningEncoderReversed = true;
inline constexpr bool kFrontLeftTurningEncoderReversed = false;
inline constexpr bool kRearLeftTurningEncoderReversed = true;
inline constexpr bool kFrontRightTurningEncoderReversed = false;
inline constexpr bool kRearRightTurningEncoderReversed = true;
constexpr int kFrontLeftDriveEncoderPorts[2]{8, 9};
constexpr int kRearLeftDriveEncoderPorts[2]{10, 11};
constexpr int kFrontRightDriveEncoderPorts[2]{12, 13};
constexpr int kRearRightDriveEncoderPorts[2]{14, 15};
inline constexpr int kFrontLeftDriveEncoderPorts[2]{8, 9};
inline constexpr int kRearLeftDriveEncoderPorts[2]{10, 11};
inline constexpr int kFrontRightDriveEncoderPorts[2]{12, 13};
inline constexpr int kRearRightDriveEncoderPorts[2]{14, 15};
constexpr bool kFrontLeftDriveEncoderReversed = false;
constexpr bool kRearLeftDriveEncoderReversed = true;
constexpr bool kFrontRightDriveEncoderReversed = false;
constexpr bool kRearRightDriveEncoderReversed = true;
inline constexpr bool kFrontLeftDriveEncoderReversed = false;
inline constexpr bool kRearLeftDriveEncoderReversed = true;
inline constexpr bool kFrontRightDriveEncoderReversed = false;
inline constexpr bool kRearRightDriveEncoderReversed = true;
// If you call DriveSubsystem::Drive with a different period make sure to update
// this.
constexpr units::second_t kDrivePeriod = frc::TimedRobot::kDefaultPeriod;
inline constexpr units::second_t kDrivePeriod = frc::TimedRobot::kDefaultPeriod;
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
// These characterization values MUST be determined either experimentally or
// theoretically for *your* robot's drive. The SysId tool provides a convenient
// method for obtaining these values for your robot.
constexpr auto ks = 1_V;
constexpr auto kv = 0.8 * 1_V * 1_s / 1_m;
constexpr auto ka = 0.15 * 1_V * 1_s * 1_s / 1_m;
inline constexpr auto ks = 1_V;
inline constexpr auto kv = 0.8 * 1_V * 1_s / 1_m;
inline constexpr auto ka = 0.15 * 1_V * 1_s * 1_s / 1_m;
// Example value only - as above, this must be tuned for your drive!
constexpr double kPFrontLeftVel = 0.5;
constexpr double kPRearLeftVel = 0.5;
constexpr double kPFrontRightVel = 0.5;
constexpr double kPRearRightVel = 0.5;
inline constexpr double kPFrontLeftVel = 0.5;
inline constexpr double kPRearLeftVel = 0.5;
inline constexpr double kPFrontRightVel = 0.5;
inline constexpr double kPRearRightVel = 0.5;
} // namespace DriveConstants
namespace ModuleConstants {
constexpr int kEncoderCPR = 1024;
constexpr double kWheelDiameterMeters = 0.15;
constexpr double kDriveEncoderDistancePerPulse =
inline constexpr int kEncoderCPR = 1024;
inline constexpr double kWheelDiameterMeters = 0.15;
inline constexpr double kDriveEncoderDistancePerPulse =
// Assumes the encoders are directly mounted on the wheel shafts
(kWheelDiameterMeters * std::numbers::pi) /
static_cast<double>(kEncoderCPR);
constexpr double kTurningEncoderDistancePerPulse =
inline constexpr double kTurningEncoderDistancePerPulse =
// Assumes the encoders are directly mounted on the wheel shafts
(std::numbers::pi * 2) / static_cast<double>(kEncoderCPR);
constexpr double kPModuleTurningController = 1;
constexpr double kPModuleDriveController = 1;
inline constexpr double kPModuleTurningController = 1;
inline constexpr double kPModuleDriveController = 1;
} // namespace ModuleConstants
namespace AutoConstants {
constexpr auto kMaxSpeed = 3_mps;
constexpr auto kMaxAcceleration = 3_mps_sq;
constexpr auto kMaxAngularSpeed = 3.142_rad_per_s;
constexpr auto kMaxAngularAcceleration = 3.142_rad_per_s_sq;
inline constexpr auto kMaxSpeed = 3_mps;
inline constexpr auto kMaxAcceleration = 3_mps_sq;
inline constexpr auto kMaxAngularSpeed = 3.142_rad_per_s;
inline constexpr auto kMaxAngularAcceleration = 3.142_rad_per_s_sq;
constexpr double kPXController = 0.5;
constexpr double kPYController = 0.5;
constexpr double kPThetaController = 0.5;
inline constexpr double kPXController = 0.5;
inline constexpr double kPYController = 0.5;
inline constexpr double kPThetaController = 0.5;
//
@@ -112,5 +112,5 @@ extern const frc::TrapezoidProfile<units::radians>::Constraints
} // namespace AutoConstants
namespace OIConstants {
constexpr int kDriverControllerPort = 0;
inline constexpr int kDriverControllerPort = 0;
} // namespace OIConstants