Skip to content

Commit

Permalink
add back subcomponent error flags
Browse files Browse the repository at this point in the history
These flags were previously removed in 661a3b5ed93591d3bfcd81dc355e8cd4079e2d7
  • Loading branch information
samuelsadok committed Mar 30, 2022
1 parent 22be53c commit 4b1081e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Arduino/ODriveArduino/ODriveEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ enum CanError {
enum AxisError {
AXIS_ERROR_NONE = 0x00000000,
AXIS_ERROR_INVALID_STATE = 0x00000001,
AXIS_ERROR_MOTOR_FAILED = 0x00000040,
AXIS_ERROR_SENSORLESS_ESTIMATOR_FAILED = 0x00000080,
AXIS_ERROR_ENCODER_FAILED = 0x00000100,
AXIS_ERROR_CONTROLLER_FAILED = 0x00000200,
AXIS_ERROR_WATCHDOG_TIMER_EXPIRED = 0x00000800,
AXIS_ERROR_MIN_ENDSTOP_PRESSED = 0x00001000,
AXIS_ERROR_MAX_ENDSTOP_PRESSED = 0x00002000,
Expand Down
1 change: 1 addition & 0 deletions Firmware/MotorControl/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void Encoder::set_error(Error error) {
vel_estimate_valid_ = false;
pos_estimate_valid_ = false;
error_ |= error;
axis_->error_ |= Axis::ERROR_ENCODER_FAILED;
}

bool Encoder::do_checks(){
Expand Down
7 changes: 5 additions & 2 deletions Firmware/MotorControl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,11 @@ void ODrive::control_loop_cb(uint32_t timestamp) {
MEASURE_TIME(axis.task_times_.sensorless_estimator_update)
axis.sensorless_estimator_.update();

MEASURE_TIME(axis.task_times_.controller_update)
axis.controller_.update(); // uses position and velocity from encoder
MEASURE_TIME(axis.task_times_.controller_update) {
if (!axis.controller_.update()) { // uses position and velocity from encoder
axis.error_ |= Axis::ERROR_CONTROLLER_FAILED;
}
}

MEASURE_TIME(axis.task_times_.open_loop_controller_update)
axis.open_loop_controller_.update(timestamp);
Expand Down
1 change: 1 addition & 0 deletions Firmware/MotorControl/motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ bool Motor::setup() {

void Motor::disarm_with_error(Motor::Error error){
error_ |= error;
axis_->error_ |= Axis::ERROR_MOTOR_FAILED;
last_error_time_ = odrv.n_evt_control_loop_ * current_meas_period;
disarm();
}
Expand Down
2 changes: 2 additions & 0 deletions Firmware/MotorControl/sensorless_estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bool SensorlessEstimator::update() {
// Check that we don't get problems with discrete time approximation
if (!(current_meas_period * pll_kp < 1.0f)) {
error_ |= ERROR_UNSTABLE_GAIN;
axis_->error_ |= Axis::ERROR_SENSORLESS_ESTIMATOR_FAILED;
reset(); // Reset state for when the next valid current measurement comes in.
return false;
}
Expand All @@ -43,6 +44,7 @@ bool SensorlessEstimator::update() {
}
if (!current_meas.has_value()) {
error_ |= ERROR_UNKNOWN_CURRENT_MEASUREMENT;
axis_->error_ |= Axis::ERROR_SENSORLESS_ESTIMATOR_FAILED;
reset(); // Reset state for when the next valid current measurement comes in.
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions Firmware/odrive-interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,13 @@ interfaces:
tried to run encoder calibration or closed loop control before the
motor was calibrated, or you tried to run closed loop control
before the encoder was calibrated.
MOTOR_FAILED:
bit: 6
doc: Check `motor.error` for more information.
SENSORLESS_ESTIMATOR_FAILED:
ENCODER_FAILED:
doc: Check `encoder.error` for more information.
CONTROLLER_FAILED:
WATCHDOG_TIMER_EXPIRED:
bit: 11
brief: The axis watchdog timer expired.
Expand Down
4 changes: 4 additions & 0 deletions tools/odrive/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
# ODrive.Axis.Error
AXIS_ERROR_NONE = 0x00000000
AXIS_ERROR_INVALID_STATE = 0x00000001
AXIS_ERROR_MOTOR_FAILED = 0x00000040
AXIS_ERROR_SENSORLESS_ESTIMATOR_FAILED = 0x00000080
AXIS_ERROR_ENCODER_FAILED = 0x00000100
AXIS_ERROR_CONTROLLER_FAILED = 0x00000200
AXIS_ERROR_WATCHDOG_TIMER_EXPIRED = 0x00000800
AXIS_ERROR_MIN_ENDSTOP_PRESSED = 0x00001000
AXIS_ERROR_MAX_ENDSTOP_PRESSED = 0x00002000
Expand Down

0 comments on commit 4b1081e

Please sign in to comment.