mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-18 01:09:22 +08:00
fix homing bug
This commit is contained in:
@@ -7,6 +7,7 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
### Fixed
|
||||
* ASCII protocol commands with multiline responses (`i`, `h`) now return the expected response (in v0.5.2 the response was corrupted)
|
||||
* odrivetool no longer shows the message `<Task pending coro=... running at ...>` when closing
|
||||
* Homing used to erroneously complete with `is_homed == True` even if it failed for some reason
|
||||
|
||||
### Added
|
||||
* `brake_resistor_current` added to interface for reading the commanded brake resistor current
|
||||
|
||||
@@ -386,10 +386,14 @@ bool Axis::run_homing() {
|
||||
|
||||
homing_.is_homed = false;
|
||||
|
||||
error_ &= ~ERROR_MIN_ENDSTOP_PRESSED;
|
||||
|
||||
bool done = false;
|
||||
|
||||
start_closed_loop_control();
|
||||
|
||||
// Driving toward the endstop
|
||||
while ((requested_state_ == AXIS_STATE_UNDEFINED) && motor_.is_armed_ && !min_endstop_.get_state()) {
|
||||
while ((requested_state_ == AXIS_STATE_UNDEFINED) && motor_.is_armed_ && !(done = min_endstop_.get_state())) {
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
@@ -397,6 +401,10 @@ bool Axis::run_homing() {
|
||||
|
||||
controller_.input_vel_ = 0.0f;
|
||||
|
||||
if (!done) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error_ &= ~ERROR_MIN_ENDSTOP_PRESSED; // clear this error since we deliberately drove into the endstop
|
||||
|
||||
std::optional<float> pos_estimate_local = encoder_.pos_estimate_.any();
|
||||
@@ -415,12 +423,16 @@ bool Axis::run_homing() {
|
||||
controller_.vel_setpoint_ = 0.0f;
|
||||
controller_.input_pos_updated();
|
||||
|
||||
while ((requested_state_ == AXIS_STATE_UNDEFINED) && motor_.is_armed_ && !controller_.trajectory_done_) {
|
||||
while ((requested_state_ == AXIS_STATE_UNDEFINED) && motor_.is_armed_ && !(done = controller_.trajectory_done_)) {
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
stop_closed_loop_control();
|
||||
|
||||
if (!done) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the current position to 0.
|
||||
encoder_.set_linear_count(0);
|
||||
controller_.input_pos_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user