Skip to content

Commit

Permalink
fix test duration slider responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
Oblarg committed Jan 13, 2024
1 parent 84e3a22 commit 30d29e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions sysid/src/main/native/cpp/analysis/FilteringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,23 @@ sysid::TrimStepVoltageData(std::vector<PreparedData>* 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 (endIt != data->end()) {
settings->stepTestDuration = std::min(
endIt->timestamp - data->front().timestamp + minStepTime, maxStepTime);
// 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);
}
}

// Find first entry greater than the step test duration
auto maxIt =
std::find_if(data->begin(), data->end(), [&](PreparedData entry) {
Expand Down
2 changes: 1 addition & 1 deletion sysid/src/main/native/include/sysid/view/Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 30d29e1

Please sign in to comment.