mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sysid] Make constexpr variables outside class scope inline (#6145)
This commit is contained in:
@@ -99,10 +99,10 @@ void AnalysisManager::PrepareGeneralData() {
|
||||
wpi::StringMap<std::vector<PreparedData>> preparedData;
|
||||
|
||||
// Store the raw data columns.
|
||||
static constexpr size_t kTimeCol = 0;
|
||||
static constexpr size_t kVoltageCol = 1;
|
||||
static constexpr size_t kPosCol = 2;
|
||||
static constexpr size_t kVelCol = 3;
|
||||
constexpr size_t kTimeCol = 0;
|
||||
constexpr size_t kVoltageCol = 1;
|
||||
constexpr size_t kPosCol = 2;
|
||||
constexpr size_t kVelCol = 3;
|
||||
|
||||
WPI_INFO(m_logger, "{}", "Reading JSON data.");
|
||||
// Get the major components from the JSON and store them inside a StringMap.
|
||||
@@ -176,15 +176,15 @@ void AnalysisManager::PrepareAngularDrivetrainData() {
|
||||
wpi::StringMap<std::vector<PreparedData>> preparedData;
|
||||
|
||||
// Store the relevant raw data columns.
|
||||
static constexpr size_t kTimeCol = 0;
|
||||
static constexpr size_t kLVoltageCol = 1;
|
||||
static constexpr size_t kRVoltageCol = 2;
|
||||
static constexpr size_t kLPosCol = 3;
|
||||
static constexpr size_t kRPosCol = 4;
|
||||
static constexpr size_t kLVelCol = 5;
|
||||
static constexpr size_t kRVelCol = 6;
|
||||
static constexpr size_t kAngleCol = 7;
|
||||
static constexpr size_t kAngularRateCol = 8;
|
||||
constexpr size_t kTimeCol = 0;
|
||||
constexpr size_t kLVoltageCol = 1;
|
||||
constexpr size_t kRVoltageCol = 2;
|
||||
constexpr size_t kLPosCol = 3;
|
||||
constexpr size_t kRPosCol = 4;
|
||||
constexpr size_t kLVelCol = 5;
|
||||
constexpr size_t kRVelCol = 6;
|
||||
constexpr size_t kAngleCol = 7;
|
||||
constexpr size_t kAngularRateCol = 8;
|
||||
|
||||
WPI_INFO(m_logger, "{}", "Reading JSON data.");
|
||||
// Get the major components from the JSON and store them inside a StringMap.
|
||||
@@ -293,13 +293,13 @@ void AnalysisManager::PrepareLinearDrivetrainData() {
|
||||
wpi::StringMap<std::vector<PreparedData>> preparedData;
|
||||
|
||||
// Store the relevant raw data columns.
|
||||
static constexpr size_t kTimeCol = 0;
|
||||
static constexpr size_t kLVoltageCol = 1;
|
||||
static constexpr size_t kRVoltageCol = 2;
|
||||
static constexpr size_t kLPosCol = 3;
|
||||
static constexpr size_t kRPosCol = 4;
|
||||
static constexpr size_t kLVelCol = 5;
|
||||
static constexpr size_t kRVelCol = 6;
|
||||
constexpr size_t kTimeCol = 0;
|
||||
constexpr size_t kLVoltageCol = 1;
|
||||
constexpr size_t kRVoltageCol = 2;
|
||||
constexpr size_t kLPosCol = 3;
|
||||
constexpr size_t kRPosCol = 4;
|
||||
constexpr size_t kLVelCol = 5;
|
||||
constexpr size_t kRVelCol = 6;
|
||||
|
||||
// Get the major components from the JSON and store them inside a StringMap.
|
||||
WPI_INFO(m_logger, "{}", "Reading JSON data.");
|
||||
|
||||
@@ -20,17 +20,17 @@
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
|
||||
// Sizes of the arrays for new sysid data.
|
||||
static constexpr size_t kDrivetrainSize = 9;
|
||||
static constexpr size_t kGeneralSize = 4;
|
||||
inline constexpr size_t kDrivetrainSize = 9;
|
||||
inline constexpr size_t kGeneralSize = 4;
|
||||
|
||||
// Indices for the old data.
|
||||
static constexpr size_t kTimestampCol = 0;
|
||||
static constexpr size_t kLVoltsCol = 3;
|
||||
static constexpr size_t kRVoltsCol = 4;
|
||||
static constexpr size_t kLPosCol = 5;
|
||||
static constexpr size_t kRPosCol = 6;
|
||||
static constexpr size_t kLVelCol = 7;
|
||||
static constexpr size_t kRVelCol = 8;
|
||||
inline constexpr size_t kTimestampCol = 0;
|
||||
inline constexpr size_t kLVoltsCol = 3;
|
||||
inline constexpr size_t kRVoltsCol = 4;
|
||||
inline constexpr size_t kLPosCol = 5;
|
||||
inline constexpr size_t kRPosCol = 6;
|
||||
inline constexpr size_t kLVelCol = 7;
|
||||
inline constexpr size_t kRVelCol = 8;
|
||||
|
||||
static wpi::json GetJSON(std::string_view path, wpi::Logger& logger) {
|
||||
std::error_code ec;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define STRINGIZE(s) #s
|
||||
|
||||
namespace sysid {
|
||||
static constexpr const char* kUnits[] = {"Meters", "Feet", "Inches",
|
||||
inline constexpr const char* kUnits[] = {"Meters", "Feet", "Inches",
|
||||
"Radians", "Rotations", "Degrees"};
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,11 +52,11 @@ struct AnalysisType {
|
||||
};
|
||||
|
||||
namespace analysis {
|
||||
constexpr AnalysisType kDrivetrain{3, 9, "Drivetrain"};
|
||||
constexpr AnalysisType kDrivetrainAngular{3, 9, "Drivetrain (Angular)"};
|
||||
constexpr AnalysisType kElevator{4, 4, "Elevator"};
|
||||
constexpr AnalysisType kArm{5, 4, "Arm"};
|
||||
constexpr AnalysisType kSimple{3, 4, "Simple"};
|
||||
inline constexpr AnalysisType kDrivetrain{3, 9, "Drivetrain"};
|
||||
inline constexpr AnalysisType kDrivetrainAngular{3, 9, "Drivetrain (Angular)"};
|
||||
inline constexpr AnalysisType kElevator{4, 4, "Elevator"};
|
||||
inline constexpr AnalysisType kArm{5, 4, "Arm"};
|
||||
inline constexpr AnalysisType kSimple{3, 4, "Simple"};
|
||||
|
||||
AnalysisType FromName(std::string_view name);
|
||||
} // namespace analysis
|
||||
|
||||
@@ -71,11 +71,11 @@ struct FeedbackControllerPreset {
|
||||
enum class FeedbackControllerLoopType { kPosition, kVelocity };
|
||||
|
||||
namespace presets {
|
||||
constexpr FeedbackControllerPreset kDefault{1.0, 1.0, 20_ms, true, 0_s};
|
||||
inline constexpr FeedbackControllerPreset kDefault{1.0, 1.0, 20_ms, true, 0_s};
|
||||
|
||||
constexpr FeedbackControllerPreset kWPILibNew{kDefault};
|
||||
constexpr FeedbackControllerPreset kWPILibOld{1.0 / 12.0, 1.0, 50_ms, false,
|
||||
0_s};
|
||||
inline constexpr FeedbackControllerPreset kWPILibNew{kDefault};
|
||||
inline constexpr FeedbackControllerPreset kWPILibOld{1.0 / 12.0, 1.0, 50_ms,
|
||||
false, 0_s};
|
||||
|
||||
// Measurement delay from a moving average filter:
|
||||
//
|
||||
@@ -117,10 +117,10 @@ constexpr FeedbackControllerPreset kWPILibOld{1.0 / 12.0, 1.0, 50_ms, false,
|
||||
*
|
||||
* Total delay = 50 ms + 31.5 ms = 81.5 ms.
|
||||
*/
|
||||
constexpr FeedbackControllerPreset kCTRECANCoder{1.0 / 12.0, 60.0, 1_ms, true,
|
||||
81.5_ms};
|
||||
constexpr FeedbackControllerPreset kCTREDefault{1023.0 / 12.0, 0.1, 1_ms, false,
|
||||
81.5_ms};
|
||||
inline constexpr FeedbackControllerPreset kCTRECANCoder{1.0 / 12.0, 60.0, 1_ms,
|
||||
true, 81.5_ms};
|
||||
inline constexpr FeedbackControllerPreset kCTREDefault{1023.0 / 12.0, 0.1, 1_ms,
|
||||
false, 81.5_ms};
|
||||
/**
|
||||
* https://api.ctr-electronics.com/phoenixpro/release/cpp/classctre_1_1phoenixpro_1_1hardware_1_1core_1_1_core_c_a_ncoder.html#a718a1a214b58d3c4543e88e3cb51ade5
|
||||
*
|
||||
@@ -129,7 +129,8 @@ constexpr FeedbackControllerPreset kCTREDefault{1023.0 / 12.0, 0.1, 1_ms, false,
|
||||
* Pro devices make use of Kalman filters default-tuned to lowest latency, which
|
||||
* in testing is roughly 1 millisecond
|
||||
*/
|
||||
constexpr FeedbackControllerPreset kCTREProDefault{1.0, 1.0, 1_ms, true, 1_ms};
|
||||
inline constexpr FeedbackControllerPreset kCTREProDefault{1.0, 1.0, 1_ms, true,
|
||||
1_ms};
|
||||
|
||||
/**
|
||||
* https://github.com/wpilibsuite/sysid/issues/258#issuecomment-1010658237
|
||||
@@ -138,8 +139,8 @@ constexpr FeedbackControllerPreset kCTREProDefault{1.0, 1.0, 1_ms, true, 1_ms};
|
||||
*
|
||||
* Total delay = 8-tap moving average delay = (8 - 1) / 2 * 32 ms = 112 ms.
|
||||
*/
|
||||
constexpr FeedbackControllerPreset kREVNEOBuiltIn{1.0 / 12.0, 60.0, 1_ms, false,
|
||||
112_ms};
|
||||
inline constexpr FeedbackControllerPreset kREVNEOBuiltIn{1.0 / 12.0, 60.0, 1_ms,
|
||||
false, 112_ms};
|
||||
|
||||
/**
|
||||
* https://www.revrobotics.com/content/sw/max/sw-docs/cpp/classrev_1_1_c_a_n_encoder.html#a7e6ce792bc0c0558fb944771df572e6a
|
||||
@@ -150,15 +151,15 @@ constexpr FeedbackControllerPreset kREVNEOBuiltIn{1.0 / 12.0, 60.0, 1_ms, false,
|
||||
*
|
||||
* Total delay = 50 ms + 31.5 ms = 81.5 ms.
|
||||
*/
|
||||
constexpr FeedbackControllerPreset kREVNonNEO{1.0 / 12.0, 60.0, 1_ms, false,
|
||||
81.5_ms};
|
||||
inline constexpr FeedbackControllerPreset kREVNonNEO{1.0 / 12.0, 60.0, 1_ms,
|
||||
false, 81.5_ms};
|
||||
|
||||
/**
|
||||
* https://github.com/wpilibsuite/sysid/pull/138#issuecomment-841734229
|
||||
*
|
||||
* Backward finite difference delay = 10 ms / 2 = 5 ms.
|
||||
*/
|
||||
constexpr FeedbackControllerPreset kVenom{4096.0 / 12.0, 60.0, 1_ms, false,
|
||||
5_ms};
|
||||
inline constexpr FeedbackControllerPreset kVenom{4096.0 / 12.0, 60.0, 1_ms,
|
||||
false, 5_ms};
|
||||
} // namespace presets
|
||||
} // namespace sysid
|
||||
|
||||
@@ -28,7 +28,7 @@ enum Movements : uint32_t {
|
||||
kFastBackward
|
||||
};
|
||||
|
||||
constexpr int kMovementCombinations = 16;
|
||||
inline constexpr int kMovementCombinations = 16;
|
||||
|
||||
/**
|
||||
* Return simulated test data for a given simulation model.
|
||||
|
||||
Reference in New Issue
Block a user