mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-18 18:20:15 +08:00
Merge pull request #451 from aprgl/mechanical-brake
Mechanical brake support
This commit is contained in:
@@ -19,7 +19,8 @@ Axis::Axis(int axis_num,
|
||||
Motor& motor,
|
||||
TrapezoidalTrajectory& trap,
|
||||
Endstop& min_endstop,
|
||||
Endstop& max_endstop)
|
||||
Endstop& max_endstop,
|
||||
MechanicalBrake& mechanical_brake)
|
||||
: axis_num_(axis_num),
|
||||
default_step_gpio_pin_(default_step_gpio_pin),
|
||||
default_dir_gpio_pin_(default_dir_gpio_pin),
|
||||
@@ -33,6 +34,7 @@ Axis::Axis(int axis_num,
|
||||
trap_traj_(trap),
|
||||
min_endstop_(min_endstop),
|
||||
max_endstop_(max_endstop),
|
||||
mechanical_brake_(mechanical_brake),
|
||||
current_limiters_(make_array(
|
||||
static_cast<CurrentLimiter*>(&fet_thermistor),
|
||||
static_cast<CurrentLimiter*>(&motor_thermistor))),
|
||||
@@ -49,6 +51,7 @@ Axis::Axis(int axis_num,
|
||||
trap_traj_.axis_ = this;
|
||||
min_endstop_.axis_ = this;
|
||||
max_endstop_.axis_ = this;
|
||||
mechanical_brake_.axis_ = this;
|
||||
}
|
||||
|
||||
Axis::LockinConfig_t Axis::default_calibration() {
|
||||
@@ -460,6 +463,7 @@ bool Axis::run_idle_loop() {
|
||||
// run_control_loop ignores missed modulation timing updates
|
||||
// if and only if we're in AXIS_STATE_IDLE
|
||||
safety_critical_disarm_motor_pwm(motor_);
|
||||
mechanical_brake_.engage();
|
||||
set_step_dir_active(config_.enable_step_dir && config_.step_dir_always_on);
|
||||
run_control_loop([this]() {
|
||||
return true;
|
||||
@@ -472,6 +476,7 @@ void Axis::run_state_machine_loop() {
|
||||
|
||||
// arm!
|
||||
motor_.arm();
|
||||
mechanical_brake_.release();
|
||||
|
||||
for (;;) {
|
||||
// Load the task chain if a specific request is pending
|
||||
@@ -573,6 +578,7 @@ void Axis::run_state_machine_loop() {
|
||||
case AXIS_STATE_IDLE: {
|
||||
run_idle_loop();
|
||||
status = motor_.arm(); // done with idling - try to arm the motor
|
||||
mechanical_brake_.release();
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user