Skip to content

Commit

Permalink
all hex files buiding
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 29, 2024
1 parent ac09f4e commit 162179e
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 37 deletions.
8 changes: 8 additions & 0 deletions include/can/core/message_handlers/move_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ using namespace can::messages;
template <move_group_task::TaskClient Client>
class MoveGroupHandler {
public:
#ifdef PIPETTE_TYPE_DEFINE
using MessageType =
std::variant<std::monostate, AddLinearMoveRequest,
ClearAllMoveGroupsRequest, ExecuteMoveGroupRequest,
GetMoveGroupRequest, HomeRequest, StopRequest, AddSensorMoveRequest>;
#else
using MessageType =
std::variant<std::monostate, AddLinearMoveRequest,
ClearAllMoveGroupsRequest, ExecuteMoveGroupRequest,
GetMoveGroupRequest, HomeRequest, StopRequest>;
#endif

MoveGroupHandler(Client &task_client) : task_client{task_client} {}
MoveGroupHandler(const MoveGroupHandler &) = delete;
MoveGroupHandler(const MoveGroupHandler &&) = delete;
Expand Down
1 change: 0 additions & 1 deletion include/motor-control/core/motor_messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ struct SensorSyncMove // NOLINT(cppcoreguidelines-pro-type-member-init)
can::ids::SensorId sensor_id;

auto build_ack(int32_t pulses, uint8_t flags, AckMessageId _id) -> Ack {
// not sure if we need to include sensor id in the ack
return Ack{
.message_index = message_index,
.group_id = group_id,
Expand Down
18 changes: 10 additions & 8 deletions include/motor-control/core/stepper_motor/motion_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ class MotionController {
steps_per_tick_sq acceleration_steps =
fixed_point_multiply(steps_per_um, can_msg.acceleration);
SensorSyncMove msg{
.message_index = can_msg.message_index,
.duration = can_msg.duration,
.velocity = velocity_steps,
.acceleration = acceleration_steps,
.group_id = can_msg.group_id,
.seq_id = can_msg.seq_id,
.stop_condition = can_msg.request_stop_condition,
.usage_key = hardware.get_usage_eeprom_config().get_distance_key()};
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ class MotorInterruptHandler {
return has_active_move() && buffered_move.velocity != 0;
}

// private:
protected:
void update_hardware_step_tracker() {
hardware.set_step_tracker(
Expand Down
32 changes: 26 additions & 6 deletions include/motor-control/core/tasks/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace motor_control_task_messages {

#ifdef PIPETTE_TYPE_DEFINE
using MotionControlTaskMessage = std::variant<
std::monostate, can::messages::AddLinearMoveRequest,
can::messages::DisableMotorRequest, can::messages::EnableMotorRequest,
Expand All @@ -14,19 +15,38 @@ using MotionControlTaskMessage = std::variant<
can::messages::MotorPositionRequest, can::messages::ReadLimitSwitchRequest,
can::messages::HomeRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest>;

using MotorDriverTaskMessage =
std::variant<std::monostate, can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest>;
can::messages::GetMotorUsageRequest, can::messages::AddSensorMoveRequest>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
can::messages::ClearAllMoveGroupsRequest,
can::messages::ExecuteMoveGroupRequest,
can::messages::GetMoveGroupRequest, can::messages::HomeRequest,
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>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
can::messages::ClearAllMoveGroupsRequest,
can::messages::ExecuteMoveGroupRequest,
can::messages::GetMoveGroupRequest, can::messages::HomeRequest,
can::messages::StopRequest>;
#endif


using MotorDriverTaskMessage =
std::variant<std::monostate, can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest>;

using MoveStatusReporterTaskMessage = std::variant<
std::monostate, motor_messages::Ack, motor_messages::UpdatePositionResponse,
Expand Down
11 changes: 11 additions & 0 deletions include/motor-control/core/tasks/motion_controller_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ class MotionControllerMessageHandler {
controller.move(m);
}

#ifdef PIPETTE_TYPE_DEFINE
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",
m.velocity, m.acceleration, m.group_id, m.seq_id, m.duration,
m.request_stop_condition);
controller.move(m);
}
#endif

void handle(const can::messages::HomeRequest& m) {
LOG("Motion Controller Received home request: velocity=%d, "
"groupid=%d, seqid=%d\n",
Expand Down Expand Up @@ -140,6 +150,7 @@ class MotionControllerMessageHandler {
controller.send_usage_data(m.message_index, usage_client);
}


MotorControllerType& controller;
CanClient& can_client;
UsageClient& usage_client;
Expand Down
14 changes: 12 additions & 2 deletions include/motor-control/core/tasks/move_group_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ namespace move_group_task {

constexpr std::size_t max_groups = 3;
constexpr std::size_t max_moves_per_group = 12;

#ifdef PIPETTE_TYPE_DEFINE
using MoveGroupType =
move_group::MoveGroupManager<max_groups, max_moves_per_group,
can::messages::AddLinearMoveRequest,
can::messages::HomeRequest,
can::messages::AddSensorMoveRequest>;
#else
using MoveGroupType =
move_group::MoveGroupManager<max_groups, max_moves_per_group,
can::messages::AddLinearMoveRequest,
can::messages::HomeRequest>;
#endif

using TaskMessage = motor_control_task_messages::MoveGroupTaskMessage;

Expand Down Expand Up @@ -122,7 +128,11 @@ class MoveGroupMessageHandler {
mc_client.send_motion_controller_queue(m);
}

void visit_move(const can::messages::AddSensorMoveRequest&) {}
#ifdef PIPETTE_TYPE_DEFINE
void visit_move(const can::messages::AddSensorMoveRequest& m) {
mc_client.send_motion_controller_queue(m);
}
#endif

MoveGroupType& move_groups;
MotionControllerClient& mc_client;
Expand Down
10 changes: 10 additions & 0 deletions include/pipettes/core/dispatch_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ using GearMotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::GearWriteMotorDriverRegister,
can::messages::GearWriteMotorCurrentRequest>;

#ifdef PIPETTE_TYPE_DEFINE
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<
linear_motor_tasks::QueueClient>,
can::messages::AddLinearMoveRequest,
can::messages::ClearAllMoveGroupsRequest,
can::messages::ExecuteMoveGroupRequest, can::messages::GetMoveGroupRequest,
can::messages::HomeRequest, can::messages::StopRequest, can::messages::AddSensorMoveRequest>;
#else
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<
linear_motor_tasks::QueueClient>,
can::messages::AddLinearMoveRequest,
can::messages::ClearAllMoveGroupsRequest,
can::messages::ExecuteMoveGroupRequest, can::messages::GetMoveGroupRequest,
can::messages::HomeRequest, can::messages::StopRequest>;
#endif

using GearMoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
gear_move_group_handler::GearMoveGroupHandler<
Expand Down
21 changes: 8 additions & 13 deletions include/pipettes/core/motor_interrupt_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

namespace pipettes {
using namespace motor_messages;
//using InterruptHandler = motor_handler::MotorInterruptHandler<
// freertos_message_queue::FreeRTOSMessageQueue, StatusClient,
// MotorMoveMessage, MotorHardware>;
// might need to change MotorMoveMessage to include sensormove
template <template <class> class QueueImpl, class StatusClient,
typename MotorMoveMessage, typename MotorHardware, class SensorClient>
requires MessageQueue<QueueImpl<MotorMoveMessage>, MotorMoveMessage> &&
Expand All @@ -32,7 +28,6 @@ class PipetteMotorInterruptHandler
MotorMoveMessage, MotorHardware>(incoming_move_queue, outgoing_queue, hardware_iface,
stall, incoming_update_position_queue),
sensor_client(sensor_queue_client) {
// sensor_client = sensor_tasks::QueueClient{};
}

~PipetteMotorInterruptHandler() = default;
Expand All @@ -47,11 +42,6 @@ class PipetteMotorInterruptHandler

PipetteMotorInterruptHandler(PipetteMotorInterruptHandler&&) = delete;

// can determine which queue write function to use with the sensor id that gets passed in
// send a message to sensor queue inside update_move, if _has_active_move

// need to write a new kind of move that contains the stuff thats gonna be sent in the new can message

void run_interrupt() {
// handle various error states
if (this->clear_queue_until_empty) {
Expand Down Expand Up @@ -91,10 +81,10 @@ class PipetteMotorInterruptHandler
.sensor_id = m.sensor_id,
.binding = can::ids::SensorOutputBinding::report
};
send_to_pressure_sensor_queue(&msg);
}

void update_move() {
// do stuff in here
this->_has_active_move = this->move_queue.try_read_isr(&this->buffered_move);
if (this->_has_active_move) {
handle_move_type(this->buffered_move);
Expand Down Expand Up @@ -128,10 +118,15 @@ class PipetteMotorInterruptHandler
// update the stall check ideal encoder counts based on
// last known location

// check if queue is empty in here and send bindsensoroutputrequest

if (!this->has_move_messages()) {
this->stall_checker.reset_itr_counts(this->hardware.get_step_tracker());
auto& stop_msg = can::messages::BindSensorOutputRequest{
.message_index = this->buffered_move.message_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = this->buffered_move.sensor_id,
.binding = can::ids::SensorOutputBinding::none
};
send_to_pressure_sensor_queue(&stop_msg);
}
}

Expand Down
4 changes: 2 additions & 2 deletions include/pipettes/firmware/interfaces_g4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "motor-control/core/motor_messages.hpp"
#include "motor-control/core/stall_check.hpp"
#include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" // can maybe get rid of this ?
#include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp"
#include "pipettes/core/motor_interrupt_handler.hpp"
#include "motor-control/firmware/stepper_motor/motor_hardware.hpp"
#include "pipettes/core/gear_motor_tasks.hpp"
Expand Down Expand Up @@ -31,7 +31,7 @@ namespace interfaces {
template <typename Client>
using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler<
freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move,
motor_hardware::MotorHardware>; // pass in sensor client here
motor_hardware::MotorHardware>;
template <typename Client>
using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler<
freertos_message_queue::FreeRTOSMessageQueue, Client,
Expand Down
1 change: 0 additions & 1 deletion pipettes/firmware/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void linear_motor::encoder_interrupt(motor_hardware::MotorHardware& hw,
hw.encoder_overflow(direction);
}

// change these two
auto linear_motor::get_interrupt(motor_hardware::MotorHardware& hw,
LowThroughputInterruptQueues& queues,
stall_check::StallCheck& stall,
Expand Down
3 changes: 0 additions & 3 deletions pipettes/firmware/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ static auto& sensor_queue_client = sensor_tasks::get_queues();
static auto linear_motor_hardware =
interfaces::linear_motor::get_motor_hardware(
motor_config.hardware_pins.linear_motor);
// try to pass sensor client in here
static auto plunger_interrupt = interfaces::linear_motor::get_interrupt(
linear_motor_hardware, interrupt_queues, linear_stall_check, sensor_queue_client);
static auto linear_motion_control =
Expand Down Expand Up @@ -135,8 +134,6 @@ static auto sensor_hardware_container =

static auto tip_sense_gpio_primary = pins_for_sensor.primary.tip_sense.value();

//static auto& sensor_queue_client = sensor_tasks::get_queues();

static auto tail_accessor =
eeprom::dev_data::DevDataTailAccessor{sensor_queue_client};

Expand Down

0 comments on commit 162179e

Please sign in to comment.