fix(speedl): preserve recoverable braking fault classification
This commit is contained in:
parent
f7cc998c3d
commit
e22d86deb1
@ -330,11 +330,13 @@ void SpeedLExecutor::workerLoop_()
|
|||||||
{
|
{
|
||||||
CycleGuard cycle{end_cycle_, status, computation_result};
|
CycleGuard cycle{end_cycle_, status, computation_result};
|
||||||
const auto emergency_zero = [&] {
|
const auto emergency_zero = [&] {
|
||||||
computation_result = false;
|
|
||||||
CMVR_LOG(ERROR) << "[SpeedLExecutor] constrained braking failed; issuing emergency zero"
|
CMVR_LOG(ERROR) << "[SpeedLExecutor] constrained braking failed; issuing emergency zero"
|
||||||
<< " (acceleration/jerk not guaranteed): " << status.message;
|
<< " (acceleration/jerk not guaranteed): " << status.message;
|
||||||
const auto zero_result = sendVelocity_(JointVelocityCommand{std::vector<double>(dof_, 0.0)});
|
const auto zero_result = sendVelocity_(JointVelocityCommand{std::vector<double>(dof_, 0.0)});
|
||||||
if (!zero_result.ok()) status.message += "; " + zero_result.message;
|
if (!zero_result.ok()) {
|
||||||
|
computation_result = false;
|
||||||
|
status.message += "; " + zero_result.message;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
if (begin_cycle_) {
|
if (begin_cycle_) {
|
||||||
@ -402,10 +404,12 @@ void SpeedLExecutor::workerLoop_()
|
|||||||
!stop_requested_.load()) {
|
!stop_requested_.load()) {
|
||||||
// Use the feedback from this acquired cycle: never release
|
// Use the feedback from this acquired cycle: never release
|
||||||
// the failed cycle while the previous speed is still held.
|
// the failed cycle while the previous speed is still held.
|
||||||
computation_result = false;
|
computation_result = true;
|
||||||
planning_result = false;
|
|
||||||
planned = planner_->brakeStep(dt, q_now, qd_now);
|
planned = planner_->brakeStep(dt, q_now, qd_now);
|
||||||
status = planned.status;
|
status = planned.status;
|
||||||
|
// A joint-limit rejection still belongs to planning if
|
||||||
|
// emergency zero and the final measured stop succeed.
|
||||||
|
planning_result = status.code == ArmErrorCode::OutOfJointLimit;
|
||||||
}
|
}
|
||||||
if (status.ok() && !stop_requested_.load()) {
|
if (status.ok() && !stop_requested_.load()) {
|
||||||
computation_result = false;
|
computation_result = false;
|
||||||
|
|||||||
@ -646,13 +646,16 @@ TEST(SpeedLExecutor, FailedCycleBrakesBeforeReleaseAndKeepsOriginalFaultUntilSto
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SpeedLExecutor, FailedBrakeOrBrakeOutputSendsEmergencyZeroWithoutCommitting) {
|
TEST(SpeedLExecutor, FailedBrakeOrBrakeOutputSendsEmergencyZeroWithoutCommitting) {
|
||||||
for (const bool fail_output : {false, true}) {
|
for (const std::string_view failure : {"braking limit", "brake output", "emergency zero"}) {
|
||||||
SCOPED_TRACE(fail_output);
|
SCOPED_TRACE(failure);
|
||||||
auto planner = std::make_shared<Planner>();
|
auto planner = std::make_shared<Planner>();
|
||||||
planner->check = [](std::string_view operation) { return operation != "step"; };
|
std::atomic<bool> reject_step{true};
|
||||||
|
planner->check = [&](std::string_view operation) {
|
||||||
|
return operation != "step" || !reject_step.load();
|
||||||
|
};
|
||||||
planner->brake = [&](double, const auto&, const auto&) {
|
planner->brake = [&](double, const auto&, const auto&) {
|
||||||
CartesianVelocityStep result;
|
CartesianVelocityStep result;
|
||||||
result.status = fail_output ? Result::success()
|
result.status = failure == "brake output" ? Result::success()
|
||||||
: Result::failure(ArmErrorCode::OutOfJointLimit, "braking distance exhausted");
|
: Result::failure(ArmErrorCode::OutOfJointLimit, "braking distance exhausted");
|
||||||
result.joint_velocity.velocity = {.02};
|
result.joint_velocity.velocity = {.02};
|
||||||
return result;
|
return result;
|
||||||
@ -662,10 +665,16 @@ TEST(SpeedLExecutor, FailedBrakeOrBrakeOutputSendsEmergencyZeroWithoutCommitting
|
|||||||
SpeedLExecutor executor({}, planner, 1,
|
SpeedLExecutor executor({}, planner, 1,
|
||||||
[](auto& q, auto& qd) { q = {0}; qd = {0}; return true; },
|
[](auto& q, auto& qd) { q = {0}; qd = {0}; return true; },
|
||||||
[&](const JointVelocityCommand& command) {
|
[&](const JointVelocityCommand& command) {
|
||||||
if (command.velocity.front() != 0)
|
if (command.velocity.front() != 0) {
|
||||||
return Result::failure(ArmErrorCode::CommandFailed, "brake send rejected");
|
return failure == "brake output"
|
||||||
|
? Result::failure(ArmErrorCode::CommandFailed, "brake send rejected")
|
||||||
|
: Result::success();
|
||||||
|
}
|
||||||
++zero_sends;
|
++zero_sends;
|
||||||
if (releases == 0) zero_before_release = true;
|
if (releases == 0) zero_before_release = true;
|
||||||
|
if (failure == "emergency zero" && zero_sends == 1) {
|
||||||
|
return Result::failure(ArmErrorCode::CommandFailed, "emergency zero rejected");
|
||||||
|
}
|
||||||
return Result::success();
|
return Result::success();
|
||||||
}, {}, [] { return .001; }, [&](bool) { ++releases; });
|
}, {}, [] { return .001; }, [&](bool) { ++releases; });
|
||||||
CartesianVelocity target;
|
CartesianVelocity target;
|
||||||
@ -678,8 +687,23 @@ TEST(SpeedLExecutor, FailedBrakeOrBrakeOutputSendsEmergencyZeroWithoutCommitting
|
|||||||
EXPECT_EQ(planner->brakes, 1);
|
EXPECT_EQ(planner->brakes, 1);
|
||||||
EXPECT_NE(executor.lastResult().message.find("step failed"), std::string::npos);
|
EXPECT_NE(executor.lastResult().message.find("step failed"), std::string::npos);
|
||||||
EXPECT_NE(executor.lastResult().message.find(
|
EXPECT_NE(executor.lastResult().message.find(
|
||||||
fail_output ? "brake send rejected" : "braking distance exhausted"), std::string::npos);
|
failure == "brake output" ? "brake send rejected" : "braking distance exhausted"),
|
||||||
EXPECT_EQ(executor.clearPlanningFault().code, ArmErrorCode::RobotInFault);
|
std::string::npos);
|
||||||
|
if (failure == "emergency zero") {
|
||||||
|
EXPECT_NE(executor.lastResult().message.find("emergency zero rejected"), std::string::npos);
|
||||||
|
}
|
||||||
|
ASSERT_TRUE(executor.shutdown().ok());
|
||||||
|
const auto recovery = executor.clearPlanningFault();
|
||||||
|
if (failure == "braking limit") {
|
||||||
|
ASSERT_TRUE(recovery.ok()) << recovery.message;
|
||||||
|
EXPECT_FALSE(executor.faulted());
|
||||||
|
reject_step.store(false);
|
||||||
|
ASSERT_TRUE(executor.speedL(target, {}, 0, FrameType::Base).ok());
|
||||||
|
EXPECT_TRUE(waitUntil([&] { return planner->commits > 0; }));
|
||||||
|
} else {
|
||||||
|
EXPECT_EQ(recovery.code, ArmErrorCode::RobotInFault);
|
||||||
|
EXPECT_TRUE(executor.faulted());
|
||||||
|
}
|
||||||
EXPECT_TRUE(executor.shutdown().ok());
|
EXPECT_TRUE(executor.shutdown().ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user