2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-08 20:35:25 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-08 20:35:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-08 20:35:25 +00:00
|
|
|
*
|
|
|
|
*/
|
2019-07-05 03:44:12 +00:00
|
|
|
#pragma once
|
2017-09-08 20:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* delta.h - Delta-specific functions
|
|
|
|
*/
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
#include "../core/types.h"
|
2020-01-31 10:40:33 +00:00
|
|
|
#include "../core/macros.h"
|
2019-09-29 09:25:39 +00:00
|
|
|
|
|
|
|
extern float delta_height;
|
|
|
|
extern abc_float_t delta_endstop_adj;
|
|
|
|
extern float delta_radius,
|
2017-09-08 20:35:25 +00:00
|
|
|
delta_diagonal_rod,
|
2021-03-04 23:34:38 +00:00
|
|
|
segments_per_second;
|
2019-09-29 09:25:39 +00:00
|
|
|
extern abc_float_t delta_tower_angle_trim;
|
|
|
|
extern xy_float_t delta_tower[ABC];
|
|
|
|
extern abc_float_t delta_diagonal_rod_2_tower;
|
|
|
|
extern float delta_clip_start_height;
|
2020-06-28 04:53:44 +00:00
|
|
|
extern abc_float_t delta_diagonal_rod_trim;
|
2022-06-03 05:19:25 +00:00
|
|
|
#if HAS_DELTA_SENSORLESS_PROBING
|
|
|
|
extern abc_float_t offset_sensorless_adj;
|
|
|
|
extern float largest_sensorless_adj;
|
|
|
|
#endif
|
2017-09-08 20:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalculate factors used for delta kinematics whenever
|
|
|
|
* settings have been changed (e.g., by M665).
|
|
|
|
*/
|
2017-11-08 09:07:17 +00:00
|
|
|
void recalc_delta_settings();
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2022-06-03 05:19:25 +00:00
|
|
|
/**
|
|
|
|
* Get a safe radius for calibration
|
|
|
|
*/
|
|
|
|
#if HAS_DELTA_SENSORLESS_PROBING
|
|
|
|
static constexpr float sensorless_radius_factor = 0.7f;
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Delta Inverse Kinematics
|
|
|
|
*
|
2017-11-03 04:59:42 +00:00
|
|
|
* Calculate the tower positions for a given machine
|
2017-09-08 20:35:25 +00:00
|
|
|
* position, storing the result in the delta[] array.
|
|
|
|
*
|
|
|
|
* This is an expensive calculation, requiring 3 square
|
|
|
|
* roots per segmented linear move, and strains the limits
|
|
|
|
* of a Mega2560 with a Graphical Display.
|
|
|
|
*
|
|
|
|
* Suggested optimizations include:
|
|
|
|
*
|
|
|
|
* - Disable the home_offset (M206) and/or position_shift (G92)
|
|
|
|
* features to remove up to 12 float additions.
|
|
|
|
*
|
|
|
|
* - Use a fast-inverse-sqrt function and add the reciprocal.
|
|
|
|
* (see above)
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Macro to obtain the Z position of an individual tower
|
2019-09-29 09:25:39 +00:00
|
|
|
#define DELTA_Z(V,T) V.z + SQRT( \
|
2017-12-22 04:41:57 +00:00
|
|
|
delta_diagonal_rod_2_tower[T] - HYPOT2( \
|
2019-09-29 09:25:39 +00:00
|
|
|
delta_tower[T].x - V.x, \
|
|
|
|
delta_tower[T].y - V.y \
|
2017-12-22 04:41:57 +00:00
|
|
|
) \
|
2017-09-08 20:35:25 +00:00
|
|
|
)
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
#define DELTA_IK(V) delta.set(DELTA_Z(V, A_AXIS), DELTA_Z(V, B_AXIS), DELTA_Z(V, C_AXIS))
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
void inverse_kinematics(const xyz_pos_t &raw);
|
2017-09-08 20:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the highest Z position where the
|
|
|
|
* effector has the full range of XY motion.
|
|
|
|
*/
|
|
|
|
float delta_safe_distance_from_top();
|
|
|
|
|
2022-02-06 14:35:18 +00:00
|
|
|
void refresh_delta_clip_start_height();
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Delta Forward Kinematics
|
|
|
|
*
|
|
|
|
* See the Wikipedia article "Trilateration"
|
|
|
|
* https://en.wikipedia.org/wiki/Trilateration
|
|
|
|
*
|
|
|
|
* Establish a new coordinate system in the plane of the
|
|
|
|
* three carriage points. This system has its origin at
|
|
|
|
* tower1, with tower2 on the X axis. Tower3 is in the X-Y
|
|
|
|
* plane with a Z component of zero.
|
|
|
|
* We will define unit vectors in this coordinate system
|
|
|
|
* in our original coordinate system. Then when we calculate
|
|
|
|
* the Xnew, Ynew and Znew values, we can translate back into
|
|
|
|
* the original system by moving along those unit vectors
|
|
|
|
* by the corresponding values.
|
|
|
|
*
|
|
|
|
* Variable names matched to Marlin, c-version, and avoid the
|
|
|
|
* use of any vector library.
|
|
|
|
*
|
|
|
|
* by Andreas Hardtung 2016-06-07
|
|
|
|
* based on a Java function from "Delta Robot Kinematics V3"
|
|
|
|
* by Steve Graves
|
|
|
|
*
|
|
|
|
* The result is stored in the cartes[] array.
|
|
|
|
*/
|
2021-04-01 22:59:57 +00:00
|
|
|
void forward_kinematics(const_float_t z1, const_float_t z2, const_float_t z3);
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2021-03-03 23:57:24 +00:00
|
|
|
FORCE_INLINE void forward_kinematics(const abc_float_t &point) {
|
|
|
|
forward_kinematics(point.a, point.b, point.c);
|
2017-09-08 20:35:25 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 02:54:07 +00:00
|
|
|
void home_delta();
|