[sysid] Rename motion threshold to velocity threshold to match GUI field name (#6240)

This commit is contained in:
Tyler Veness
2024-01-19 22:23:51 -08:00
committed by GitHub
parent a274e297cd
commit 4b15c73f64
6 changed files with 21 additions and 21 deletions

View File

@@ -173,7 +173,7 @@ AnalysisManager::AnalysisManager(TestData data, Settings& settings,
: m_data{std::move(data)}, m_logger{logger}, m_settings{settings} {
// Reset settings for Dynamic Test Limits
m_settings.stepTestDuration = units::second_t{0.0};
m_settings.motionThreshold = std::numeric_limits<double>::infinity();
m_settings.velocityThreshold = std::numeric_limits<double>::infinity();
}
void AnalysisManager::PrepareData() {

View File

@@ -127,7 +127,7 @@ sysid::TrimStepVoltageData(std::vector<PreparedData>* data,
auto motionBegins = std::find_if(
data->begin(), data->end(), [settings, firstPosition](auto& datum) {
return std::abs(datum.position - firstPosition) >
(settings->motionThreshold * datum.dt.value());
(settings->velocityThreshold * datum.dt.value());
});
units::second_t positionDelay;
@@ -335,13 +335,13 @@ void sysid::InitialTrimAndFilter(
maxStepTime = GetMaxStepTime(preparedData);
// Calculate Velocity Threshold if it hasn't been set yet
if (settings->motionThreshold == std::numeric_limits<double>::infinity()) {
if (settings->velocityThreshold == std::numeric_limits<double>::infinity()) {
for (auto& it : preparedData) {
auto key = it.first();
auto& dataset = it.getValue();
if (wpi::contains(key, "quasistatic")) {
settings->motionThreshold =
std::min(settings->motionThreshold,
settings->velocityThreshold =
std::min(settings->velocityThreshold,
GetNoiseFloor(dataset, kNoiseMeanWindow,
[](auto&& pt) { return pt.velocity; }));
}
@@ -353,13 +353,13 @@ void sysid::InitialTrimAndFilter(
auto& dataset = it.getValue();
// Trim quasistatic test data to remove all points where voltage is zero or
// velocity < motion threshold.
// velocity < velocity threshold.
if (wpi::contains(key, "quasistatic")) {
dataset.erase(std::remove_if(dataset.begin(), dataset.end(),
[&](const auto& pt) {
return std::abs(pt.voltage) <= 0 ||
std::abs(pt.velocity) <
settings->motionThreshold;
settings->velocityThreshold;
}),
dataset.end());

View File

@@ -61,7 +61,7 @@ void Analyzer::UpdateFeedforwardGains() {
m_state = AnalyzerState::kGeneralDataError;
HandleError(e.what());
} catch (const sysid::NoQuasistaticDataError& e) {
m_state = AnalyzerState::kMotionThresholdError;
m_state = AnalyzerState::kVelocityThresholdError;
HandleError(e.what());
} catch (const sysid::NoDynamicDataError& e) {
m_state = AnalyzerState::kTestDurationError;
@@ -112,14 +112,14 @@ static void SetPosition(double beginX, double beginY, double xShift,
}
bool Analyzer::IsErrorState() {
return m_state == AnalyzerState::kMotionThresholdError ||
return m_state == AnalyzerState::kVelocityThresholdError ||
m_state == AnalyzerState::kTestDurationError ||
m_state == AnalyzerState::kGeneralDataError ||
m_state == AnalyzerState::kFileError;
}
bool Analyzer::IsDataErrorState() {
return m_state == AnalyzerState::kMotionThresholdError ||
return m_state == AnalyzerState::kVelocityThresholdError ||
m_state == AnalyzerState::kTestDurationError ||
m_state == AnalyzerState::kGeneralDataError;
}
@@ -253,7 +253,7 @@ void Analyzer::Display() {
}
case AnalyzerState::kGeneralDataError:
case AnalyzerState::kTestDurationError:
case AnalyzerState::kMotionThresholdError: {
case AnalyzerState::kVelocityThresholdError: {
CreateErrorPopup(m_errorPopup, m_exception);
if (DisplayResetAndUnitOverride()) {
return;
@@ -276,7 +276,7 @@ void Analyzer::PrepareData() {
m_state = AnalyzerState::kGeneralDataError;
HandleError(e.what());
} catch (const sysid::NoQuasistaticDataError& e) {
m_state = AnalyzerState::kMotionThresholdError;
m_state = AnalyzerState::kVelocityThresholdError;
HandleError(e.what());
} catch (const sysid::NoDynamicDataError& e) {
m_state = AnalyzerState::kTestDurationError;
@@ -437,15 +437,15 @@ void Analyzer::DisplayFeedforwardParameters(float beginX, float beginY) {
"filter's sliding window.");
}
if (displayAll || m_state == AnalyzerState::kMotionThresholdError) {
if (displayAll || m_state == AnalyzerState::kVelocityThresholdError) {
// Wait for enter before refresh so decimal inputs like "0.2" don't
// prematurely refresh with a velocity threshold of "0".
SetPosition(beginX, beginY, kHorizontalOffset, 1);
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
double threshold = m_settings.motionThreshold;
double threshold = m_settings.velocityThreshold;
if (ImGui::InputDouble("Velocity Threshold", &threshold, 0.0, 0.0, "%.3f",
ImGuiInputTextFlags_EnterReturnsTrue)) {
m_settings.motionThreshold = std::max(0.0, threshold);
m_settings.velocityThreshold = std::max(0.0, threshold);
PrepareData();
}
CreateTooltip("Velocity data below this threshold will be ignored.");

View File

@@ -39,7 +39,7 @@ class AnalysisManager {
TestData m_data;
/**
* Represents settings for an instance of the analysis manager. This contains
* information about the feedback controller preset, loop type, motion
* information about the feedback controller preset, loop type, velocity
* threshold, acceleration window size, LQR parameters, and the selected
* dataset.
*/
@@ -60,9 +60,9 @@ class AnalysisManager {
LQRParameters lqr{1, 1.5, 7};
/**
* The motion threshold (units/s) for trimming quasistatic test data.
* The velocity threshold (units/s) for trimming quasistatic test data.
*/
double motionThreshold = 0.2;
double velocityThreshold = 0.2;
/**
* The window size for the median filter.

View File

@@ -43,7 +43,7 @@ class InvalidDataError : public std::exception {
explicit InvalidDataError(std::string_view message) {
m_message = fmt::format(
"{}. Please verify that your units and data is reasonable and then "
"adjust your motion threshold, test duration, and/or window size to "
"adjust your velocity threshold, test duration, and/or window size to "
"try to fix this issue.",
message);
}
@@ -64,7 +64,7 @@ class NoQuasistaticDataError : public std::exception {
public:
const char* what() const noexcept override {
return "Quasistatic test trimming removed all data. Please adjust your "
"motion threshold and double check "
"velocity threshold and double check "
"your units and test data to make sure that the robot is reporting "
"reasonable values.";
}

View File

@@ -47,7 +47,7 @@ class Analyzer : public glass::View {
enum class AnalyzerState {
kWaitingForData,
kNominalDisplay,
kMotionThresholdError,
kVelocityThresholdError,
kTestDurationError,
kGeneralDataError,
kFileError