Skip to content

Commit

Permalink
lint and build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoegenburg committed Nov 3, 2023
1 parent 394ea1d commit 90c6a50
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/motor-control/core/motor_hardware_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class MotorHardwareIface {
virtual void read_limit_switch() = 0;
virtual void read_estop_in() = 0;
virtual void read_sync_in() = 0;
virtual bool read_tmc_diag0() = 0;
virtual auto read_tmc_diag0() -> bool = 0;
virtual auto get_encoder_pulses() -> int32_t = 0;
virtual void reset_encoder_pulses() = 0;
virtual void start_timer_interrupt() = 0;
Expand Down
4 changes: 3 additions & 1 deletion include/motor-control/core/tasks/motion_controller_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ class MotionControllerMessageHandler {
CanClient& can_client;
UsageClient& usage_client;
DriverClient& driver_client;
std::atomic<bool> driver_error_handled_flag = false; // can get rid of this if indefinite interrupt trigger issue gets resolved
std::atomic<bool> driver_error_handled_flag =
false; // can get rid of this if indefinite interrupt trigger issue
// gets resolved
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BrushedMotorHardware : public BrushedMotorHardwareIface {
void read_limit_switch() final;
void read_estop_in() final;
void read_sync_in() final;
bool read_tmc_diag0() final;
auto read_tmc_diag0() -> bool final;
void grip() final;
void ungrip() final;
void stop_pwm() final;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MotorHardware : public StepperMotorHardwareIface {
void read_limit_switch() final;
void read_estop_in() final;
void read_sync_in() final;
bool read_tmc_diag0() final;
auto read_tmc_diag0() -> bool final;
void set_LED(bool status) final;
auto get_encoder_pulses() -> int32_t final;
void reset_encoder_pulses() final;
Expand Down
15 changes: 9 additions & 6 deletions include/motor-control/simulation/sim_motor_hardware_iface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SimMotorHardwareIface : public motor_hardware::StepperMotorHardwareIface {
void read_limit_switch() final {}
void read_estop_in() final {}
void read_sync_in() final {}
bool read_tmc_diag0() final { return false; }
void set_LED(bool) final {}
void trigger_limit_switch() { limit_switch_status = true; }
bool check_sync_in() final {
Expand Down Expand Up @@ -87,11 +88,11 @@ class SimMotorHardwareIface : public motor_hardware::StepperMotorHardwareIface {
bool check_estop_in() final { return estop_detected; }

void set_estop(bool estop_pressed) { estop_detected = estop_pressed; }
auto has_cancel_request() -> motor_hardware::CancelRequest final {
auto get_cancel_request() -> motor_hardware::CancelRequest final {
motor_hardware::CancelRequest exchange_request;
return cancel_request.exchange(exchange_request);
}
void request_cancel(can::ids::ErrorSeverity error_severity,
void set_cancel_request(can::ids::ErrorSeverity error_severity,
can::ids::ErrorCode error_code) final {
motor_hardware::CancelRequest update_request{
.severity = static_cast<uint8_t>(error_severity),
Expand Down Expand Up @@ -148,6 +149,7 @@ class SimBrushedMotorHardwareIface
void read_limit_switch() final {}
void read_estop_in() final {}
void read_sync_in() final {}
bool read_tmc_diag0() final { return false; }
void trigger_limit_switch() { limit_switch_status = true; }
void grip() final {}
void ungrip() final {}
Expand Down Expand Up @@ -188,11 +190,11 @@ class SimBrushedMotorHardwareIface
return ret;
}

auto has_cancel_request() -> motor_hardware::CancelRequest final {
auto get_cancel_request() -> motor_hardware::CancelRequest final {
motor_hardware::CancelRequest exchange_request;
return cancel_request.exchange(exchange_request);
}
void request_cancel(can::ids::ErrorSeverity error_severity,
void set_cancel_request(can::ids::ErrorSeverity error_severity,
can::ids::ErrorCode error_code) final {
motor_hardware::CancelRequest update_request{
.severity = static_cast<uint8_t>(error_severity),
Expand Down Expand Up @@ -256,6 +258,7 @@ class SimGearMotorHardwareIface
void read_limit_switch() final {}
void read_estop_in() final {}
void read_sync_in() final {}
bool read_tmc_diag0() final { return false; }
void set_LED(bool) final {}
void trigger_limit_switch() { limit_switch_status = true; }
bool check_sync_in() final {
Expand Down Expand Up @@ -288,11 +291,11 @@ class SimGearMotorHardwareIface
bool check_estop_in() final { return estop_detected; }

void set_estop(bool estop_pressed) { estop_detected = estop_pressed; }
auto has_cancel_request() -> motor_hardware::CancelRequest final {
auto get_cancel_request() -> motor_hardware::CancelRequest final {
motor_hardware::CancelRequest exchange_request;
return cancel_request.exchange(exchange_request);
}
void request_cancel(can::ids::ErrorSeverity error_severity,
void set_cancel_request(can::ids::ErrorSeverity error_severity,
can::ids::ErrorCode error_code) final {
motor_hardware::CancelRequest update_request{
.severity = static_cast<uint8_t>(error_severity),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MockBrushedMotorHardware : public BrushedMotorHardwareIface {
return old_request;
}
void set_cancel_request(can::ids::ErrorSeverity error_severity,
can::ids::ErrorCode error_code) final {
can::ids::ErrorCode error_code) final {
CancelRequest update_request{
.severity = static_cast<uint8_t>(error_severity),
.code = static_cast<uint8_t>(error_code)};
Expand Down
2 changes: 1 addition & 1 deletion include/motor-control/tests/mock_motor_hardware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MockMotorHardware : public motor_hardware::StepperMotorHardwareIface {
return old_request;
}
void set_cancel_request(can::ids::ErrorSeverity error_severity,
can::ids::ErrorCode error_code) final {
can::ids::ErrorCode error_code) final {
motor_hardware::CancelRequest update_request{
.severity = static_cast<uint8_t>(error_severity),
.code = static_cast<uint8_t>(error_code)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ void BrushedMotorHardware::read_sync_in() {
sync.debounce_update(gpio::is_set(pins.sync_in));
}

bool BrushedMotorHardware::read_tmc_diag0() {
return 0;
}
bool BrushedMotorHardware::read_tmc_diag0() { return 0; }

int32_t BrushedMotorHardware::get_encoder_pulses() {
if (!enc_handle) {
Expand Down
4 changes: 1 addition & 3 deletions motor-control/firmware/stepper_motor/motor_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ void MotorHardware::read_estop_in() {

void MotorHardware::read_sync_in() { sync = gpio::is_set(pins.sync_in); }

bool MotorHardware::read_tmc_diag0() {
return gpio::is_set(pins.diag0);
}
bool MotorHardware::read_tmc_diag0() { return gpio::is_set(pins.diag0); }

void MotorHardware::set_LED(bool status) {
if (status) {
Expand Down
5 changes: 3 additions & 2 deletions motor-control/tests/test_brushed_motor_interrupt_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,9 @@ SCENARIO("handler recovers from error state") {
test_objs.handler.error_handled = true;

WHEN("a cancel request is received") {
test_objs.hw.set_cancel_request(can::ids::ErrorSeverity::warning,
can::ids::ErrorCode::stop_requested);
test_objs.hw.set_cancel_request(
can::ids::ErrorSeverity::warning,
can::ids::ErrorCode::stop_requested);
test_objs.handler.run_interrupt();
THEN(
"motor state should become un-homed only if stay engaged is "
Expand Down
5 changes: 3 additions & 2 deletions motor-control/tests/test_motor_interrupt_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ SCENARIO("a move is cancelled due to a stop request") {
test_objs.handler.run_interrupt();
test_objs.handler.run_interrupt();
CHECK(test_objs.hw.steps_taken() == 1);
test_objs.hw.set_cancel_request(can::ids::ErrorSeverity::warning,
can::ids::ErrorCode::stop_requested);
test_objs.hw.set_cancel_request(
can::ids::ErrorSeverity::warning,
can::ids::ErrorCode::stop_requested);
test_objs.handler.run_interrupt();
THEN("An error and increase error count is sent") {
REQUIRE(test_objs.reporter.messages.size() == 2);
Expand Down

0 comments on commit 90c6a50

Please sign in to comment.