tests: homing: cleanup SimulateFailedHomeFirstTime
We never home Idler and Selector at the same time. I think we did early perhaps, but now the selector always waits for the idler homing to be valid.pull/337/head
parent
79b0d0bec0
commit
c2bf5fc3e0
|
|
@ -185,33 +185,40 @@ bool SimulateFailedHomeSelectorPostfix(logic::CommandBase &cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimulateFailedHomeFirstTime(logic::CommandBase &cb) {
|
bool SimulateFailedHomeFirstTime(logic::CommandBase &cb) {
|
||||||
if (mi::idler.HomingValid())
|
REQUIRE(!mi::idler.HomingValid());
|
||||||
return false;
|
REQUIRE(!ms::selector.HomingValid());
|
||||||
if (ms::selector.HomingValid())
|
|
||||||
return false;
|
// Idler homing is successful
|
||||||
|
SimulateIdlerHoming(cb);
|
||||||
|
SimulateIdlerWaitForHomingValid(cb);
|
||||||
|
|
||||||
|
// Selector homes once the idler homing is valid.
|
||||||
|
REQUIRE(mi::idler.HomingValid());
|
||||||
|
REQUIRE(!ms::selector.HomingValid());
|
||||||
|
|
||||||
|
// The selector will only rehome once the idler homing is valid. At that moment
|
||||||
|
// the state will change to HomeForward.
|
||||||
|
REQUIRE(WhileCondition(
|
||||||
|
cb,
|
||||||
|
[&](uint32_t) { return ms::selector.State() != mm::MovableBase::HomeForward; },
|
||||||
|
5000));
|
||||||
|
|
||||||
constexpr uint32_t selectorSteps = mm::unitToSteps<mm::S_pos_t>(config::selectorLimits.lenght) + 1;
|
constexpr uint32_t selectorSteps = mm::unitToSteps<mm::S_pos_t>(config::selectorLimits.lenght) + 1;
|
||||||
{
|
{
|
||||||
// do 5 steps until we trigger the simulated StallGuard
|
// do 5 steps until we trigger the simulated StallGuard
|
||||||
constexpr uint32_t idlerStepsFwd = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght - 5.0_deg);
|
for (uint32_t i = 0; i < selectorSteps; ++i) {
|
||||||
static_assert(idlerStepsFwd < selectorSteps); // beware, we expect that the Idler homes faster than Selector (less steps)
|
|
||||||
for (uint32_t i = 0; i < idlerStepsFwd; ++i) {
|
|
||||||
main_loop();
|
main_loop();
|
||||||
cb.Step();
|
cb.Step();
|
||||||
}
|
}
|
||||||
|
|
||||||
mm::TriggerStallGuard(mm::Selector);
|
mm::TriggerStallGuard(mm::Selector);
|
||||||
mm::TriggerStallGuard(mm::Idler);
|
|
||||||
main_loop();
|
main_loop();
|
||||||
cb.Step();
|
cb.Step();
|
||||||
mm::motion.StallGuardReset(mm::Selector);
|
mm::motion.StallGuardReset(mm::Selector);
|
||||||
mm::motion.StallGuardReset(mm::Idler);
|
|
||||||
}
|
}
|
||||||
// now do a correct amount of steps of each axis towards the other end
|
|
||||||
constexpr uint32_t idlerSteps = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght);
|
|
||||||
// now do LESS steps than expected to simulate something is blocking the selector
|
|
||||||
|
|
||||||
constexpr uint32_t selectorTriggerShort = std::min(idlerSteps, selectorSteps) / 2;
|
// now do LESS steps than expected to simulate something is blocking the selector
|
||||||
|
constexpr uint32_t selectorTriggerShort = selectorSteps / 2;
|
||||||
constexpr uint32_t maxSteps = selectorTriggerShort + 1;
|
constexpr uint32_t maxSteps = selectorTriggerShort + 1;
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < maxSteps; ++i) {
|
for (uint32_t i = 0; i < maxSteps; ++i) {
|
||||||
|
|
@ -225,17 +232,6 @@ bool SimulateFailedHomeFirstTime(logic::CommandBase &cb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the Idler finishes its homing procedure (makes further checks much easier)
|
|
||||||
for (uint32_t i = maxSteps; i < idlerSteps + 1; ++i) {
|
|
||||||
main_loop();
|
|
||||||
cb.Step();
|
|
||||||
if (i == idlerSteps) {
|
|
||||||
mm::TriggerStallGuard(mm::Idler);
|
|
||||||
} else {
|
|
||||||
mm::motion.StallGuardReset(mm::Idler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!(ms::selector.State() & mm::MovableBase::OnHold)) {
|
while (!(ms::selector.State() & mm::MovableBase::OnHold)) {
|
||||||
main_loop();
|
main_loop();
|
||||||
cb.Step();
|
cb.Step();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue