From 8ac36791e67547ec0e1487635922f31d3365e5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Wed, 21 Dec 2022 21:33:56 +0000 Subject: [PATCH] WIP: Allow prism printing volumes --- .../Kinematics/HangprinterKinematics.cpp | 22 ++++++++++++++++++- .../Kinematics/HangprinterKinematics.h | 7 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Movement/Kinematics/HangprinterKinematics.cpp b/src/Movement/Kinematics/HangprinterKinematics.cpp index eb6874a231..83aac35f9d 100644 --- a/src/Movement/Kinematics/HangprinterKinematics.cpp +++ b/src/Movement/Kinematics/HangprinterKinematics.cpp @@ -96,6 +96,7 @@ void HangprinterKinematics::Init() noexcept constexpr uint32_t DefaultFullStepsPerMotorRev[HANGPRINTER_MAX_AXES] = { 25, 25, 25, 25, 25, 25, 25, 25, 25}; ARRAY_INIT(anchors, DefaultAnchors); numAnchors = DefaultNumAnchors; + anchorsSetup = LastTopRestDown; printRadius = DefaultPrintRadius; spoolBuildupFactor = DefaultSpoolBuildupFactor; ARRAY_INIT(spoolRadii, DefaultSpoolRadii); @@ -359,7 +360,9 @@ static bool isSameSide(float const v0[3], float const v1[3], float const v2[3], return dot0*dot1 > 0.0F; } -bool HangprinterKinematics::IsReachable(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept /*override*/ +// The last axe must be the one on the top +// TODO Validate this in HangprinterKinematics::Configure +bool HangprinterKinematics::IsReachablePyramid(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept /*override*/ { float const coords[3] = {axesCoords[X_AXIS], axesCoords[Y_AXIS], axesCoords[Z_AXIS]}; @@ -381,6 +384,23 @@ bool HangprinterKinematics::IsReachable(float axesCoords[MaxAxes], AxesBitmap ax return reachable; } +bool HangprinterKinematics::IsReachablePrism(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept +{ + // TODO Implement. We will need some sort of max height parameter since it's not implicit here. + return true; +} + +bool HangprinterKinematics::IsReachable(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept +{ + switch (anchorsSetup) { + case LastTopRestDown: + default: + return IsReachablePyramid(axesCoords, axes); + case AllTop: + return IsReachablePrism(axesCoords, axes); + } +} + // Limit the Cartesian position that the user wants to move to returning true if we adjusted the position LimitPositionResult HangprinterKinematics::LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesToLimit, bool isCoordinated, bool applyM208Limits) const noexcept diff --git a/src/Movement/Kinematics/HangprinterKinematics.h b/src/Movement/Kinematics/HangprinterKinematics.h index e2d7df05cf..6b3080b424 100644 --- a/src/Movement/Kinematics/HangprinterKinematics.h +++ b/src/Movement/Kinematics/HangprinterKinematics.h @@ -50,6 +50,9 @@ class HangprinterKinematics : public RoundBedKinematics OBJECT_MODEL_ARRAY(anchors) OBJECT_MODEL_ARRAY(anchorCoordinates) + bool IsReachablePyramid(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept; + bool IsReachablePrism(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept; + private: // Basic facts about movement system const char* ANCHOR_CHARS = "ABCDEFHIJ"; // Skip the G, since it is reserved in G-code @@ -58,6 +61,9 @@ class HangprinterKinematics : public RoundBedKinematics static constexpr size_t B_AXIS = 1; static constexpr size_t C_AXIS = 2; static constexpr size_t D_AXIS = 3; + // LastTopRestDown (default) has a single anchor on top and produces pyramid-shaped printing volumes + // AllTop has a all anchors on top and produces prism-shaped printing volumes + enum AnchorsSetup {LastTopRestDown, AllTop}; // Allowed setups for placing the anchors void Init() noexcept; void Recalc() noexcept; @@ -69,6 +75,7 @@ class HangprinterKinematics : public RoundBedKinematics size_t numAnchors; float anchors[HANGPRINTER_MAX_AXES][3]; // XYZ coordinates of the anchors + AnchorsSetup anchorsSetup; float printRadius; // Line buildup compensation float spoolBuildupFactor;