itersolve: Support calculating a stepper position from a cartesian coordinate
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
e2b4b1616f
commit
cb29143939
|
@ -1,6 +1,6 @@
|
|||
# Wrapper around C helper code
|
||||
#
|
||||
# Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
|
||||
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import os, logging
|
||||
|
@ -51,7 +51,7 @@ defs_itersolve = """
|
|||
int32_t itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m);
|
||||
void itersolve_set_stepcompress(struct stepper_kinematics *sk
|
||||
, struct stepcompress *sc, double step_dist);
|
||||
void itersolve_set_position(struct stepper_kinematics *sk
|
||||
double itersolve_calc_position_from_coord(struct stepper_kinematics *sk
|
||||
, double x, double y, double z);
|
||||
void itersolve_set_commanded_pos(struct stepper_kinematics *sk, double pos);
|
||||
double itersolve_get_commanded_pos(struct stepper_kinematics *sk);
|
||||
|
|
|
@ -215,14 +215,14 @@ itersolve_set_stepcompress(struct stepper_kinematics *sk
|
|||
sk->step_dist = step_dist;
|
||||
}
|
||||
|
||||
void __visible
|
||||
itersolve_set_position(struct stepper_kinematics *sk
|
||||
, double x, double y, double z)
|
||||
double __visible
|
||||
itersolve_calc_position_from_coord(struct stepper_kinematics *sk
|
||||
, double x, double y, double z)
|
||||
{
|
||||
struct move m;
|
||||
memset(&m, 0, sizeof(m));
|
||||
move_fill(&m, 0., 0., 1., 0., x, y, z, 0., 1., 0., 0., 1., 0.);
|
||||
sk->commanded_pos = sk->calc_position(sk, &m, 0.);
|
||||
return sk->calc_position(sk, &m, 0.);
|
||||
}
|
||||
|
||||
void __visible
|
||||
|
|
|
@ -41,8 +41,8 @@ struct stepper_kinematics {
|
|||
int32_t itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m);
|
||||
void itersolve_set_stepcompress(struct stepper_kinematics *sk
|
||||
, struct stepcompress *sc, double step_dist);
|
||||
void itersolve_set_position(struct stepper_kinematics *sk
|
||||
, double x, double y, double z);
|
||||
double itersolve_calc_position_from_coord(struct stepper_kinematics *sk
|
||||
, double x, double y, double z);
|
||||
void itersolve_set_commanded_pos(struct stepper_kinematics *sk, double pos);
|
||||
double itersolve_get_commanded_pos(struct stepper_kinematics *sk);
|
||||
|
||||
|
|
|
@ -69,11 +69,13 @@ class MCU_stepper:
|
|||
return self._oid
|
||||
def get_step_dist(self):
|
||||
return self._step_dist
|
||||
def calc_position_from_coord(self, coord):
|
||||
return self._ffi_lib.itersolve_calc_position_from_coord(
|
||||
self._stepper_kinematics, coord[0], coord[1], coord[2])
|
||||
def set_position(self, newpos):
|
||||
orig_cmd_pos = self.get_commanded_position()
|
||||
self._ffi_lib.itersolve_set_position(
|
||||
self._stepper_kinematics, newpos[0], newpos[1], newpos[2])
|
||||
self._mcu_position_offset += orig_cmd_pos - self.get_commanded_position()
|
||||
spos = self.calc_position_from_coord(newpos)
|
||||
self._mcu_position_offset += self.get_commanded_position() - spos
|
||||
self._ffi_lib.itersolve_set_commanded_pos(self._stepper_kinematics, spos)
|
||||
def get_commanded_position(self):
|
||||
return self._ffi_lib.itersolve_get_commanded_pos(
|
||||
self._stepper_kinematics)
|
||||
|
|
|
@ -64,6 +64,7 @@ class PrinterStepper:
|
|||
self.setup_itersolve = self.mcu_stepper.setup_itersolve
|
||||
self.set_stepper_kinematics = self.mcu_stepper.set_stepper_kinematics
|
||||
self.set_ignore_move = self.mcu_stepper.set_ignore_move
|
||||
self.calc_position_from_coord = self.mcu_stepper.calc_position_from_coord
|
||||
self.set_position = self.mcu_stepper.set_position
|
||||
self.get_mcu_position = self.mcu_stepper.get_mcu_position
|
||||
self.get_commanded_position = self.mcu_stepper.get_commanded_position
|
||||
|
|
Loading…
Reference in New Issue