diff --git a/.github/workflows/cross-compile-special-sensors.yaml b/.github/workflows/cross-compile-special-sensors.yaml index 152de1eb1..bc6798960 100644 --- a/.github/workflows/cross-compile-special-sensors.yaml +++ b/.github/workflows/cross-compile-special-sensors.yaml @@ -24,6 +24,7 @@ jobs: pipettes-single, pipettes-multi, pipettes-96, + gripper, ] fail-fast: false name: Build ${{ matrix.target }} @@ -89,6 +90,7 @@ jobs: matrix: target: [ pipettes, + gripper, ] steps: - name: Checkout ot3-firmware repo diff --git a/gripper/firmware/interfaces_z_motor.cpp b/gripper/firmware/interfaces_z_motor.cpp index cb6d1c3c0..b272faa79 100644 --- a/gripper/firmware/interfaces_z_motor.cpp +++ b/gripper/firmware/interfaces_z_motor.cpp @@ -199,7 +199,7 @@ static motor_class::Motor z_motor{ static motor_handler::MotorInterruptHandler motor_interrupt( motor_queue, gripper_tasks::z_tasks::get_queues(), gripper_tasks::z_tasks::get_queues(), motor_hardware_iface, stallcheck, - update_position_queue); + update_position_queue, gripper_tasks::get_main_queues()); // use USE_SENSOR_MOVE static auto encoder_background_timer = motor_encoder::BackgroundTimer(motor_interrupt, motor_hardware_iface); diff --git a/include/bootloader/core/ids.h b/include/bootloader/core/ids.h index e51d6cbb6..bbd118211 100644 --- a/include/bootloader/core/ids.h +++ b/include/bootloader/core/ids.h @@ -114,7 +114,7 @@ typedef enum { can_messageid_peripheral_status_request = 0x8c, can_messageid_peripheral_status_response = 0x8d, can_messageid_baseline_sensor_response = 0x8e, - can_messageid_send_accumulated_pressure_data = 0x8f, + can_messageid_send_accumulated_sensor_data = 0x8f, can_messageid_set_hepa_fan_state_request = 0x90, can_messageid_get_hepa_fan_state_request = 0x91, can_messageid_get_hepa_fan_state_response = 0x92, diff --git a/include/can/core/ids.hpp b/include/can/core/ids.hpp index 2c5dd4169..2ffd1c398 100644 --- a/include/can/core/ids.hpp +++ b/include/can/core/ids.hpp @@ -118,7 +118,7 @@ enum class MessageId { peripheral_status_request = 0x8c, peripheral_status_response = 0x8d, baseline_sensor_response = 0x8e, - send_accumulated_pressure_data = 0x8f, + send_accumulated_sensor_data = 0x8f, set_hepa_fan_state_request = 0x90, get_hepa_fan_state_request = 0x91, get_hepa_fan_state_response = 0x92, @@ -197,6 +197,7 @@ enum class SensorType { pressure_temperature = 0x4, humidity = 0x5, temperature = 0x6, + UNUSED = 0x7, }; /** Sensor IDs available. diff --git a/include/can/core/messages.hpp b/include/can/core/messages.hpp index 2a37a0a85..1e5d5d917 100644 --- a/include/can/core/messages.hpp +++ b/include/can/core/messages.hpp @@ -786,24 +786,28 @@ struct FirmwareUpdateStatusResponse -> bool = default; }; -struct SendAccumulatedPressureDataRequest - : BaseMessage { +struct SendAccumulatedSensorDataRequest + : BaseMessage { uint32_t message_index = 0; uint8_t sensor_id = 0; + uint8_t sensor_type = 0; template static auto parse(Input body, Limit limit) - -> SendAccumulatedPressureDataRequest { + -> SendAccumulatedSensorDataRequest { uint32_t msg_ind = 0; uint8_t sensor_id = 0; + uint8_t sensor_type = 0; body = bit_utils::bytes_to_int(body, limit, msg_ind); body = bit_utils::bytes_to_int(body, limit, sensor_id); - return SendAccumulatedPressureDataRequest{.message_index = msg_ind, - .sensor_id = sensor_id}; + body = bit_utils::bytes_to_int(body, limit, sensor_type); + return SendAccumulatedSensorDataRequest{.message_index = msg_ind, + .sensor_id = sensor_id, + .sensor_type = sensor_type}; } - auto operator==(const SendAccumulatedPressureDataRequest& other) const + auto operator==(const SendAccumulatedSensorDataRequest& other) const -> bool = default; }; @@ -1772,6 +1776,7 @@ struct AddSensorMoveRequest : BaseMessage { mm_per_tick velocity; uint8_t request_stop_condition; can::ids::SensorId sensor_id{}; + can::ids::SensorType sensor_type{}; template static auto parse(Input body, Limit limit) -> AddSensorMoveRequest { @@ -1783,6 +1788,7 @@ struct AddSensorMoveRequest : BaseMessage { uint8_t request_stop_condition = 0; uint32_t msg_ind = 0; uint8_t sensor_id = 0; + uint8_t sensor_type = 0; body = bit_utils::bytes_to_int(body, limit, msg_ind); body = bit_utils::bytes_to_int(body, limit, group_id); @@ -1792,6 +1798,7 @@ struct AddSensorMoveRequest : BaseMessage { body = bit_utils::bytes_to_int(body, limit, velocity); body = bit_utils::bytes_to_int(body, limit, request_stop_condition); body = bit_utils::bytes_to_int(body, limit, sensor_id); + body = bit_utils::bytes_to_int(body, limit, sensor_type); return AddSensorMoveRequest{ .message_index = msg_ind, .group_id = group_id, @@ -1801,6 +1808,7 @@ struct AddSensorMoveRequest : BaseMessage { .velocity = velocity, .request_stop_condition = request_stop_condition, .sensor_id = static_cast(sensor_id), + .sensor_type = static_cast(sensor_type), }; } diff --git a/include/gripper/core/can_task.hpp b/include/gripper/core/can_task.hpp index 91e03acc7..0d91017fc 100644 --- a/include/gripper/core/can_task.hpp +++ b/include/gripper/core/can_task.hpp @@ -66,7 +66,7 @@ using GripperInfoDispatchTarget = can::dispatch::DispatchParseTarget< using SensorDispatchTarget = can::dispatch::DispatchParseTarget< sensors::handlers::SensorHandler, can::messages::TipStatusQueryRequest, can::messages::ReadFromSensorRequest, - can::messages::SendAccumulatedPressureDataRequest, + can::messages::SendAccumulatedSensorDataRequest, can::messages::WriteToSensorRequest, can::messages::BaselineSensorRequest, can::messages::SetSensorThresholdRequest, can::messages::BindSensorOutputRequest, diff --git a/include/motor-control/core/motor_messages.hpp b/include/motor-control/core/motor_messages.hpp index d012507f5..0f77c5dc7 100644 --- a/include/motor-control/core/motor_messages.hpp +++ b/include/motor-control/core/motor_messages.hpp @@ -90,6 +90,7 @@ struct SensorSyncMove { // NOLINT(cppcoreguidelines-pro-type-member-init) int32_t start_encoder_position; uint16_t usage_key; can::ids::SensorId sensor_id; + can::ids::SensorType sensor_type; auto build_ack(uint32_t position, int32_t pulses, uint8_t flags, AckMessageId _id) -> Ack { @@ -119,6 +120,7 @@ struct GearMotorMove // NOLINT(cppcoreguidelines-pro-type-member-init) can::ids::PipetteTipActionType action; can::ids::GearMotorId gear_motor_id; can::ids::SensorId sensor_id; + can::ids::SensorType sensor_type; auto build_ack(uint32_t position, int32_t pulses, uint8_t flags, AckMessageId _id) -> GearMotorAck { return GearMotorAck{message_index, group_id, diff --git a/include/motor-control/core/stepper_motor/motion_controller.hpp b/include/motor-control/core/stepper_motor/motion_controller.hpp index b798f136a..0f0203921 100644 --- a/include/motor-control/core/stepper_motor/motion_controller.hpp +++ b/include/motor-control/core/stepper_motor/motion_controller.hpp @@ -79,7 +79,8 @@ class MotionController { can_msg.request_stop_condition, 0, hardware.get_usage_eeprom_config().get_distance_key(), - can_msg.sensor_id}; + can_msg.sensor_id, + can_msg.sensor_type}; if (!enabled) { enable_motor(); } @@ -100,7 +101,8 @@ class MotionController { .seq_id = can_msg.seq_id, .stop_condition = can_msg.request_stop_condition, .usage_key = hardware.get_usage_eeprom_config().get_distance_key(), - .sensor_id = can::ids::SensorId::UNUSED}; + .sensor_id = can::ids::SensorId::UNUSED, + .sensor_type = can::ids::SensorType::UNUSED}; if (!enabled) { enable_motor(); } @@ -120,7 +122,8 @@ class MotionController { .stop_condition = static_cast(MoveStopCondition::limit_switch), .usage_key = hardware.get_usage_eeprom_config().get_distance_key(), - .sensor_id = can::ids::SensorId::UNUSED}; + .sensor_id = can::ids::SensorId::UNUSED, + .sensor_type = can::ids::SensorType::UNUSED}; if (!enabled) { enable_motor(); } @@ -329,7 +332,8 @@ class PipetteMotionController { hardware.get_step_tracker(), can_msg.action, gear_motor_id, - can::ids::SensorId::UNUSED}; + can::ids::SensorId::UNUSED, + can::ids::SensorType::UNUSED}; if (!enabled) { enable_motor(); 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 2c96cb90c..df84bc496 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -10,9 +10,6 @@ #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 -#include "pipettes/core/sensor_tasks.hpp" -#endif namespace motor_handler { @@ -45,8 +42,28 @@ using namespace motor_messages; * Note: The position tracker should never be allowed to go below zero. */ +// take macros up a level to this? +//see tabs +struct Empty {}; + +template +struct SensorAccessHelper { + inline static void send_to_pressure_sensor_queue(SensorClient& sensor_client, can::messages::BindSensorOutputRequest& m) { + sensor_client.send_to_pressure_sensor_queue(m); // handle return type/data. use send_to_isr like previously + } + inline static void send_to_capacitive_sensor_queue(SensorClient& sensor_client, can::messages::BindSensorOutputRequest& m) { + sensor_client.send_to_capacitive_sensor_queue(m); + } +} + +template<> struct SensorAccessHelper { + inline static void send_to_pressure_sensor_queue(Empty& sensor_client, can::messages::BindSensorOutputRequest& m) {} + inline static void send_to_capacitive_sensor_queue(Empty& sensor_client, can::messages::BindSensorOutputRequest& m) {} +} + template