Commit | Line | Data |
---|---|---|
bdaaa75d L |
1 | #include "HBotSolution.h" |
2 | #include <math.h> | |
3 | ||
4 | HBotSolution::HBotSolution(Config* passed_config) : config(passed_config){ | |
5 | this->alpha_steps_per_mm = this->config->value(alpha_steps_per_mm_checksum)->as_number(); | |
6 | this->beta_steps_per_mm = this->config->value( beta_steps_per_mm_checksum)->as_number(); | |
7 | this->gamma_steps_per_mm = this->config->value(gamma_steps_per_mm_checksum)->as_number(); | |
8 | } | |
9 | ||
10 | void HBotSolution::millimeters_to_steps( double millimeters[], int steps[] ){ | |
5a893291 JM |
11 | double delta_x = millimeters[X_AXIS] * this->alpha_steps_per_mm; |
12 | double delta_y = millimeters[Y_AXIS] * this->beta_steps_per_mm; | |
13 | steps[ALPHA_STEPPER] = lround(delta_x + delta_y); | |
14 | steps[BETA_STEPPER ] = lround(delta_x - delta_y); | |
bdaaa75d L |
15 | steps[GAMMA_STEPPER] = lround( millimeters[Z_AXIS] * this->gamma_steps_per_mm ); |
16 | } | |
17 | ||
18 | void HBotSolution::steps_to_millimeters( int steps[], double millimeters[] ){ | |
5a893291 JM |
19 | double delta_alpha = steps[X_AXIS] / this->alpha_steps_per_mm; |
20 | double delta_beta = steps[Y_AXIS] / this->beta_steps_per_mm; | |
bdaaa75d L |
21 | millimeters[ALPHA_STEPPER] = 0.5*(delta_alpha + delta_beta); |
22 | millimeters[BETA_STEPPER ] = 0.5*(delta_alpha - delta_beta); | |
23 | millimeters[GAMMA_STEPPER] = steps[Z_AXIS] / this->gamma_steps_per_mm; | |
24 | } | |
25 | ||
26 | void HBotSolution::set_steps_per_millimeter( double steps[] ) | |
27 | { | |
28 | this->alpha_steps_per_mm = steps[0]; | |
29 | this->beta_steps_per_mm = steps[1]; | |
30 | this->gamma_steps_per_mm = steps[2]; | |
31 | } | |
32 | ||
33 | void HBotSolution::get_steps_per_millimeter( double steps[] ) | |
34 | { | |
35 | steps[0] = this->alpha_steps_per_mm; | |
36 | steps[1] = this->beta_steps_per_mm; | |
37 | steps[2] = this->gamma_steps_per_mm; | |
38 | } |