mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-01-16 04:45:47 -07:00
Introduces buildup_factor and uses distances that are relative to the origin.
The buildup compensation is not applied yet, it's just prepared for.
This commit is contained in:
parent
c2935a9a04
commit
971a888fe1
3 changed files with 8 additions and 3 deletions
|
|
@ -154,7 +154,7 @@ defs_kin_winch = """
|
|||
struct winch_flex *winch_flex_alloc(void);
|
||||
void winch_flex_free(struct winch_flex *wf);
|
||||
void winch_flex_configure(struct winch_flex *wf, int num_anchors,
|
||||
const double *anchors, double mover_weight, double spring_constant,
|
||||
const double *anchors, double buildup_factor, double mover_weight, double spring_constant,
|
||||
const double *min_force,
|
||||
const double *max_force, const double *guy_wires,
|
||||
int flex_compensation_algorithm, int ignore_gravity, int ignore_pretension,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ struct winch_flex {
|
|||
int num_anchors;
|
||||
int enabled;
|
||||
int flex_compensation_algorithm;
|
||||
double buildup_factor;
|
||||
double mover_weight;
|
||||
double spring_constant;
|
||||
double min_force[WINCH_MAX_ANCHORS];
|
||||
|
|
@ -615,7 +616,7 @@ calc_position_common(struct winch_stepper *ws, struct move *m, double move_time)
|
|||
double distances[WINCH_MAX_ANCHORS];
|
||||
double flex[WINCH_MAX_ANCHORS];
|
||||
compute_flex(wf, pos.x, pos.y, pos.z, distances, flex);
|
||||
return dist + flex[ws->index];
|
||||
return dist - wf->distances_origin[ws->index] + flex[ws->index];
|
||||
}
|
||||
|
||||
static double
|
||||
|
|
@ -661,6 +662,7 @@ void __visible
|
|||
winch_flex_configure(struct winch_flex *wf,
|
||||
int num_anchors,
|
||||
const double *anchors,
|
||||
double buildup_factor,
|
||||
double mover_weight,
|
||||
double spring_constant,
|
||||
const double *min_force,
|
||||
|
|
@ -678,6 +680,7 @@ winch_flex_configure(struct winch_flex *wf,
|
|||
if (num_anchors > WINCH_MAX_ANCHORS)
|
||||
num_anchors = WINCH_MAX_ANCHORS;
|
||||
wf->num_anchors = num_anchors;
|
||||
wf->buildup_factor = buildup_factor;
|
||||
wf->mover_weight = mover_weight;
|
||||
wf->spring_constant = spring_constant;
|
||||
wf->flex_compensation_algorithm = flex_compensation_algorithm;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class WinchFlexHelper:
|
|||
self.set_active(self.enabled)
|
||||
|
||||
def _read_config(self, config):
|
||||
self.buildup_factor = config.getfloat('winch_buildup_factor', 0., minval=0.)
|
||||
self.mover_weight = config.getfloat('winch_mover_weight', 0., minval=0.)
|
||||
self.spring_constant = config.getfloat('winch_spring_constant', 0., minval=0.)
|
||||
if self.num:
|
||||
|
|
@ -50,6 +51,7 @@ class WinchFlexHelper:
|
|||
self.min_force = []
|
||||
self.max_force = []
|
||||
self.guy_wires = []
|
||||
self.mechanical_advantage = []
|
||||
algo_choices = list(self.ALGORITHMS.keys())
|
||||
self.flex_compensation_algorithm_name = config.getchoice(
|
||||
'flex_compensation_algorithm', algo_choices, default='qp')
|
||||
|
|
@ -64,7 +66,7 @@ class WinchFlexHelper:
|
|||
max_c = self.ffi_main.new("double[]", self.max_force)
|
||||
guy_ptr = self.ffi_main.new("double[]", self.guy_wires)
|
||||
self.ffi_lib.winch_flex_configure(
|
||||
self.ptr, self.num, anchors_c, self.mover_weight,
|
||||
self.ptr, self.num, anchors_c, self.buildup_factor, self.mover_weight,
|
||||
self.spring_constant, min_c, max_c,
|
||||
guy_ptr, self.flex_compensation_algorithm,
|
||||
self.ignore_gravity, self.ignore_pretension, self.mechanical_advantage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue