Convert config::selectorSlotPositions to physical units
parent
6daf7fd060
commit
d955897829
|
|
@ -13,7 +13,9 @@ static constexpr U_deg idlerSlotPositions[toolCount + 1] = {
|
|||
}; ///< slots 0-4 are the real ones, the 5th is the idle position
|
||||
|
||||
// Selector's setup
|
||||
static constexpr uint16_t selectorSlotPositions[toolCount + 1] = { 1, 2, 3, 4, 5, 6 }; ///< slots 0-4 are the real ones, the 5th is the farthest parking positions
|
||||
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
|
||||
|
||||
// Printer's filament sensor setup
|
||||
static constexpr const uint16_t fsensorDebounceMs = 10;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ bool Selector::MoveToSlot(uint8_t slot) {
|
|||
return true;
|
||||
|
||||
mm::motion.InitAxis(mm::Selector);
|
||||
mm::motion.PlanMove(mm::Selector, config::selectorSlotPositions[slot] - mm::motion.Position(mm::Selector), 1000); // @@TODO
|
||||
mm::motion.PlanMoveTo<mm::Selector>(SlotPosition(slot), 1000.0_S_mm_s); // @@TODO
|
||||
state = Moving;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
#pragma once
|
||||
#include "../config/config.h"
|
||||
#include <stdint.h>
|
||||
#include "../modules/axisunit.h"
|
||||
|
||||
namespace modules {
|
||||
|
||||
/// The selector namespace provides all necessary facilities related to the logical model of the selector device of the MMU unit.
|
||||
namespace selector {
|
||||
|
||||
namespace mm = modules::motion;
|
||||
|
||||
/// The selector model - handles asynchronnous move operations between filament individual slots and keeps track of selector's current state.
|
||||
class Selector {
|
||||
public:
|
||||
|
|
@ -41,7 +43,9 @@ public:
|
|||
inline uint8_t Slot() const { return currentSlot; }
|
||||
|
||||
/// @returns predefined positions of individual slots
|
||||
inline static uint16_t SlotPosition(uint8_t slot) { return config::selectorSlotPositions[slot]; }
|
||||
static constexpr mm::S_pos_t SlotPosition(uint8_t slot) {
|
||||
return mm::unitToAxisUnit<mm::S_pos_t>(config::selectorSlotPositions[slot]);
|
||||
}
|
||||
|
||||
/// @returns the index of idle position of the selector, usually 5 in case of 0-4 valid indices of filament slots
|
||||
inline static constexpr uint8_t IdleSlotIndex() { return config::toolCount; }
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ TEST_CASE("eject_filament::eject0", "[eject_filament][.]") {
|
|||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(modules::motion::axes[modules::motion::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(modules::motion::axes[modules::motion::Selector].targetPos == ms::Selector::SlotPosition(4));
|
||||
CHECK(modules::motion::axes[modules::motion::Selector].targetPos == ms::Selector::SlotPosition(4).v);
|
||||
|
||||
// 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(ef, ProgressCode::SelectingFilamentSlot, 5000));
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
// it should have instructed the selector and idler to move to slot 0
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
|
|
@ -55,7 +55,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
5000));
|
||||
|
||||
CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// idler engaged, selector in position, we'll start pushing filament
|
||||
REQUIRE(fb.State() == FeedToBondtech::PushingFilament);
|
||||
|
|
@ -81,7 +81,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
// 5000));
|
||||
|
||||
// CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(5)); // @@TODO constants
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// state machine finished ok, the green LED should be on
|
||||
REQUIRE(fb.State() == FeedToBondtech::OK);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
|
|
@ -55,7 +55,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
5000));
|
||||
|
||||
CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// idler engaged, selector in position, we'll start pushing filament
|
||||
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
||||
|
|
@ -87,7 +87,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
// 5000));
|
||||
|
||||
CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v); // @@TODO constants
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// state machine finished ok, the green LED should be on
|
||||
REQUIRE(ff.State() == FeedToFinda::OK);
|
||||
|
|
@ -112,7 +112,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
|||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// engaging idler
|
||||
REQUIRE(WhileCondition(
|
||||
|
|
@ -121,7 +121,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
|||
5000));
|
||||
|
||||
CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// idler engaged, we'll start pushing filament
|
||||
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ bool VerifyState(SM &uf, bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t se
|
|||
CHECKED_ELSE(mg::globals.FilamentLoaded() == filamentLoaded) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(idlerSlotIndex).v) { return false; }
|
||||
CHECKED_ELSE(mi::idler.Engaged() == (idlerSlotIndex < config::toolCount)) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(selectorSlotIndex)) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(selectorSlotIndex).v) { return false; }
|
||||
CHECKED_ELSE(ms::selector.Slot() == selectorSlotIndex) { return false; }
|
||||
CHECKED_ELSE(mf::finda.Pressed() == findaPressed) { return false; }
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ bool VerifyState2(SM &uf, bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t s
|
|||
CHECKED_ELSE(mg::globals.FilamentLoaded() == filamentLoaded) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(idlerSlotIndex).v) { return false; }
|
||||
CHECKED_ELSE(mi::idler.Engaged() == (idlerSlotIndex < config::toolCount)) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(selectorSlotIndex)) { return false; }
|
||||
CHECKED_ELSE(mm::axes[mm::Selector].pos == ms::Selector::SlotPosition(selectorSlotIndex).v) { return false; }
|
||||
CHECKED_ELSE(ms::selector.Slot() == selectorSlotIndex) { return false; }
|
||||
CHECKED_ELSE(mf::finda.Pressed() == findaPressed) { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -70,9 +70,11 @@ 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({ 1, 1, false, false, false }); // selector //@@TODO proper selector positions once defined
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
|||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
|
|
@ -94,7 +94,7 @@ TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]")
|
|||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0));
|
||||
CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
|
|
|
|||
Loading…
Reference in New Issue