Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoegenburg committed Oct 12, 2023
1 parent b8afae2 commit 16baac0
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions include/motor-control/core/tasks/motion_controller_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,21 @@ class MotionControllerMessageHandler {
// cancel_and_clear_moves(can::ids::ErrorCode::motor_driver_error)?
void handle(const can::messages::MotorDriverErrorEncountered& m) {
// check if gpio is low before making controller calls
//if (!driver_error_handled()) {
controller.stop(can::ids::ErrorSeverity::unrecoverable);
if (!controller.is_timer_interrupt_running()){
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ErrorMessage{.message_index = m.message_index,
.severity = can::ids::ErrorSeverity::unrecoverable,
.error_code = can::ids::ErrorCode::hardware});
driver_client.send_motor_driver_queue(
can::messages::ReadMotorDriverErrorStatus{.message_index = m.message_index});
}
//}
controller.stop(can::ids::ErrorSeverity::unrecoverable);
if (!controller.is_timer_interrupt_running()){
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ErrorMessage{.message_index = m.message_index,
.severity = can::ids::ErrorSeverity::unrecoverable,
.error_code = can::ids::ErrorCode::hardware});
driver_client.send_motor_driver_queue(
can::messages::ReadMotorDriverErrorStatus{.message_index = m.message_index});
}
}

bool driver_error_handled() { return driver_error_handled_flag.exchange(true); }

MotorControllerType& controller;
CanClient& can_client;
UsageClient& usage_client;
DriverClient& driver_client;
std::atomic<bool> driver_error_handled_flag = false;
};

/**
Expand Down

0 comments on commit 16baac0

Please sign in to comment.