Skip to content

Commit

Permalink
fix(motor-control): monitor encoder during empty moves (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsinapi authored Oct 19, 2023
1 parent 01859ad commit cd2ae02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BackgroundTimer {
auto callback() -> void {
auto critical_section =
freertos_synchronization::FreeRTOSCriticalSectionRAII();
if (!_interrupt_handler.has_active_move()) {
if (!_interrupt_handler.is_moving()) {
// Refresh the overflow counter if nothing else is doing it
// and update position flag if needed
std::ignore = _interrupt_handler.check_for_stall();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,14 @@ class MotorInterruptHandler {

auto has_active_move() -> bool { return _has_active_move.load(); }

/**
* @brief Returns whether the motor has an active move *and*
* the velocity is nonzero.
*/
auto is_moving() -> bool {
return has_active_move() && buffered_move.velocity != 0;
}

private:
void update_hardware_step_tracker() {
hardware.set_step_tracker(
Expand Down

0 comments on commit cd2ae02

Please sign in to comment.