mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-23 09:03:40 +08:00
Merge branch 'timing' into devel
This commit is contained in:
@@ -186,12 +186,30 @@ bool Axis::do_checks() {
|
||||
// @brief Update all esitmators
|
||||
bool Axis::do_updates() {
|
||||
// Sub-components should use set_error which will propegate to this error_
|
||||
task_times_.thermistor_update.beginTimer();
|
||||
for (ThermistorCurrentLimiter* thermistor : thermistors_) {
|
||||
thermistor->update();
|
||||
}
|
||||
task_times_.thermistor_update.stopTimer();
|
||||
|
||||
task_times_.encoder_update.beginTimer();
|
||||
encoder_.update();
|
||||
task_times_.encoder_update.stopTimer();
|
||||
|
||||
task_times_.sensorless_update.beginTimer();
|
||||
sensorless_estimator_.update();
|
||||
task_times_.sensorless_update.stopTimer();
|
||||
|
||||
task_times_.min_endstop_update.beginTimer();
|
||||
motor_.fet_thermistor_.update();
|
||||
motor_.motor_thermistor_.update();
|
||||
min_endstop_.update();
|
||||
task_times_.min_endstop_update.stopTimer();
|
||||
|
||||
task_times_.max_endstop_update.beginTimer();
|
||||
max_endstop_.update();
|
||||
task_times_.max_endstop_update.stopTimer();
|
||||
|
||||
bool ret = check_for_errors();
|
||||
odCAN->send_cyclic(*this);
|
||||
return ret;
|
||||
@@ -331,13 +349,18 @@ bool Axis::run_closed_loop_control_loop() {
|
||||
set_step_dir_active(config_.enable_step_dir);
|
||||
run_control_loop([this](){
|
||||
// Note that all estimators are updated in the loop prefix in run_control_loop
|
||||
|
||||
task_times_.controller_update.beginTimer();
|
||||
float torque_setpoint;
|
||||
if (!controller_.update(&torque_setpoint))
|
||||
return error_ |= ERROR_CONTROLLER_FAILED, false;
|
||||
task_times_.controller_update.stopTimer();
|
||||
|
||||
task_times_.motor_update.beginTimer();
|
||||
float phase_vel = (2*M_PI) * encoder_.vel_estimate_ * motor_.config_.pole_pairs;
|
||||
if (!motor_.update(torque_setpoint, encoder_.phase_, phase_vel))
|
||||
return false; // set_error should update axis.error_
|
||||
task_times_.motor_update.stopTimer();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user