mirror of https://github.com/Desuuuu/klipper.git
polar: Implement bed angle wrapping adjustments in chelper code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
92993c062b
commit
374eb98765
|
@ -206,6 +206,8 @@ itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m)
|
|||
}
|
||||
queue_append_finish(qa);
|
||||
sk->commanded_pos = last.position;
|
||||
if (sk->post_cb)
|
||||
sk->post_cb(sk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,12 @@ struct coord move_get_coord(struct move *m, double move_time);
|
|||
struct stepper_kinematics;
|
||||
typedef double (*sk_calc_callback)(struct stepper_kinematics *sk, struct move *m
|
||||
, double move_time);
|
||||
typedef void (*sk_post_callback)(struct stepper_kinematics *sk);
|
||||
struct stepper_kinematics {
|
||||
double step_dist, commanded_pos;
|
||||
struct stepcompress *sc;
|
||||
sk_calc_callback calc_position_cb;
|
||||
sk_post_callback post_cb;
|
||||
};
|
||||
|
||||
int32_t itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m);
|
||||
|
|
|
@ -32,14 +32,26 @@ polar_stepper_angle_calc_position(struct stepper_kinematics *sk, struct move *m
|
|||
return angle;
|
||||
}
|
||||
|
||||
static void
|
||||
polar_stepper_angle_post_fixup(struct stepper_kinematics *sk)
|
||||
{
|
||||
// Normalize the stepper_bed angle
|
||||
if (sk->commanded_pos < -M_PI)
|
||||
sk->commanded_pos += 2 * M_PI;
|
||||
else if (sk->commanded_pos > M_PI)
|
||||
sk->commanded_pos -= 2 * M_PI;
|
||||
}
|
||||
|
||||
struct stepper_kinematics * __visible
|
||||
polar_stepper_alloc(char type)
|
||||
{
|
||||
struct stepper_kinematics *sk = malloc(sizeof(*sk));
|
||||
memset(sk, 0, sizeof(*sk));
|
||||
if (type == 'r')
|
||||
if (type == 'r') {
|
||||
sk->calc_position_cb = polar_stepper_radius_calc_position;
|
||||
else if (type == 'a')
|
||||
} else if (type == 'a') {
|
||||
sk->calc_position_cb = polar_stepper_angle_calc_position;
|
||||
sk->post_cb = polar_stepper_angle_post_fixup;
|
||||
}
|
||||
return sk;
|
||||
}
|
||||
|
|
|
@ -120,14 +120,7 @@ class PolarKinematics:
|
|||
cmove = move.cmove
|
||||
if axes_d[0] or axes_d[1]:
|
||||
self.rails[0].step_itersolve(cmove)
|
||||
stepper_bed = self.steppers[0]
|
||||
stepper_bed.step_itersolve(cmove)
|
||||
# Normalize the stepper_bed angle
|
||||
angle = stepper_bed.get_commanded_position()
|
||||
if angle < -math.pi:
|
||||
stepper_bed.set_commanded_position(angle + 2. * math.pi)
|
||||
elif angle > math.pi:
|
||||
stepper_bed.set_commanded_position(angle - 2. * math.pi)
|
||||
self.steppers[0].step_itersolve(cmove)
|
||||
if axes_d[2]:
|
||||
self.rails[1].step_itersolve(cmove)
|
||||
def get_status(self):
|
||||
|
|
Loading…
Reference in New Issue