Skip to content

Commit

Permalink
Some tweaks to the automated test thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
jpieper committed May 9, 2022
1 parent a60aab4 commit 5bbb281
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions utils/dynamometer_drive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,12 @@ class Application {
// Then slew phase around. We'll make sure that the current
// remains largely in the D phase, and that the fixture does
// indeed move around.
const double kSlewVoltage = 0.35;
for (double phase = 0.0; phase < 30.0; phase += 1.0) {
fmt::print("{} \r", phase);
::fflush(stdout);
slew_results.push_back(
co_await RunPwmVoltage(phase, 0.35));
co_await RunPwmVoltage(phase, kSlewVoltage));
}

co_await dut_->Command("d stop");
Expand Down Expand Up @@ -865,9 +866,10 @@ class Application {
}

// This test runs with a motor that has a phase resistance of
// roughly 0.062 ohms.
// roughly 0.051-0.062 ohms.
const float kMotorResistance = 0.055;
for (const auto& r : ramp_results) {
const auto expected_current = r.voltage / 0.062;
const auto expected_current = r.voltage / kMotorResistance;
if (std::abs(r.d_A - expected_current) > 2.5) {
errors.push_back(
fmt::format(
Expand All @@ -886,9 +888,9 @@ class Application {
fmt::format("fixture moved position at voltage {}", r.voltage));
break;
}
if (std::abs(r.fixture_speed) > 0.1) {
if (std::abs(r.fixture_speed) > 0.12) {
errors.push_back(
fmt::format("fixture had non-zero velocity at voltage {} |{}|>0.1",
fmt::format("fixture had non-zero velocity at voltage {} |{}|>0.12",
r.voltage, r.fixture_speed));
break;
}
Expand All @@ -905,8 +907,8 @@ class Application {
}

for (const auto& r : slew_results) {
const double kExpectedCurrent = 6.0;
const double kMaxError = 1.5;
const double kExpectedCurrent = kSlewVoltage / kMotorResistance;
const double kMaxError = 1.8;
if (std::abs(r.d_A - kExpectedCurrent) > kMaxError) {
errors.push_back(
fmt::format("D phase is not correct |{} - {}| > {}",
Expand All @@ -916,7 +918,7 @@ class Application {
}

for (const auto& r : slew_results) {
if (std::abs(r.fixture_speed) > 0.1) {
if (std::abs(r.fixture_speed) > 0.12) {
errors.push_back(
fmt::format("fixture has non-zero speed at phase {}, {} != 0.0",
r.phase, r.fixture_speed));
Expand Down Expand Up @@ -1347,10 +1349,10 @@ class Application {
const double expected_torque = kDelayS * pid.ki * position;

verify_position_mode();
if (std::abs(current_torque_Nm_ - expected_torque) > 0.16) {
if (std::abs(current_torque_Nm_ - expected_torque) > 0.17) {
throw mjlib::base::system_error::einval(
fmt::format("ki torque not as expected {} != {} (within {})",
current_torque_Nm_, expected_torque, 0.16));
current_torque_Nm_, expected_torque, 0.17));
}

// Stop the DUT to clear out the I term.
Expand Down Expand Up @@ -1901,9 +1903,9 @@ class Application {
double expected_speed_Hz;
} tests[] = {
{ 100.0, 4.04 },
{ 20.0, 3.0 },
{ 10.0, 2.09 },
{ 5.0, 1.55 },
{ 20.0, 2.35 },
{ 10.0, 1.69 },
{ 5.0, 1.17 },
};

for (const auto test : tests) {
Expand Down Expand Up @@ -2091,9 +2093,9 @@ class Application {
// fixture's MiToot motor.
{ 0.0, 0.0 },
{ 2.0, 0.1 },
{ 5.0, 0.28 },
{ 5.0, 0.30 },
{ -2.0, -0.1 },
{ -5.0, -0.28 },
{ -5.0, -0.30 },
};

for (const auto& test : brake_tests) {
Expand Down

0 comments on commit 5bbb281

Please sign in to comment.