diff --git a/include/can/core/message_handlers/move_group.hpp b/include/can/core/message_handlers/move_group.hpp index a0f7e79fe..b29d54fce 100644 --- a/include/can/core/message_handlers/move_group.hpp +++ b/include/can/core/message_handlers/move_group.hpp @@ -11,7 +11,7 @@ using namespace can::messages; template class MoveGroupHandler { public: -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE using MessageType = std::variant class MotionController { public: using GenericQueue = -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE freertos_message_queue::FreeRTOSMessageQueue; #else freertos_message_queue::FreeRTOSMessageQueue; @@ -63,7 +63,7 @@ class MotionController { -> const lms::LinearMotionSystemConfig& { return linear_motion_sys_config; } -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE void move(const can::messages::AddSensorMoveRequest& can_msg) { steps_per_tick velocity_steps = fixed_point_multiply(steps_per_mm, can_msg.velocity); 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 d148348e3..adb52f9a7 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,7 @@ #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stall_check.hpp" #include "motor-control/core/tasks/move_status_reporter_task.hpp" -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE #include "pipettes/core/sensor_tasks.hpp" #endif namespace motor_handler { @@ -378,7 +378,7 @@ class MotorInterruptHandler { hardware.enable_encoder(); buffered_move.start_encoder_position = hardware.get_encoder_pulses(); -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) { auto msg = can::messages::BindSensorOutputRequest{ .message_index = buffered_move.message_index, @@ -471,7 +471,7 @@ class MotorInterruptHandler { tick_count = 0x0; stall_handled = false; build_and_send_ack(ack_msg_id); -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) { auto stop_msg = can::messages::BindSensorOutputRequest{ .message_index = buffered_move.message_index, @@ -624,7 +624,7 @@ class MotorInterruptHandler { hardware.set_step_tracker( static_cast(position_tracker >> 31)); } -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE void send_to_pressure_sensor_queue( can::messages::BindSensorOutputRequest& m) { std::ignore = sensor_tasks::get_queues() diff --git a/include/motor-control/core/tasks/messages.hpp b/include/motor-control/core/tasks/messages.hpp index c49ac5563..e9557b127 100644 --- a/include/motor-control/core/tasks/messages.hpp +++ b/include/motor-control/core/tasks/messages.hpp @@ -6,7 +6,7 @@ namespace motor_control_task_messages { -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE using MotionControlTaskMessage = std::variant< std::monostate, can::messages::AddLinearMoveRequest, can::messages::DisableMotorRequest, can::messages::EnableMotorRequest, diff --git a/include/motor-control/core/tasks/motion_controller_task.hpp b/include/motor-control/core/tasks/motion_controller_task.hpp index 5321b0e96..34b9e4596 100644 --- a/include/motor-control/core/tasks/motion_controller_task.hpp +++ b/include/motor-control/core/tasks/motion_controller_task.hpp @@ -95,7 +95,7 @@ class MotionControllerMessageHandler { controller.move(m); } -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE void handle(const can::messages::AddSensorMoveRequest& m) { LOG("Received add linear move request: velocity=%d, acceleration=%d, " "groupid=%d, seqid=%d, duration=%d, stopcondition=%d", diff --git a/include/motor-control/core/tasks/move_group_task.hpp b/include/motor-control/core/tasks/move_group_task.hpp index 789cbd808..828c370b2 100644 --- a/include/motor-control/core/tasks/move_group_task.hpp +++ b/include/motor-control/core/tasks/move_group_task.hpp @@ -14,7 +14,7 @@ namespace move_group_task { constexpr std::size_t max_groups = 3; constexpr std::size_t max_moves_per_group = 12; -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE using MoveGroupType = move_group::MoveGroupManager< max_groups, max_moves_per_group, can::messages::AddLinearMoveRequest, can::messages::HomeRequest, can::messages::AddSensorMoveRequest>; @@ -126,7 +126,7 @@ class MoveGroupMessageHandler { mc_client.send_motion_controller_queue(m); } -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE void visit_move(const can::messages::AddSensorMoveRequest& m) { mc_client.send_motion_controller_queue(m); } diff --git a/include/pipettes/core/dispatch_builder.hpp b/include/pipettes/core/dispatch_builder.hpp index ec4a3dbd1..78dc85d34 100644 --- a/include/pipettes/core/dispatch_builder.hpp +++ b/include/pipettes/core/dispatch_builder.hpp @@ -39,7 +39,7 @@ using GearMotorDispatchTarget = can::dispatch::DispatchParseTarget< can::messages::GearWriteMotorDriverRegister, can::messages::GearWriteMotorCurrentRequest>; -#ifdef PIPETTE_TYPE_DEFINE +#ifdef USE_PRESSURE_MOVE using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::move_group::MoveGroupHandler< linear_motor_tasks::QueueClient>, diff --git a/include/pipettes/core/interfaces.hpp b/include/pipettes/core/interfaces.hpp index cb1538b8b..1912d942e 100644 --- a/include/pipettes/core/interfaces.hpp +++ b/include/pipettes/core/interfaces.hpp @@ -6,9 +6,13 @@ #include "motor-control/core/tasks/motor_hardware_task.hpp" namespace interfaces { - +#ifdef USE_PRESSURE_MOVE using MoveQueue = freertos_message_queue::FreeRTOSMessageQueue< motor_messages::SensorSyncMove>; +#else +using MoveQueue = + freertos_message_queue::FreeRTOSMessageQueue; +#endif using GearMoveQueue = freertos_message_queue::FreeRTOSMessageQueue; using MotionControlType = diff --git a/include/pipettes/firmware/interfaces.hpp b/include/pipettes/firmware/interfaces.hpp index 19720b0ae..8baa83d24 100644 --- a/include/pipettes/firmware/interfaces.hpp +++ b/include/pipettes/firmware/interfaces.hpp @@ -18,10 +18,17 @@ namespace interfaces { +#ifdef USE_PRESSURE_MOVE template using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::SensorSyncMove, motor_hardware::MotorHardware>; +#else +template +using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move, + motor_hardware::MotorHardware>; +#endif template using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< freertos_message_queue::FreeRTOSMessageQueue, Client, diff --git a/include/pipettes/firmware/interfaces_g4.hpp b/include/pipettes/firmware/interfaces_g4.hpp index af74d9ea3..9e4138416 100644 --- a/include/pipettes/firmware/interfaces_g4.hpp +++ b/include/pipettes/firmware/interfaces_g4.hpp @@ -28,19 +28,30 @@ namespace interfaces { +#ifdef USE_PRESSURE_MOVE template using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::SensorSyncMove, motor_hardware::MotorHardware>; template -using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< - freertos_message_queue::FreeRTOSMessageQueue, Client, - motor_messages::GearMotorMove, motor_hardware::MotorHardware>; -template using PipetteMotorInterruptHandlerType = pipettes::PipetteMotorInterruptHandler< freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::SensorSyncMove, motor_hardware::MotorHardware, sensor_tasks::QueueClient>; +#else +template +using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move, + motor_hardware::MotorHardware>; +template +using PipetteMotorInterruptHandlerType = pipettes::PipetteMotorInterruptHandler< + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move, + motor_hardware::MotorHardware, sensor_tasks::QueueClient>; +#endif +template +using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< + freertos_message_queue::FreeRTOSMessageQueue, Client, + motor_messages::GearMotorMove, motor_hardware::MotorHardware>; template auto get_interrupt_queues() diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 801d17309..c5b938f71 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -14,7 +14,9 @@ #include "sensors/core/sensors.hpp" #include "sensors/core/utils.hpp" -#if PIPETTE_TYPE_DEFINE == NINETY_SIX_CHANNEL +#ifndef USE_PRESSURE_MOVE +constexpr size_t PRESSURE_SENSOR_BUFFER_SIZE = 0; +#elif PIPETTE_TYPE_DEFINE == NINETY_SIX_CHANNEL constexpr size_t PRESSURE_SENSOR_BUFFER_SIZE = 1800; #else constexpr size_t PRESSURE_SENSOR_BUFFER_SIZE = 3000; @@ -367,6 +369,7 @@ class MMR920 { } if (echo_this_time) { +#ifdef USE_PRESSURE_MOVE // send a response with 9999 to make an overload of the buffer // visible if (pressure_buffer_index < PRESSURE_SENSOR_BUFFER_SIZE) { @@ -380,6 +383,15 @@ class MMR920 { .severity = can::ids::ErrorSeverity::warning, .error_code = can::ids::ErrorCode::stop_requested}); } +#else + can_client.send_can_message( + can::ids::NodeId::host, + can::messages::ReadFromSensorResponse{ + .message_index = m.message_index, + .sensor = can::ids::SensorType::pressure, + .sensor_id = sensor_id, + .sensor_data = mmr920::reading_to_fixed_point(pressure)}); +#endif } } diff --git a/pipettes/core/CMakeLists.txt b/pipettes/core/CMakeLists.txt index 6cb31a375..4d3ef01cb 100644 --- a/pipettes/core/CMakeLists.txt +++ b/pipettes/core/CMakeLists.txt @@ -9,6 +9,9 @@ function(target_pipettes_core_common TARGET REVISION) target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_FUNCTION_LIST_DIR}) target_link_libraries(${TARGET} PUBLIC common-core) target_include_directories(${TARGET} INTERFACE ${CMAKE_SOURCE_DIR}/cpp-utils/include) + if(${USE_PRESSURE_MOVE}) + add_compile_definitions(-DUSE_PRESSURE_MOVE) + endif() endfunction() function(target_pipettes_core_single TARGET REVISION) diff --git a/pipettes/simulator/interfaces.cpp b/pipettes/simulator/interfaces.cpp index e2d534179..bab0ed521 100644 --- a/pipettes/simulator/interfaces.cpp +++ b/pipettes/simulator/interfaces.cpp @@ -56,9 +56,15 @@ auto linear_motor::get_interrupt_driver( sim_motor_hardware_iface::SimMotorHardwareIface& hw, MoveQueue& queue, MotorInterruptHandlerType& handler, UpdatePositionQueue& update_queue) +#ifdef USE_PRESSURE_MOVE -> motor_interrupt_driver::MotorInterruptDriver< linear_motor_tasks::QueueClient, motor_messages::SensorSyncMove, sim_motor_hardware_iface::SimMotorHardwareIface> { +#else + -> motor_interrupt_driver::MotorInterruptDriver< + linear_motor_tasks::QueueClient, motor_messages::Move, + sim_motor_hardware_iface::SimMotorHardwareIface> { +#endif return motor_interrupt_driver::MotorInterruptDriver(queue, handler, hw, update_queue); }