From 7ff6133f10383721f45b803ee96df85311f8047c Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Mon, 29 Jan 2024 15:32:52 -0500 Subject: [PATCH] format --- .../can/core/message_handlers/move_group.hpp | 9 +-- include/can/core/messages.hpp | 17 +++-- include/motor-control/core/motor_messages.hpp | 20 +++--- .../core/stepper_motor/motion_controller.hpp | 24 +++---- .../stepper_motor/motor_interrupt_handler.hpp | 42 ++++++------- include/motor-control/core/tasks/messages.hpp | 32 +++++----- .../core/tasks/motion_controller_task.hpp | 1 - .../core/tasks/move_group_task.hpp | 12 ++-- include/pipettes/core/dispatch_builder.hpp | 7 ++- .../pipettes/core/motor_interrupt_handler.hpp | 63 +++++++++---------- include/pipettes/firmware/interfaces_g4.hpp | 6 +- pipettes/firmware/main.cpp | 3 +- 12 files changed, 116 insertions(+), 120 deletions(-) diff --git a/include/can/core/message_handlers/move_group.hpp b/include/can/core/message_handlers/move_group.hpp index 9cd589ad6..a0f7e79fe 100644 --- a/include/can/core/message_handlers/move_group.hpp +++ b/include/can/core/message_handlers/move_group.hpp @@ -15,12 +15,13 @@ class MoveGroupHandler { using MessageType = std::variant; + GetMoveGroupRequest, HomeRequest, StopRequest, + AddSensorMoveRequest>; #else using MessageType = - std::variant; + std::variant; #endif MoveGroupHandler(Client &task_client) : task_client{task_client} {} diff --git a/include/can/core/messages.hpp b/include/can/core/messages.hpp index ba3484499..dbdfcc7a5 100644 --- a/include/can/core/messages.hpp +++ b/include/can/core/messages.hpp @@ -1591,21 +1591,20 @@ struct AddSensorMoveRequest : BaseMessage { body = bit_utils::bytes_to_int(body, limit, request_stop_condition); body = bit_utils::bytes_to_int(body, limit, sensor_id); return AddSensorMoveRequest{ - .message_index = msg_ind, - .group_id = group_id, - .seq_id = seq_id, - .duration = duration, - .acceleration = acceleration, - .velocity = velocity, - .request_stop_condition = request_stop_condition, - .sensor_id = static_cast(sensor_id), + .message_index = msg_ind, + .group_id = group_id, + .seq_id = seq_id, + .duration = duration, + .acceleration = acceleration, + .velocity = velocity, + .request_stop_condition = request_stop_condition, + .sensor_id = static_cast(sensor_id), }; } auto operator==(const AddSensorMoveRequest& other) const -> bool = default; }; - /** * A variant of all message types we might send.. */ diff --git a/include/motor-control/core/motor_messages.hpp b/include/motor-control/core/motor_messages.hpp index 27c47da2d..724790659 100644 --- a/include/motor-control/core/motor_messages.hpp +++ b/include/motor-control/core/motor_messages.hpp @@ -80,20 +80,20 @@ struct Move { // NOLINT(cppcoreguidelines-pro-type-member-init) }; struct SensorSyncMove // NOLINT(cppcoreguidelines-pro-type-member-init) - : public Move { + : public Move { can::ids::SensorId sensor_id; auto build_ack(int32_t pulses, uint8_t flags, AckMessageId _id) -> Ack { return Ack{ - .message_index = message_index, - .group_id = group_id, - .seq_id = seq_id, - .current_position_steps = 0, - .encoder_position = pulses, - .position_flags = flags, - .ack_id = _id, - .start_encoder_position = start_encoder_position, - .usage_key = usage_key, + .message_index = message_index, + .group_id = group_id, + .seq_id = seq_id, + .current_position_steps = 0, + .encoder_position = pulses, + .position_flags = flags, + .ack_id = _id, + .start_encoder_position = start_encoder_position, + .usage_key = usage_key, }; } }; diff --git a/include/motor-control/core/stepper_motor/motion_controller.hpp b/include/motor-control/core/stepper_motor/motion_controller.hpp index dede8841b..6ee1f379d 100644 --- a/include/motor-control/core/stepper_motor/motion_controller.hpp +++ b/include/motor-control/core/stepper_motor/motion_controller.hpp @@ -61,20 +61,20 @@ class MotionController { void move(const can::messages::AddSensorMoveRequest& can_msg) { steps_per_tick velocity_steps = - fixed_point_multiply(steps_per_mm, can_msg.velocity); + fixed_point_multiply(steps_per_mm, can_msg.velocity); steps_per_tick_sq acceleration_steps = - fixed_point_multiply(steps_per_um, can_msg.acceleration); + fixed_point_multiply(steps_per_um, can_msg.acceleration); SensorSyncMove msg{ - can_msg.message_index, - can_msg.duration, - velocity_steps, - acceleration_steps, - can_msg.group_id, - can_msg.seq_id, - can_msg.request_stop_condition, - 0, - hardware.get_usage_eeprom_config().get_distance_key(), - can_msg.sensor_id}; + can_msg.message_index, + can_msg.duration, + velocity_steps, + acceleration_steps, + can_msg.group_id, + can_msg.seq_id, + can_msg.request_stop_condition, + 0, + hardware.get_usage_eeprom_config().get_distance_key(), + can_msg.sensor_id}; 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 4dc7763b9..c70c369e9 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -594,26 +594,26 @@ class MotorInterruptHandler { return has_active_move() && buffered_move.velocity != 0; } -protected: -void update_hardware_step_tracker() { - hardware.set_step_tracker( - static_cast(position_tracker >> 31)); -} - -uint64_t tick_count = 0x0; -static constexpr const q31_31 tick_flag = 0x80000000; -static constexpr const uint64_t overflow_flag = 0x8000000000000000; -// Tracks position with sub-microstep accuracy -q31_31 position_tracker{0}; -MoveQueue& move_queue; -StatusClient& status_queue_client; -MotorHardware& hardware; -stall_check::StallCheck& stall_checker; -UpdatePositionQueue& update_position_queue; -MotorMoveMessage buffered_move = MotorMoveMessage{}; -bool clear_queue_until_empty = false; -bool stall_handled = false; -bool in_estop = false; -std::atomic_bool _has_active_move = false; + protected: + void update_hardware_step_tracker() { + hardware.set_step_tracker( + static_cast(position_tracker >> 31)); + } + + uint64_t tick_count = 0x0; + static constexpr const q31_31 tick_flag = 0x80000000; + static constexpr const uint64_t overflow_flag = 0x8000000000000000; + // Tracks position with sub-microstep accuracy + q31_31 position_tracker{0}; + MoveQueue& move_queue; + StatusClient& status_queue_client; + MotorHardware& hardware; + stall_check::StallCheck& stall_checker; + UpdatePositionQueue& update_position_queue; + MotorMoveMessage buffered_move = MotorMoveMessage{}; + bool clear_queue_until_empty = false; + bool stall_handled = false; + bool in_estop = false; + std::atomic_bool _has_active_move = false; }; } // namespace motor_handler diff --git a/include/motor-control/core/tasks/messages.hpp b/include/motor-control/core/tasks/messages.hpp index 1e27fb529..c49ac5563 100644 --- a/include/motor-control/core/tasks/messages.hpp +++ b/include/motor-control/core/tasks/messages.hpp @@ -22,27 +22,27 @@ using MoveGroupTaskMessage = can::messages::ClearAllMoveGroupsRequest, can::messages::ExecuteMoveGroupRequest, can::messages::GetMoveGroupRequest, can::messages::HomeRequest, - can::messages::StopRequest, can::messages::AddSensorMoveRequest>; + can::messages::StopRequest, + can::messages::AddSensorMoveRequest>; #else using MotionControlTaskMessage = std::variant< - std::monostate, can::messages::AddLinearMoveRequest, - can::messages::DisableMotorRequest, can::messages::EnableMotorRequest, - can::messages::GetMotionConstraintsRequest, - can::messages::SetMotionConstraints, can::messages::StopRequest, - can::messages::MotorPositionRequest, can::messages::ReadLimitSwitchRequest, - can::messages::HomeRequest, - can::messages::UpdateMotorPositionEstimationRequest, - can::messages::GetMotorUsageRequest>; + std::monostate, can::messages::AddLinearMoveRequest, + can::messages::DisableMotorRequest, can::messages::EnableMotorRequest, + can::messages::GetMotionConstraintsRequest, + can::messages::SetMotionConstraints, can::messages::StopRequest, + can::messages::MotorPositionRequest, can::messages::ReadLimitSwitchRequest, + can::messages::HomeRequest, + can::messages::UpdateMotorPositionEstimationRequest, + can::messages::GetMotorUsageRequest>; - using MoveGroupTaskMessage = - std::variant; +using MoveGroupTaskMessage = + std::variant; #endif - using MotorDriverTaskMessage = std::variant; +#else using MoveGroupType = move_group::MoveGroupManager; -#else -using MoveGroupType = - move_group::MoveGroupManager; + can::messages::HomeRequest>; #endif using TaskMessage = motor_control_task_messages::MoveGroupTaskMessage; diff --git a/include/pipettes/core/dispatch_builder.hpp b/include/pipettes/core/dispatch_builder.hpp index 00e60e019..88d98b4bf 100644 --- a/include/pipettes/core/dispatch_builder.hpp +++ b/include/pipettes/core/dispatch_builder.hpp @@ -46,11 +46,12 @@ using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::messages::AddLinearMoveRequest, can::messages::ClearAllMoveGroupsRequest, can::messages::ExecuteMoveGroupRequest, can::messages::GetMoveGroupRequest, - can::messages::HomeRequest, can::messages::StopRequest, can::messages::AddSensorMoveRequest>; + can::messages::HomeRequest, can::messages::StopRequest, + can::messages::AddSensorMoveRequest>; #else - using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< +using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::move_group::MoveGroupHandler< - linear_motor_tasks::QueueClient>, + linear_motor_tasks::QueueClient>, can::messages::AddLinearMoveRequest, can::messages::ClearAllMoveGroupsRequest, can::messages::ExecuteMoveGroupRequest, can::messages::GetMoveGroupRequest, diff --git a/include/pipettes/core/motor_interrupt_handler.hpp b/include/pipettes/core/motor_interrupt_handler.hpp index 74597b759..5f47f02ac 100644 --- a/include/pipettes/core/motor_interrupt_handler.hpp +++ b/include/pipettes/core/motor_interrupt_handler.hpp @@ -10,9 +10,9 @@ template