Move anticogging_t into config, use a fixed size array and scale

This commit is contained in:
Paul Guenette
2019-05-23 18:56:34 +02:00
parent 4ecaba769f
commit 301d68adc6
7 changed files with 37 additions and 48 deletions
-11
View File
@@ -288,17 +288,6 @@ bool Axis::run_idle_loop() {
// Infinite loop that does calibration and enters main control loop as appropriate
void Axis::run_state_machine_loop() {
// Allocate the map for anti-cogging algorithm and initialize all values to 0.0f
// TODO: Move this somewhere else
// TODO: respect changes of CPR
int encoder_cpr = encoder_.config_.cpr;
controller_.anticogging_.cogging_map = (float*)malloc(encoder_cpr * sizeof(float));
if (controller_.anticogging_.cogging_map != NULL) {
for (int i = 0; i < encoder_cpr; i++) {
controller_.anticogging_.cogging_map[i] = 0.0f;
}
}
// arm!
motor_.arm();