From 77dce9eaeff21abebccba5dcf763c0a465377cae Mon Sep 17 00:00:00 2001 From: Ryan howard Date: Tue, 4 Jun 2024 11:29:29 -0400 Subject: [PATCH] rip out the unneeded templating of sensor hardware since that stuff is behind ifdefs --- gripper/core/tasks.cpp | 4 + gripper/firmware/interfaces_z_motor.cpp | 2 +- include/gripper/core/tasks.hpp | 4 + .../stepper_motor/motor_interrupt_handler.hpp | 89 +++---------------- include/pipettes/firmware/interfaces.hpp | 13 ++- include/pipettes/firmware/interfaces_g4.hpp | 11 +-- include/pipettes/simulator/interfaces.hpp | 24 +++-- motor-control/core/CMakeLists.txt | 11 ++- .../core/motor_interrupt_handler.cpp | 4 - pipettes/firmware/interfaces.cpp | 10 +-- pipettes/firmware/main.cpp | 3 +- pipettes/simulator/interfaces.cpp | 24 +++-- 12 files changed, 79 insertions(+), 120 deletions(-) delete mode 100644 motor-control/core/motor_interrupt_handler.cpp diff --git a/gripper/core/tasks.cpp b/gripper/core/tasks.cpp index 46c9c811e..da192c96d 100644 --- a/gripper/core/tasks.cpp +++ b/gripper/core/tasks.cpp @@ -199,3 +199,7 @@ auto gripper_tasks::get_all_tasks() -> AllTask& { return tasks; } * @return */ auto gripper_tasks::get_main_queues() -> QueueClient& { return queues; } + +auto sensor_tasks::get_queues() -> gripper_tasks::QueueClient& { + return queues; +} diff --git a/gripper/firmware/interfaces_z_motor.cpp b/gripper/firmware/interfaces_z_motor.cpp index 88c389eaf..69405dfde 100644 --- a/gripper/firmware/interfaces_z_motor.cpp +++ b/gripper/firmware/interfaces_z_motor.cpp @@ -197,7 +197,7 @@ static motor_class::Motor z_motor{ */ static motor_handler::MotorInterruptHandler motor_interrupt( motor_queue, gripper_tasks::z_tasks::get_queues(), motor_hardware_iface, - stallcheck, update_position_queue, gripper_tasks::get_main_queues()); + stallcheck, update_position_queue); static auto encoder_background_timer = motor_encoder::BackgroundTimer(motor_interrupt, motor_hardware_iface); diff --git a/include/gripper/core/tasks.hpp b/include/gripper/core/tasks.hpp index f31229362..c61ef164b 100644 --- a/include/gripper/core/tasks.hpp +++ b/include/gripper/core/tasks.hpp @@ -271,3 +271,7 @@ struct QueueClient : can::message_writer::MessageWriter { } // namespace g_tasks } // namespace gripper_tasks + +namespace sensor_tasks { +[[nodiscard]] auto get_queues() -> gripper_tasks::QueueClient&; +} // namespace sensor_tasks diff --git a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp index 4b5ab9f44..577d1cb41 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -9,7 +9,14 @@ #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stall_check.hpp" #include "motor-control/core/tasks/move_status_reporter_task.hpp" - +#include "motor-control/core/tasks/tmc_motor_driver_common.hpp" +#ifdef USE_SENSOR_MOVE +#ifdef PIPETTE_TYPE_DEFINE +#include "pipettes/core/sensor_tasks.hpp" +#else +#include "gripper/core/tasks.hpp" +#endif // PIPETTE_TYPE_DEFINE +#endif // USE_SENSOR_MOVE namespace motor_handler { using namespace motor_messages; @@ -41,61 +48,8 @@ using namespace motor_messages; * Note: The position tracker should never be allowed to go below zero. */ -struct Empty { - static auto get_default() -> Empty&; -}; - -template -struct SensorClientHelper { - inline static void send_to_pressure_sensor_queue_rear( - SensorClient& sensor_client, - can::messages::BindSensorOutputRequest& m) { - sensor_client.send_pressure_sensor_queue_rear_isr(m); - } - inline static void send_to_pressure_sensor_queue_front( - SensorClient& sensor_client, - can::messages::BindSensorOutputRequest& m) { - sensor_client.send_pressure_sensor_queue_front_isr(m); - } - inline static void send_to_capacitive_sensor_queue_rear( - SensorClient& sensor_client, - can::messages::BindSensorOutputRequest& m) { - sensor_client.send_capacitive_sensor_queue_rear_isr(m); - } - inline static void send_to_capacitive_sensor_queue_front( - SensorClient& sensor_client, - can::messages::BindSensorOutputRequest& m) { - sensor_client.send_capacitive_sensor_queue_front_isr(m); - } -}; - -template <> -struct SensorClientHelper { - inline static void send_to_pressure_sensor_queue_rear( - Empty& sensor_client, can::messages::BindSensorOutputRequest& m) { - std::ignore = sensor_client; - std::ignore = m; - } - inline static void send_to_pressure_sensor_queue_front( - Empty& sensor_client, can::messages::BindSensorOutputRequest& m) { - std::ignore = sensor_client; - std::ignore = m; - } - inline static void send_to_capacitive_sensor_queue_rear( - Empty& sensor_client, can::messages::BindSensorOutputRequest& m) { - std::ignore = sensor_client; - std::ignore = m; - } - inline static void send_to_capacitive_sensor_queue_front( - Empty& sensor_client, can::messages::BindSensorOutputRequest& m) { - std::ignore = sensor_client; - std::ignore = m; - } -}; - template