make axis allocation static

This commit is contained in:
Samuel Sadok
2020-07-21 13:02:03 +02:00
parent b3ddadb360
commit 938f088fc2
20 changed files with 184 additions and 206 deletions
+6 -6
View File
@@ -4,10 +4,10 @@
#include <algorithm>
Controller::Controller(Config_t& config) :
config_(config)
{
bool Controller::apply_config() {
config_.parent = this;
update_filter_gains();
return true;
}
void Controller::reset() {
@@ -32,7 +32,7 @@ void Controller::input_pos_updated() {
bool Controller::select_encoder(size_t encoder_num) {
if (encoder_num < AXIS_COUNT) {
Axis* ax = axes[encoder_num];
Axis* ax = &axes[encoder_num];
if (config_.setpoints_in_cpr) {
pos_estimate_src_ = &ax->encoder_.pos_cpr_;
pos_wrap_src_ = &ax->encoder_.config_.cpr;
@@ -181,8 +181,8 @@ bool Controller::update(float* torque_setpoint_output) {
} break;
case INPUT_MODE_MIRROR: {
if (config_.axis_to_mirror < AXIS_COUNT) {
pos_setpoint_ = axes[config_.axis_to_mirror]->encoder_.pos_estimate_ * config_.mirror_ratio;
vel_setpoint_ = axes[config_.axis_to_mirror]->encoder_.vel_estimate_ * config_.mirror_ratio;
pos_setpoint_ = axes[config_.axis_to_mirror].encoder_.pos_estimate_ * config_.mirror_ratio;
vel_setpoint_ = axes[config_.axis_to_mirror].encoder_.vel_estimate_ * config_.mirror_ratio;
} else {
set_error(ERROR_INVALID_MIRROR_AXIS);
return false;