Skip to content

Commit

Permalink
[sysid] Relax peak acceleration search (wpilibsuite#6378)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oblarg authored and DeltaDizzy committed Mar 26, 2024
1 parent 03dfc05 commit 4217a12
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sysid/src/main/native/cpp/analysis/FilteringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,18 @@ sysid::TrimStepVoltageData(std::vector<PreparedData>* data,
wpi::sgn(b.velocity) * b.acceleration;
});

// Current limiting can delay onset of the peak acceleration, so we need to
// find the first acceleration *near* the max. Magic number tolerance here
// because this whole file is tech debt already
auto accelBegins = std::find_if(
data->begin(), data->end(), [&maxAccel](const auto& measurement) {
return wpi::sgn(measurement.velocity) * measurement.acceleration >
0.8 * wpi::sgn(maxAccel->velocity) * maxAccel->acceleration;
});

units::second_t velocityDelay;
if (maxAccel != data->end()) {
velocityDelay = maxAccel->timestamp - firstTimestamp;
if (accelBegins != data->end()) {
velocityDelay = accelBegins->timestamp - firstTimestamp;

// Trim data before max acceleration
data->erase(data->begin(), maxAccel);
Expand Down

0 comments on commit 4217a12

Please sign in to comment.