mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilibcExamples] Add inline specifier to constexpr constants (#6049)
This commit is contained in:
@@ -20,56 +20,56 @@
|
||||
*/
|
||||
|
||||
namespace DriveConstants {
|
||||
constexpr int kLeftMotor1Port = 0;
|
||||
constexpr int kLeftMotor2Port = 1;
|
||||
constexpr int kRightMotor1Port = 2;
|
||||
constexpr int kRightMotor2Port = 3;
|
||||
inline constexpr int kLeftMotor1Port = 0;
|
||||
inline constexpr int kLeftMotor2Port = 1;
|
||||
inline constexpr int kRightMotor1Port = 2;
|
||||
inline constexpr int kRightMotor2Port = 3;
|
||||
|
||||
constexpr int kLeftEncoderPorts[]{0, 1};
|
||||
constexpr int kRightEncoderPorts[]{2, 3};
|
||||
constexpr bool kLeftEncoderReversed = false;
|
||||
constexpr bool kRightEncoderReversed = true;
|
||||
inline constexpr int kLeftEncoderPorts[]{0, 1};
|
||||
inline constexpr int kRightEncoderPorts[]{2, 3};
|
||||
inline constexpr bool kLeftEncoderReversed = false;
|
||||
inline constexpr bool kRightEncoderReversed = true;
|
||||
|
||||
constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
inline constexpr int kEncoderCPR = 1024;
|
||||
inline constexpr double kWheelDiameterInches = 6;
|
||||
inline constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
namespace ShooterConstants {
|
||||
constexpr int kEncoderPorts[]{4, 5};
|
||||
constexpr bool kEncoderReversed = false;
|
||||
constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
inline constexpr int kEncoderPorts[]{4, 5};
|
||||
inline constexpr bool kEncoderReversed = false;
|
||||
inline constexpr int kEncoderCPR = 1024;
|
||||
inline constexpr double kEncoderDistancePerPulse =
|
||||
// Distance units will be rotations
|
||||
1.0 / static_cast<double>(kEncoderCPR);
|
||||
|
||||
constexpr int kShooterMotorPort = 4;
|
||||
constexpr int kFeederMotorPort = 5;
|
||||
inline constexpr int kShooterMotorPort = 4;
|
||||
inline constexpr int kFeederMotorPort = 5;
|
||||
|
||||
constexpr auto kShooterFreeRPS = 5300_tr / 1_s;
|
||||
constexpr auto kShooterTargetRPS = 4000_tr / 1_s;
|
||||
constexpr auto kShooterToleranceRPS = 50_tr / 1_s;
|
||||
inline constexpr auto kShooterFreeRPS = 5300_tr / 1_s;
|
||||
inline constexpr auto kShooterTargetRPS = 4000_tr / 1_s;
|
||||
inline constexpr auto kShooterToleranceRPS = 50_tr / 1_s;
|
||||
|
||||
constexpr double kP = 1;
|
||||
constexpr double kI = 0;
|
||||
constexpr double kD = 0;
|
||||
inline constexpr double kP = 1;
|
||||
inline constexpr double kI = 0;
|
||||
inline constexpr double kD = 0;
|
||||
|
||||
// On a real robot the feedforward constants should be empirically determined;
|
||||
// these are reasonable guesses.
|
||||
constexpr auto kS = 0.05_V;
|
||||
constexpr auto kV =
|
||||
inline constexpr auto kS = 0.05_V;
|
||||
inline constexpr auto kV =
|
||||
// Should have value 12V at free speed...
|
||||
12_V / kShooterFreeRPS;
|
||||
|
||||
constexpr double kFeederSpeed = 0.5;
|
||||
inline constexpr double kFeederSpeed = 0.5;
|
||||
} // namespace ShooterConstants
|
||||
|
||||
namespace AutoConstants {
|
||||
constexpr auto kAutoTimeoutSeconds = 12_s;
|
||||
constexpr auto kAutoShootTimeSeconds = 7_s;
|
||||
inline constexpr auto kAutoTimeoutSeconds = 12_s;
|
||||
inline constexpr auto kAutoShootTimeSeconds = 7_s;
|
||||
} // namespace AutoConstants
|
||||
|
||||
namespace OIConstants {
|
||||
|
||||
Reference in New Issue
Block a user