diff --git a/Firmware/MotorControl/async_estimator.cpp b/Firmware/MotorControl/acim_estimator.cpp similarity index 86% rename from Firmware/MotorControl/async_estimator.cpp rename to Firmware/MotorControl/acim_estimator.cpp index e2edefa4..55cc1be8 100644 --- a/Firmware/MotorControl/async_estimator.cpp +++ b/Firmware/MotorControl/acim_estimator.cpp @@ -1,11 +1,11 @@ -#include "async_estimator.hpp" +#include "acim_estimator.hpp" #include -void AsyncEstimator::update(uint32_t timestamp) { - std::optional rotor_phase = rotor_phase_src_.get_current(); - std::optional rotor_phase_vel = rotor_phase_vel_src_.get_current(); - std::optional idq = idq_src_.get_current(); +void AcimEstimator::update(uint32_t timestamp) { + std::optional rotor_phase = rotor_phase_src_.present(); + std::optional rotor_phase_vel = rotor_phase_vel_src_.present(); + std::optional idq = idq_src_.present(); if (!rotor_phase.has_value() || !rotor_phase_vel.has_value() || !idq.has_value()) { active_ = false; diff --git a/Firmware/MotorControl/async_estimator.hpp b/Firmware/MotorControl/acim_estimator.hpp similarity index 85% rename from Firmware/MotorControl/async_estimator.hpp rename to Firmware/MotorControl/acim_estimator.hpp index 3505ce53..242b5d86 100644 --- a/Firmware/MotorControl/async_estimator.hpp +++ b/Firmware/MotorControl/acim_estimator.hpp @@ -1,11 +1,11 @@ -#ifndef __ASYNC_ESTIMATOR_HPP -#define __ASYNC_ESTIMATOR_HPP +#ifndef __ACIM_ESTIMATOR_HPP +#define __ACIM_ESTIMATOR_HPP #include #include #include -class AsyncEstimator : public ComponentBase { +class AcimEstimator : public ComponentBase { public: struct Config_t { float slip_velocity = 14.706f; // [rad/s electrical] = 1/rotor_tau @@ -33,4 +33,4 @@ public: OutputPort stator_phase_ = 0.0f; // [rad] rotor flux phase angle estimate }; -#endif // __ASYNC_ESTIMATOR_HPP \ No newline at end of file +#endif // __ACIM_ESTIMATOR_HPP \ No newline at end of file diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index 2a1d5e57..6c8e6663 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -204,11 +204,11 @@ bool Axis::run_lockin_spin(const LockinConfig_t &lockin_config, bool remain_arme motor_.current_control_.Vdq_setpoint_src_.connect_to(&open_loop_controller_.Vdq_setpoint_); motor_.current_control_.phase_src_.connect_to(&open_loop_controller_.phase_); - async_estimator_.rotor_phase_src_.connect_to(&open_loop_controller_.phase_); + acim_estimator_.rotor_phase_src_.connect_to(&open_loop_controller_.phase_); motor_.phase_vel_src_.connect_to(&open_loop_controller_.phase_vel_); motor_.current_control_.phase_vel_src_.connect_to(&open_loop_controller_.phase_vel_); - async_estimator_.rotor_phase_vel_src_.connect_to(&open_loop_controller_.phase_vel_); + acim_estimator_.rotor_phase_vel_src_.connect_to(&open_loop_controller_.phase_vel_); } wait_for_control_iteration(); @@ -219,8 +219,8 @@ bool Axis::run_lockin_spin(const LockinConfig_t &lockin_config, bool remain_arme float dir = lockin_config.vel >= 0.0f ? 1.0f : -1.0f; while ((requested_state_ == AXIS_STATE_UNDEFINED) && motor_.is_armed_) { - bool reached_target_vel = std::abs(open_loop_controller_.phase_vel_.get_any().value_or(0.0f) - lockin_config.vel) <= std::numeric_limits::epsilon(); - bool reached_target_dist = open_loop_controller_.total_distance_.get_any().value_or(0.0f) * dir >= lockin_config.finish_distance * dir; + bool reached_target_vel = std::abs(open_loop_controller_.phase_vel_.any().value_or(0.0f) - lockin_config.vel) <= std::numeric_limits::epsilon(); + bool reached_target_dist = open_loop_controller_.total_distance_.any().value_or(0.0f) * dir >= lockin_config.finish_distance * dir; // Check if terminal condition is reached bool terminal_condition = (reached_target_vel && lockin_config.finish_on_vel) @@ -286,7 +286,7 @@ bool Axis::start_closed_loop_control() { if (controller_.config_.control_mode >= Controller::CONTROL_MODE_POSITION_CONTROL) { std::optional pos_init = (controller_.config_.circular_setpoints ? controller_.pos_estimate_circular_src_ : - controller_.pos_estimate_linear_src_).get_any(); + controller_.pos_estimate_linear_src_).any(); if (!pos_init.has_value()) { return false; } else { @@ -308,12 +308,12 @@ bool Axis::start_closed_loop_control() { OutputPort* phase_src = sensorless_mode ? &sensorless_estimator_.phase_ : &encoder_.phase_; motor_.current_control_.phase_src_.connect_to(phase_src); - async_estimator_.rotor_phase_src_.connect_to(phase_src); + acim_estimator_.rotor_phase_src_.connect_to(phase_src); OutputPort* phase_vel_src = sensorless_mode ? &sensorless_estimator_.phase_vel_ : &encoder_.phase_vel_; motor_.phase_vel_src_.connect_to(phase_vel_src); motor_.current_control_.phase_vel_src_.connect_to(phase_vel_src); - async_estimator_.rotor_phase_vel_src_.connect_to(phase_vel_src); + acim_estimator_.rotor_phase_vel_src_.connect_to(phase_vel_src); if (sensorless_mode) { // Make the final velocity of the loĉk-in spin the setpoint of the diff --git a/Firmware/MotorControl/axis.hpp b/Firmware/MotorControl/axis.hpp index 50d506d3..c79c91dd 100644 --- a/Firmware/MotorControl/axis.hpp +++ b/Firmware/MotorControl/axis.hpp @@ -4,7 +4,7 @@ class Axis; #include "encoder.hpp" -#include "async_estimator.hpp" +#include "acim_estimator.hpp" #include "sensorless_estimator.hpp" #include "controller.hpp" #include "open_loop_controller.hpp" @@ -39,7 +39,7 @@ public: TaskTimer can_heartbeat; TaskTimer controller_update; TaskTimer open_loop_controller_update; - TaskTimer async_estimator_update; + TaskTimer acim_estimator_update; TaskTimer motor_update; TaskTimer current_controller_update; TaskTimer dc_calib; @@ -161,7 +161,7 @@ public: Config_t config_; Encoder& encoder_; - AsyncEstimator async_estimator_; + AcimEstimator acim_estimator_; SensorlessEstimator& sensorless_estimator_; Controller& controller_; OpenLoopController open_loop_controller_; diff --git a/Firmware/MotorControl/component.hpp b/Firmware/MotorControl/component.hpp index aa156e1c..4569de99 100644 --- a/Firmware/MotorControl/component.hpp +++ b/Firmware/MotorControl/component.hpp @@ -40,8 +40,8 @@ public: /** * @brief Initializes the output port with the specified value. * - * An initialization value is required for get_any() to work properly. - * get_current() and get_previous() cannot be used to fetch the + * An initialization value is required for any() to work properly. + * present() and previous() cannot be used to fetch the * initialization value. */ OutputPort(T val) : content_(val) {} @@ -60,7 +60,7 @@ public: * of this class. */ void reset() { - // This will eventually overflow to 0 so get_current() could + // This will eventually overflow to 0 so present() could // theoretically return a very old value however it is very likely that // the motor will be long disarmed by then. age_++; @@ -70,7 +70,7 @@ public: * @brief Returns the value from this control loop iteration or std::nullopt * if the value was not yet set during this control loop iteration. */ - std::optional get_current() { + std::optional present() { if (age_ == 0) { return content_; } else { @@ -85,7 +85,7 @@ public: * overwritten during this control loop iteration then this function returns * std::nullopt. */ - std::optional get_previous() { + std::optional previous() { if (age_ == 1) { return content_; } else { @@ -99,7 +99,7 @@ public: * * This function is thread-safe if load/store operations of T are atomic. */ - std::optional get_any() { + std::optional any() { return content_; } @@ -134,10 +134,10 @@ public: content_ = (OutputPort*)nullptr; } - std::optional get_current() { + std::optional present() { if (content_.index() == 2) { OutputPort* ptr = std::get<2>(content_); - return ptr ? ptr->get_current() : std::nullopt; + return ptr ? ptr->present() : std::nullopt; } else if (content_.index() == 1) { T* ptr = std::get<1>(content_); return ptr ? std::make_optional(*ptr) : std::nullopt; @@ -150,10 +150,10 @@ public: // ok for this input port to fetch the value from the last iteration. // This would provide a general way to resolve same-iteration data path cycles. - //std::optional get_previous() { + //std::optional previous() { // if (content_.index() == 2) { // OutputPort* ptr = std::get<2>(content_); - // return ptr ? ptr->get_previous() : std::nullopt; + // return ptr ? ptr->previous() : std::nullopt; // } else if (content_.index() == 1) { // T* ptr = std::get<1>(content_); // return ptr ? std::make_optional(*ptr) : std::nullopt; @@ -162,10 +162,10 @@ public: // } //} - std::optional get_any() { + std::optional any() { if (content_.index() == 2) { OutputPort* ptr = std::get<2>(content_); - return ptr ? ptr->get_any() : std::nullopt; + return ptr ? ptr->any() : std::nullopt; } else if (content_.index() == 1) { T* ptr = std::get<1>(content_); return ptr ? std::make_optional(*ptr) : std::nullopt; diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index 51c64983..9c4e97ca 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -97,13 +97,13 @@ static float limitVel(const float vel_limit, const float vel_estimate, const flo } bool Controller::update() { - std::optional pos_estimate_linear = pos_estimate_linear_src_.get_current(); - std::optional pos_estimate_circular = pos_estimate_circular_src_.get_current(); - std::optional pos_wrap = pos_wrap_src_.get_current(); - std::optional vel_estimate = vel_estimate_src_.get_current(); + std::optional pos_estimate_linear = pos_estimate_linear_src_.present(); + std::optional pos_estimate_circular = pos_estimate_circular_src_.present(); + std::optional pos_wrap = pos_wrap_src_.present(); + std::optional vel_estimate = vel_estimate_src_.present(); - std::optional anticogging_pos_estimate = axis_->encoder_.pos_estimate_.get_current(); - std::optional anticogging_vel_estimate = axis_->encoder_.vel_estimate_.get_current(); + std::optional anticogging_pos_estimate = axis_->encoder_.pos_estimate_.present(); + std::optional anticogging_vel_estimate = axis_->encoder_.vel_estimate_.present(); if (config_.anticogging.calib_anticogging) { if (!anticogging_pos_estimate.has_value() || !anticogging_vel_estimate.has_value()) { @@ -156,8 +156,8 @@ bool Controller::update() { } break; case INPUT_MODE_MIRROR: { if (config_.axis_to_mirror < AXIS_COUNT) { - std::optional other_pos = axes[config_.axis_to_mirror].encoder_.pos_estimate_.get_current(); - std::optional other_vel = axes[config_.axis_to_mirror].encoder_.vel_estimate_.get_current(); + std::optional other_pos = axes[config_.axis_to_mirror].encoder_.pos_estimate_.present(); + std::optional other_vel = axes[config_.axis_to_mirror].encoder_.vel_estimate_.present(); if (!other_pos.has_value() || !other_vel.has_value()) { set_error(ERROR_INVALID_ESTIMATE); @@ -262,7 +262,7 @@ bool Controller::update() { float vel_gain = config_.vel_gain; float vel_integrator_gain = config_.vel_integrator_gain; if (axis_->motor_.config_.motor_type == Motor::MOTOR_TYPE_ACIM) { - float effective_flux = axis_->async_estimator_.rotor_flux_; + float effective_flux = axis_->acim_estimator_.rotor_flux_; float minflux = axis_->motor_.config_.acim_gain_min_flux; if (std::abs(effective_flux) < minflux) effective_flux = std::copysignf(minflux, effective_flux); diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 7132100e..358dca72 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -235,11 +235,11 @@ bool Encoder::run_offset_calibration() { axis_->motor_.current_control_.Vdq_setpoint_src_.connect_to(&axis_->open_loop_controller_.Vdq_setpoint_); axis_->motor_.current_control_.phase_src_.connect_to(&axis_->open_loop_controller_.phase_); - axis_->async_estimator_.rotor_phase_src_.connect_to(&axis_->open_loop_controller_.phase_); + axis_->acim_estimator_.rotor_phase_src_.connect_to(&axis_->open_loop_controller_.phase_); axis_->motor_.phase_vel_src_.connect_to(&axis_->open_loop_controller_.phase_vel_); axis_->motor_.current_control_.phase_vel_src_.connect_to(&axis_->open_loop_controller_.phase_vel_); - axis_->async_estimator_.rotor_phase_vel_src_.connect_to(&axis_->open_loop_controller_.phase_vel_); + axis_->acim_estimator_.rotor_phase_vel_src_.connect_to(&axis_->open_loop_controller_.phase_vel_); } axis_->wait_for_control_iteration(); @@ -269,7 +269,7 @@ bool Encoder::run_offset_calibration() { // scan forward while ((axis_->requested_state_ == Axis::AXIS_STATE_UNDEFINED) && axis_->motor_.is_armed_) { - bool reached_target_dist = axis_->open_loop_controller_.total_distance_.get_any().value_or(-INFINITY) >= config_.calib_scan_distance; + bool reached_target_dist = axis_->open_loop_controller_.total_distance_.any().value_or(-INFINITY) >= config_.calib_scan_distance; if (reached_target_dist) { break; } @@ -308,7 +308,7 @@ bool Encoder::run_offset_calibration() { // scan backwards while ((axis_->requested_state_ == Axis::AXIS_STATE_UNDEFINED) && axis_->motor_.is_armed_) { - bool reached_target_dist = axis_->open_loop_controller_.total_distance_.get_any().value_or(INFINITY) <= 0.0f; + bool reached_target_dist = axis_->open_loop_controller_.total_distance_.any().value_or(INFINITY) <= 0.0f; if (reached_target_dist) { break; } @@ -590,7 +590,7 @@ bool Encoder::update() { // TODO: we should strictly require that this value is from the previous iteration // to avoid spinout scenarios. However that requires a proper way to reset // the encoder from error states. - float pos_circular = pos_circular_.get_any().value_or(0.0f); + float pos_circular = pos_circular_.any().value_or(0.0f); pos_circular += wrap_pm((pos_cpr_counts_ - pos_cpr_counts_last) / (float)config_.cpr, 1.0f); pos_circular = fmodf_pos(pos_circular, axis_->controller_.config_.circular_setpoint_range); pos_circular_ = pos_circular; @@ -622,7 +622,7 @@ bool Encoder::update() { if (is_ready_) { phase_ = wrap_pm_pi(ph) * config_.direction; - phase_vel_ = (2*M_PI) * *vel_estimate_.get_current() * axis_->motor_.config_.pole_pairs * config_.direction; + phase_vel_ = (2*M_PI) * *vel_estimate_.present() * axis_->motor_.config_.pole_pairs * config_.direction; } return true; diff --git a/Firmware/MotorControl/foc.cpp b/Firmware/MotorControl/foc.cpp index ae4a05af..219f4076 100644 --- a/Firmware/MotorControl/foc.cpp +++ b/Firmware/MotorControl/foc.cpp @@ -183,9 +183,9 @@ void FieldOrientedController::update(uint32_t timestamp) { CRITICAL_SECTION() { ctrl_timestamp_ = timestamp; enable_current_control_ = enable_current_control_src_; - Idq_setpoint_ = Idq_setpoint_src_.get_current(); - Vdq_setpoint_ = Vdq_setpoint_src_.get_current(); - phase_ = phase_src_.get_current(); - phase_vel_ = phase_vel_src_.get_current(); + Idq_setpoint_ = Idq_setpoint_src_.present(); + Vdq_setpoint_ = Vdq_setpoint_src_.present(); + phase_ = phase_src_.present(); + phase_vel_ = phase_vel_src_.present(); } } diff --git a/Firmware/MotorControl/main.cpp b/Firmware/MotorControl/main.cpp index 67e2c46d..834ce743 100644 --- a/Firmware/MotorControl/main.cpp +++ b/Firmware/MotorControl/main.cpp @@ -306,9 +306,9 @@ void ODrive::control_loop_cb(uint32_t timestamp) { // TODO: maybe we should add a check to output ports that prevents // double-setting the value. for (auto& axis: axes) { - axis.async_estimator_.slip_vel_.reset(); - axis.async_estimator_.stator_phase_vel_.reset(); - axis.async_estimator_.stator_phase_.reset(); + axis.acim_estimator_.slip_vel_.reset(); + axis.acim_estimator_.stator_phase_vel_.reset(); + axis.acim_estimator_.stator_phase_.reset(); axis.controller_.torque_output_.reset(); axis.encoder_.phase_.reset(); axis.encoder_.phase_vel_.reset(); @@ -381,7 +381,7 @@ void ODrive::control_loop_cb(uint32_t timestamp) { axis.motor_.update(timestamp); // uses torque from controller and phase_vel from encoder MEASURE_TIME(axis.task_times_.current_controller_update) - axis.motor_.current_control_.update(timestamp); // uses the output of controller_ or open_loop_contoller_ and encoder_ or sensorless_estimator_ or async_estimator_ + axis.motor_.current_control_.update(timestamp); // uses the output of controller_ or open_loop_contoller_ and encoder_ or sensorless_estimator_ or acim_estimator_ } // Tell the axis threads that the control loop has finished @@ -480,7 +480,7 @@ static void rtos_main(void*) { } for(auto& axis: axes){ - axis.async_estimator_.idq_src_.connect_to(&axis.motor_.Idq_setpoint_); + axis.acim_estimator_.idq_src_.connect_to(&axis.motor_.Idq_setpoint_); } // Start PWM and enable adc interrupts/callbacks diff --git a/Firmware/MotorControl/motor.cpp b/Firmware/MotorControl/motor.cpp index ca9753c3..6585cccc 100644 --- a/Firmware/MotorControl/motor.cpp +++ b/Firmware/MotorControl/motor.cpp @@ -193,7 +193,7 @@ bool Motor::arm(PhaseControlLaw<3>* control_law) { // Reset controller states, integrators, setpoints, etc. axis_->controller_.reset(); - axis_->async_estimator_.rotor_flux_ = 0.0f; + axis_->acim_estimator_.rotor_flux_ = 0.0f; if (control_law_) { control_law_->reset(); } @@ -373,7 +373,7 @@ float Motor::effective_current_lim() { //Note - for ACIM motors, available torque is allowed to be 0. float Motor::max_available_torque() { if (config_.motor_type == Motor::MOTOR_TYPE_ACIM) { - float max_torque = effective_current_lim_ * config_.torque_constant * axis_->async_estimator_.rotor_flux_; + float max_torque = effective_current_lim_ * config_.torque_constant * axis_->acim_estimator_.rotor_flux_; max_torque = std::clamp(max_torque, 0.0f, config_.torque_lim); return max_torque; } else { @@ -494,19 +494,19 @@ bool Motor::run_calibration() { } void Motor::update(uint32_t timestamp) { - std::optional torque = torque_setpoint_src_.get_current(); + std::optional torque = torque_setpoint_src_.present(); if (!torque.has_value()) { error_ |= ERROR_UNKNOWN_TORQUE; return; } - auto [id, iq] = Idq_setpoint_.get_previous() + auto [id, iq] = Idq_setpoint_.previous() .value_or(float2D{0.0f, 0.0f}); // Id doubles as a state variable // Convert torque to current if (axis_->motor_.config_.motor_type == Motor::MOTOR_TYPE_ACIM) { - iq = *torque / (axis_->motor_.config_.torque_constant * std::max(axis_->async_estimator_.rotor_flux_, config_.acim_gain_min_flux)); + iq = *torque / (axis_->motor_.config_.torque_constant * std::max(axis_->acim_estimator_.rotor_flux_, config_.acim_gain_min_flux)); } else { iq = *torque / axis_->motor_.config_.torque_constant; } @@ -534,13 +534,13 @@ void Motor::update(uint32_t timestamp) { // in this function. // A cleaner fix would be to take the feedforward calculation out of here // and turn it into a separate component. - MEASURE_TIME(axis_->task_times_.async_estimator_update) - axis_->async_estimator_.update(timestamp); + MEASURE_TIME(axis_->task_times_.acim_estimator_update) + axis_->acim_estimator_.update(timestamp); float vd = 0.0f; float vq = 0.0f; - std::optional phase_vel = phase_vel_src_.get_current(); + std::optional phase_vel = phase_vel_src_.present(); if (config_.R_wL_FF_enable) { if (!phase_vel.has_value()) { diff --git a/Firmware/MotorControl/open_loop_controller.cpp b/Firmware/MotorControl/open_loop_controller.cpp index 16d2d5db..7d21df98 100644 --- a/Firmware/MotorControl/open_loop_controller.cpp +++ b/Firmware/MotorControl/open_loop_controller.cpp @@ -3,10 +3,10 @@ #include void OpenLoopController::update(uint32_t timestamp) { - auto [prev_Id, prev_Iq] = Idq_setpoint_.get_previous().value_or(float2D{0.0f, 0.0f}); - auto [prev_Vd, prev_Vq] = Vdq_setpoint_.get_previous().value_or(float2D{0.0f, 0.0f}); - float phase = phase_.get_previous().value_or(initial_phase_); - float phase_vel = phase_vel_.get_previous().value_or(0.0f); + auto [prev_Id, prev_Iq] = Idq_setpoint_.previous().value_or(float2D{0.0f, 0.0f}); + auto [prev_Vd, prev_Vq] = Vdq_setpoint_.previous().value_or(float2D{0.0f, 0.0f}); + float phase = phase_.previous().value_or(initial_phase_); + float phase_vel = phase_vel_.previous().value_or(0.0f); (void)prev_Iq; // unused (void)prev_Vq; // unused @@ -25,6 +25,6 @@ void OpenLoopController::update(uint32_t timestamp) { phase_vel = std::clamp(target_vel_, phase_vel - max_phase_vel_ramp_ * dt, phase_vel + max_phase_vel_ramp_ * dt); phase_vel_ = phase_vel; phase_ = wrap_pm_pi(phase + phase_vel * dt); - total_distance_ = total_distance_.get_previous().value_or(0.0f) + phase_vel * dt; + total_distance_ = total_distance_.previous().value_or(0.0f) + phase_vel * dt; timestamp_ = timestamp; } diff --git a/Firmware/MotorControl/sensorless_estimator.cpp b/Firmware/MotorControl/sensorless_estimator.cpp index c3951056..84f12f55 100644 --- a/Firmware/MotorControl/sensorless_estimator.cpp +++ b/Firmware/MotorControl/sensorless_estimator.cpp @@ -81,7 +81,7 @@ bool SensorlessEstimator::update() { V_alpha_beta_memory_[0] = axis_->motor_.current_control_.final_v_alpha_; V_alpha_beta_memory_[1] = axis_->motor_.current_control_.final_v_beta_; - float phase_vel = phase_vel_.get_previous().value_or(0.0f); + float phase_vel = phase_vel_.previous().value_or(0.0f); // predict PLL phase with velocity pll_pos_ = wrap_pm_pi(pll_pos_ + current_meas_period * phase_vel); diff --git a/Firmware/Tupfile.lua b/Firmware/Tupfile.lua index 611e174c..90eecd2c 100644 --- a/Firmware/Tupfile.lua +++ b/Firmware/Tupfile.lua @@ -200,7 +200,7 @@ sources = { 'MotorControl/thermistor.cpp', 'MotorControl/encoder.cpp', 'MotorControl/endstop.cpp', - 'MotorControl/async_estimator.cpp', + 'MotorControl/acim_estimator.cpp', 'MotorControl/mechanical_brake.cpp', 'MotorControl/controller.cpp', 'MotorControl/foc.cpp', diff --git a/Firmware/communication/ascii_protocol.cpp b/Firmware/communication/ascii_protocol.cpp index 6e62e8a6..578c3f7b 100644 --- a/Firmware/communication/ascii_protocol.cpp +++ b/Firmware/communication/ascii_protocol.cpp @@ -284,8 +284,8 @@ void cmd_get_feedback(char * pStr, StreamSink& response_channel, bool use_checks } else { Axis& axis = axes[motor_number]; respond(response_channel, use_checksum, "%f %f", - (double)axis.encoder_.pos_estimate_.get_any().value_or(0.0f), - (double)axis.encoder_.vel_estimate_.get_any().value_or(0.0f)); + (double)axis.encoder_.pos_estimate_.any().value_or(0.0f), + (double)axis.encoder_.vel_estimate_.any().value_or(0.0f)); } } diff --git a/Firmware/communication/can_simple.cpp b/Firmware/communication/can_simple.cpp index 650dd6e1..af897495 100644 --- a/Firmware/communication/can_simple.cpp +++ b/Firmware/communication/can_simple.cpp @@ -173,8 +173,8 @@ int32_t CANSimple::get_encoder_estimates_callback(const Axis& axis) { txmsg.isExt = axis.config_.can.is_extended; txmsg.len = 8; - can_setSignal(txmsg, axis.encoder_.pos_estimate_.get_any().value_or(0.0f), 0, 32, true); - can_setSignal(txmsg, axis.encoder_.vel_estimate_.get_any().value_or(0.0f), 32, 32, true); + can_setSignal(txmsg, axis.encoder_.pos_estimate_.any().value_or(0.0f), 0, 32, true); + can_setSignal(txmsg, axis.encoder_.vel_estimate_.any().value_or(0.0f), 32, 32, true); return odCAN->write(txmsg); } @@ -189,7 +189,7 @@ int32_t CANSimple::get_sensorless_estimates_callback(const Axis& axis) { static_assert(sizeof(float) == sizeof(axis.sensorless_estimator_.pll_pos_)); can_setSignal(txmsg, axis.sensorless_estimator_.pll_pos_, 0, 32, true); - can_setSignal(txmsg, axis.sensorless_estimator_.vel_estimate_.get_any().value_or(0.0f), 32, 32, true); + can_setSignal(txmsg, axis.sensorless_estimator_.vel_estimate_.any().value_or(0.0f), 32, 32, true); return odCAN->write(txmsg); } diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index fee4f9eb..83f294b4 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -506,7 +506,7 @@ interfaces: motor: Motor controller: Controller encoder: Encoder - async_estimator: AsyncEstimator + acim_estimator: AcimEstimator sensorless_estimator: SensorlessEstimator trap_traj: TrapezoidalTrajectory min_endstop: Endstop @@ -522,7 +522,7 @@ interfaces: can_heartbeat: TaskTimer controller_update: TaskTimer open_loop_controller_update: TaskTimer - async_estimator_update: TaskTimer + acim_estimator_update: TaskTimer motor_update: TaskTimer current_controller_update: TaskTimer dc_calib: TaskTimer @@ -811,7 +811,7 @@ interfaces: functions: get_val: {in: {index: uint32}, out: {val: float32}} - ODrive.AsyncEstimator: + ODrive.AcimEstimator: c_is_class: True attributes: rotor_flux: {type: readonly float32, unit: A, doc: estimated magnitude of the rotor flux} @@ -819,7 +819,7 @@ interfaces: type: readonly float32 unit: rad/s doc: estimated slip between physical and electrical angular velocity} - c_getter: slip_vel_.get_any().value_or(0.0f) + c_getter: slip_vel_.any().value_or(0.0f) phase_offset: type: readonly float32 unit: rad @@ -828,12 +828,12 @@ interfaces: type: readonly float32 unit: rad/s doc: calculated setpoint for the electrical velocity} - c_getter: stator_phase_vel_.get_any().value_or(0.0f) + c_getter: stator_phase_vel_.any().value_or(0.0f) stator_phase: type: readonly float32 unit: rad doc: calculated setpoint for the electrical phase} - c_getter: stator_phase_.get_any().value_or(0.0f) + c_getter: stator_phase_.any().value_or(0.0f) config: c_is_class: False attributes: @@ -992,13 +992,13 @@ interfaces: shadow_count: readonly int32 count_in_cpr: readonly int32 interpolation: readonly float32 - phase: {type: readonly float32, c_getter: phase_.get_any().value_or(0.0f)} - pos_estimate: {type: readonly float32, c_getter: pos_estimate_.get_any().value_or(0.0f)} + phase: {type: readonly float32, c_getter: phase_.any().value_or(0.0f)} + pos_estimate: {type: readonly float32, c_getter: pos_estimate_.any().value_or(0.0f)} pos_estimate_counts: readonly float32 pos_cpr_counts: readonly float32 - pos_circular: {type: readonly float32, c_getter: pos_circular_.get_any().value_or(0.0f)} + pos_circular: {type: readonly float32, c_getter: pos_circular_.any().value_or(0.0f)} hall_state: readonly uint8 - vel_estimate: {type: readonly float32, c_getter: vel_estimate_.get_any().value_or(0.0f)} + vel_estimate: {type: readonly float32, c_getter: vel_estimate_.any().value_or(0.0f)} vel_estimate_counts: readonly float32 calib_scan_response: readonly float32 pos_abs: int32 @@ -1040,10 +1040,10 @@ interfaces: flags: UnstableGain: UnknownCurrentMeasurement: - phase: {type: readonly float32, unit: rad, c_getter: phase_.get_any().value_or(0.0f)} + phase: {type: readonly float32, unit: rad, c_getter: phase_.any().value_or(0.0f)} pll_pos: {type: readonly float32, unit: rad} - phase_vel: {type: readonly float32, unit: rad/s, c_getter: phase_vel_.get_any().value_or(0.0f)} - vel_estimate: {type: readonly float32, unit: turns/s, c_getter: vel_estimate_.get_any().value_or(0.0f)} + phase_vel: {type: readonly float32, unit: rad/s, c_getter: phase_vel_.any().value_or(0.0f)} + vel_estimate: {type: readonly float32, unit: turns/s, c_getter: vel_estimate_.any().value_or(0.0f)} # pll_kp: float32 # pll_ki: float32 config: