mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-10 13:16:23 +08:00
Add axis homing function and AXIS state
This commit is contained in:
@@ -51,6 +51,25 @@ void Controller::start_anticogging_calibration() {
|
||||
}
|
||||
}
|
||||
|
||||
// Slowly drive in the negative direction at homing_speed until the min endstop is pressed
|
||||
// When pressed, set the linear count to the offset (default 0), and then
|
||||
bool Controller::home_axis() {
|
||||
if (axis_->config_.min_endstop.enabled) {
|
||||
set_vel_setpoint(-config_.homing_speed, 0.0f);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
axis_->run_control_loop([&](){
|
||||
if(axis_->min_endstop_state_){
|
||||
axis_->encoder_.set_linear_count(axis_->config_.min_endstop.offset);
|
||||
set_pos_setpoint(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
return !axis_->min_endstop_state_;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This anti-cogging implementation iterates through each encoder position,
|
||||
* waits for zero velocity & position error,
|
||||
|
||||
Reference in New Issue
Block a user