diff --git a/sysid/src/main/native/cpp/analysis/FilteringUtils.cpp b/sysid/src/main/native/cpp/analysis/FilteringUtils.cpp index 103dc8a458..d10fa03e63 100644 --- a/sysid/src/main/native/cpp/analysis/FilteringUtils.cpp +++ b/sysid/src/main/native/cpp/analysis/FilteringUtils.cpp @@ -158,18 +158,22 @@ sysid::TrimStepVoltageData(std::vector* data, minStepTime = std::min(data->at(0).timestamp - firstTimestamp, minStepTime); - // Find maximum speed reached - const auto maxSpeed = - GetMaxSpeed(*data, [](auto&& pt) { return pt.velocity; }); - // Find place where 90% of maximum speed exceeded - auto endIt = - std::find_if(data->begin(), data->end(), [&](const PreparedData& entry) { - return std::abs(entry.velocity) > maxSpeed * 0.9; - }); + // If step test duration not yet specified, calculate default + if (settings->stepTestDuration == 0_s) { + // Find maximum speed reached + const auto maxSpeed = + GetMaxSpeed(*data, [](auto&& pt) { return pt.velocity; }); + // Find place where 90% of maximum speed exceeded + auto endIt = std::find_if( + data->begin(), data->end(), [&](const PreparedData& entry) { + return std::abs(entry.velocity) > maxSpeed * 0.9; + }); - if (endIt != data->end()) { - settings->stepTestDuration = std::min( - endIt->timestamp - data->front().timestamp + minStepTime, maxStepTime); + if (endIt != data->end()) { + settings->stepTestDuration = + std::min(endIt->timestamp - data->front().timestamp + minStepTime, + maxStepTime); + } } // Find first entry greater than the step test duration diff --git a/sysid/src/main/native/include/sysid/view/Analyzer.h b/sysid/src/main/native/include/sysid/view/Analyzer.h index 7dcfd41164..7175cb9ca4 100644 --- a/sysid/src/main/native/include/sysid/view/Analyzer.h +++ b/sysid/src/main/native/include/sysid/view/Analyzer.h @@ -225,7 +225,7 @@ class Analyzer : public glass::View { int m_dataset = 0; int m_window = 8; double m_threshold = 0.2; - float m_stepTestDuration = 10; + float m_stepTestDuration = 0; double m_gearingNumerator = 1.0; double m_gearingDenominator = 1.0;