mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-21 07:14:22 +08:00
encoder can now be precalibrated without offset when using ACIM
This commit is contained in:
@@ -3,14 +3,17 @@
|
||||
|
||||
|
||||
Encoder::Encoder(const EncoderHardwareConfig_t& hw_config,
|
||||
Config_t& config) :
|
||||
Config_t& config, Motor::Config_t motor_config) :
|
||||
hw_config_(hw_config),
|
||||
config_(config)
|
||||
{
|
||||
update_pll_gains();
|
||||
|
||||
if (config.pre_calibrated && (config.mode == Encoder::MODE_HALL || config.mode == Encoder::MODE_SINCOS)) {
|
||||
is_ready_ = true;
|
||||
if (config.pre_calibrated) {
|
||||
if (config.mode == Encoder::MODE_HALL || config.mode == Encoder::MODE_SINCOS)
|
||||
is_ready_ = true;
|
||||
if (motor_config.motor_type == Motor::MOTOR_TYPE_ACIM)
|
||||
is_ready_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +82,8 @@ void Encoder::update_pll_gains() {
|
||||
}
|
||||
|
||||
void Encoder::check_pre_calibrated() {
|
||||
if (!is_ready_)
|
||||
config_.pre_calibrated = false;
|
||||
if (config_.mode == MODE_INCREMENTAL && !index_found_)
|
||||
// TODO: restoring config from python backup is fragile here (ACIM motor type must be set first)
|
||||
if (!is_ready_ && axis_->motor_.config_.motor_type != Motor::MOTOR_TYPE_ACIM)
|
||||
config_.pre_calibrated = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
};
|
||||
|
||||
Encoder(const EncoderHardwareConfig_t& hw_config,
|
||||
Config_t& config);
|
||||
Config_t& config, Motor::Config_t motor_config);
|
||||
|
||||
void setup();
|
||||
void set_error(Error_t error);
|
||||
@@ -116,11 +116,11 @@ public:
|
||||
[](void* ctx) { static_cast<Encoder*>(ctx)->set_idx_subscribe(); }, this),
|
||||
make_protocol_property("find_idx_on_lockin_only", &config_.find_idx_on_lockin_only,
|
||||
[](void* ctx) { static_cast<Encoder*>(ctx)->set_idx_subscribe(); }, this),
|
||||
make_protocol_property("pre_calibrated", &config_.pre_calibrated,
|
||||
[](void* ctx) { static_cast<Encoder*>(ctx)->check_pre_calibrated(); }, this),
|
||||
make_protocol_property("zero_count_on_find_idx", &config_.zero_count_on_find_idx),
|
||||
make_protocol_property("cpr", &config_.cpr),
|
||||
make_protocol_property("offset", &config_.offset),
|
||||
make_protocol_property("pre_calibrated", &config_.pre_calibrated,
|
||||
[](void* ctx) { static_cast<Encoder*>(ctx)->check_pre_calibrated(); }, this),
|
||||
make_protocol_property("offset_float", &config_.offset_float),
|
||||
make_protocol_property("enable_phase_interpolation", &config_.enable_phase_interpolation),
|
||||
make_protocol_property("bandwidth", &config_.bandwidth,
|
||||
|
||||
@@ -162,7 +162,7 @@ int odrive_main(void) {
|
||||
// Construct all objects.
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
Encoder *encoder = new Encoder(hw_configs[i].encoder_config,
|
||||
encoder_configs[i]);
|
||||
encoder_configs[i], motor_configs[i]);
|
||||
SensorlessEstimator *sensorless_estimator = new SensorlessEstimator(sensorless_configs[i]);
|
||||
Controller *controller = new Controller(controller_configs[i]);
|
||||
Motor *motor = new Motor(hw_configs[i].motor_config,
|
||||
|
||||
@@ -113,10 +113,10 @@ inline ENUMTYPE operator ~ (ENUMTYPE a) { return static_cast<ENUMTYPE>(~static_c
|
||||
// ODrive specific includes
|
||||
#include <utils.h>
|
||||
#include <low_level.h>
|
||||
#include <motor.hpp>
|
||||
#include <encoder.hpp>
|
||||
#include <sensorless_estimator.hpp>
|
||||
#include <controller.hpp>
|
||||
#include <motor.hpp>
|
||||
#include <trapTraj.hpp>
|
||||
#include <axis.hpp>
|
||||
#include <communication/communication.h>
|
||||
|
||||
Reference in New Issue
Block a user