Update to latest main + fix unit tests
... in relation to the newly introduced stepping in physical units rather than in stepspull/77/head
parent
16dc129b49
commit
aa5995368d
|
|
@ -7,42 +7,26 @@ namespace config {
|
|||
|
||||
static constexpr const uint8_t toolCount = 5U; ///< Max number of extruders/tools/slots
|
||||
|
||||
// Idler's setup
|
||||
/*
|
||||
static constexpr U_deg idlerSlotPositions[toolCount + 1] = {
|
||||
1.0_deg, 2.0_deg, 3.0_deg, 4.0_deg, 5.0_deg, 0
|
||||
}; ///< slots 0-4 are the real ones, the 5th is the idle position
|
||||
|
||||
// Selector's setup
|
||||
static constexpr U_mm selectorSlotPositions[toolCount + 1] = {
|
||||
1.0_mm, 2.0_mm, 3.0_mm, 4.0_mm, 5.0_mm, 6.0_mm
|
||||
}; ///< slots 0-4 are the real ones, the 5th is the farthest parking positions
|
||||
*/
|
||||
/// Idler steps between neighbor positions: 2 msteps = 180 / 4
|
||||
static constexpr uint16_t idlerSteps = 1420 / 4;
|
||||
|
||||
/// Absolute positions for Idler's slots: 0-4 are the real ones, the 5th index is the idle position
|
||||
static constexpr uint16_t idlerSlotPositions[toolCount + 1] = {
|
||||
idlerSteps,
|
||||
idlerSteps * 2,
|
||||
idlerSteps * 3,
|
||||
idlerSteps * 4,
|
||||
idlerSteps * 5,
|
||||
0
|
||||
static constexpr U_deg idlerSlotPositions[toolCount + 1] = {
|
||||
45.0_deg,
|
||||
90.0_deg,
|
||||
135.0_deg,
|
||||
180.0_deg,
|
||||
225.0_deg,
|
||||
0.0_deg
|
||||
};
|
||||
|
||||
// Selector's setup
|
||||
|
||||
/// Selector steps between neighbor positions
|
||||
static constexpr uint16_t selectorSteps = 2790 / 4;
|
||||
/// slots 0-4 are the real ones, the 5th is the farthest parking positions
|
||||
static constexpr uint16_t selectorSlotPositions[toolCount + 1] = {
|
||||
selectorSteps,
|
||||
selectorSteps * 2,
|
||||
selectorSteps * 3,
|
||||
selectorSteps * 4,
|
||||
selectorSteps * 5,
|
||||
selectorSteps * 6
|
||||
static constexpr U_mm selectorSlotPositions[toolCount + 1] = {
|
||||
20.0_mm,
|
||||
20.0_mm + 14.0_mm,
|
||||
20.0_mm + 2.0_mm * 14.0_mm,
|
||||
20.0_mm + 3.0_mm * 14.0_mm,
|
||||
20.0_mm + 4.0_mm * 14.0_mm,
|
||||
20.0_mm + 5.0_mm * 14.0_mm
|
||||
};
|
||||
|
||||
// Printer's filament sensor setup
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ void CutSlot(uint8_t cutSlot) {
|
|||
REQUIRE(VerifyState(cf, false, mi::Idler::IdleSlotIndex(), cutSlot, false, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::SelectingFilamentSlot));
|
||||
|
||||
// now cycle at most some number of cycles (to be determined yet) and then verify, that the idler and selector reached their target positions
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::SelectingFilamentSlot, 5000));
|
||||
// Beware - with the real positions of the selector, the number of steps needed to finish some states grows, so the ~40K steps here has a reason
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::SelectingFilamentSlot, selectorMoveMaxSteps));
|
||||
|
||||
// idler and selector reached their target positions and the CF automaton will start feeding to FINDA as the next step
|
||||
REQUIRE(VerifyState(cf, false, cutSlot, cutSlot, false, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::FeedingToFinda));
|
||||
|
|
@ -84,11 +85,11 @@ void CutSlot(uint8_t cutSlot) {
|
|||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, cutSlot + 1, false, cutSlot, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::PerformingCut));
|
||||
|
||||
// cutting
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::PerformingCut, 10000));
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::PerformingCut, selectorMoveMaxSteps));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, 0, false, cutSlot, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::ReturningSelector));
|
||||
|
||||
// moving selector to the other end of its axis
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::ReturningSelector, 5000));
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::ReturningSelector, selectorMoveMaxSteps));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, ms::Selector::IdleSlotIndex(), false, cutSlot, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf) {
|
|||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::EngagingIdler));
|
||||
|
||||
// Stage 1 - engaging idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::EngagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::EngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::FeedingToFinda));
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) {
|
|||
REQUIRE(VerifyState(lf, false, slot, slot, true, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::DisengagingIdler));
|
||||
|
||||
// Stage 4 - disengaging idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::DisengagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, true, mi::Idler::IdleSlotIndex(), slot, true, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ void FailedLoadToFinda(uint8_t slot, logic::LoadFilament &lf) {
|
|||
REQUIRE(VerifyState(lf, false, slot, slot, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRDisengagingIdler));
|
||||
|
||||
// Stage 3 - disengaging idler in error mode
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERRDisengagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERR1DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ void FailedLoadToFindaResolveHelp(uint8_t slot, logic::LoadFilament &lf) {
|
|||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERREngagingIdler));
|
||||
|
||||
// Stage 4 - engage the idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERREngagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERR1EngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRHelpingFilament));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,3 +24,9 @@ bool WhileTopState(SM &sm, ProgressCode state, uint32_t maxLoops = 5000) {
|
|||
extern void EnsureActiveSlotIndex(uint8_t slot);
|
||||
|
||||
extern void SetFINDAStateAndDebounce(bool press);
|
||||
|
||||
// these are recommended max steps for simulated movement of the idler and selector
|
||||
// - roughly the amount of motion steps from one end to the other + some margin
|
||||
// ... could be computed in the future from the pre-set number of microsteps and real positions
|
||||
static constexpr uint32_t idlerEngageDisengageMaxSteps = 40000UL;
|
||||
static constexpr uint32_t selectorMoveMaxSteps = 40000UL;
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ void Motion::AbortPlannedMoves() {
|
|||
}
|
||||
|
||||
void ReinitMotion() {
|
||||
const pos_t selector_pos = unitToSteps<S_pos_t>(config::selectorSlotPositions[0]);
|
||||
|
||||
// reset the simulation data to defaults
|
||||
axes[0] = AxisSim({ 0, 0, false, false, false }); // pulley
|
||||
// axes[1] = AxisSim({ selector_pos, selector_pos, false, false, false }); // selector //@@TODO proper selector positions once defined
|
||||
// axes[2] = AxisSim({ 0, 0, false, false, false }); // idler
|
||||
axes[1] = AxisSim({ config::selectorSlotPositions[0], config::selectorSlotPositions[0], false, false, false }); // selector
|
||||
axes[2] = AxisSim({ config::idlerSlotPositions[mi::Idler::IdleSlotIndex()], config::idlerSlotPositions[mi::Idler::IdleSlotIndex()], false, false, false }); // idler
|
||||
axes[1] = AxisSim({ unitToSteps<S_pos_t>(config::selectorSlotPositions[0]),
|
||||
unitToSteps<S_pos_t>(config::selectorSlotPositions[0]),
|
||||
false, false, false }); // selector
|
||||
axes[2] = AxisSim({ unitToSteps<I_pos_t>(config::idlerSlotPositions[mi::Idler::IdleSlotIndex()]),
|
||||
unitToSteps<I_pos_t>(config::idlerSlotPositions[mi::Idler::IdleSlotIndex()]),
|
||||
false, false, false }); // idler
|
||||
}
|
||||
|
||||
/// probably higher-level operations knowing the semantic meaning of axes
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void ToolChange(uint8_t fromSlot, uint8_t toSlot) {
|
|||
hal::adc::SetADC(config::findaADCIndex, 0);
|
||||
}
|
||||
return tc.TopLevelState() == ProgressCode::UnloadingFilament; },
|
||||
50000));
|
||||
200000UL));
|
||||
REQUIRE(mg::globals.FilamentLoaded() == false);
|
||||
|
||||
REQUIRE(WhileCondition(
|
||||
|
|
@ -54,7 +54,7 @@ void ToolChange(uint8_t fromSlot, uint8_t toSlot) {
|
|||
hal::adc::SetADC(config::findaADCIndex, 900);
|
||||
}
|
||||
return tc.TopLevelState() == ProgressCode::LoadingFilament; },
|
||||
50000));
|
||||
200000UL));
|
||||
|
||||
REQUIRE(tc.TopLevelState() == ProgressCode::OK);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == true);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
hal::adc::SetADC(config::findaADCIndex, 0);
|
||||
}
|
||||
return uf.TopLevelState() == ProgressCode::UnloadingToFinda; },
|
||||
5000));
|
||||
50000));
|
||||
|
||||
// we still think we have filament loaded at this stage
|
||||
// idler should have been activated by the underlying automaton
|
||||
|
|
@ -76,7 +76,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
REQUIRE(VerifyState(uf, true, slot, slot, false, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::DisengagingIdler));
|
||||
|
||||
// Stage 2 - idler was engaged, disengage it
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::DisengagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
||||
// we still think we have filament loaded at this stage
|
||||
// idler should have been disengaged
|
||||
|
|
@ -161,7 +161,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
REQUIRE(VerifyState(uf, true, slot, slot, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRDisengagingIdler));
|
||||
|
||||
// Stage 2 - idler should get disengaged
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERRDisengagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERR1DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
||||
// we still think we have filament loaded at this stage
|
||||
// idler should have been disengaged
|
||||
|
|
@ -197,7 +197,7 @@ void FindaDidntTriggerResolveHelp(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERREngagingIdler));
|
||||
|
||||
// Stage 4 - engage the idler
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERREngagingIdler, 5000));
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERR1EngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
||||
// we still think we have filament loaded at this stage
|
||||
// idler should be engaged
|
||||
|
|
|
|||
Loading…
Reference in New Issue