Skip to content

Commit

Permalink
fix(motor-control): reduce the number of responses that happen after …
Browse files Browse the repository at this point in the history
…a stop request (#818)
  • Loading branch information
ryanthecoder authored Dec 13, 2024
1 parent b1d725e commit a3cd34c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
12 changes: 7 additions & 5 deletions include/motor-control/core/tasks/brushed_move_group_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ class MoveGroupMessageHandler {
can_client.send_can_message(can::ids::NodeId::host, response);
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
void clear_move_groups() {
for (auto& group : move_groups) {
group.clear();
}
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
this->clear_move_groups();
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ack_from_request(m));
}
Expand All @@ -104,9 +108,7 @@ class MoveGroupMessageHandler {

void handle(const can::messages::StopRequest& m) {
LOG("Recieved StopRequest in MoveGroup");
auto clear_req =
can::messages::ClearAllMoveGroupsRequest{.message_index = 0};
this->handle(clear_req);
this->clear_move_groups();
// pass the stop message to motion controller to kill pwm
// and any running moves
mc_client.send_brushed_motion_controller_queue(m);
Expand Down
12 changes: 7 additions & 5 deletions include/motor-control/core/tasks/move_group_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ class MoveGroupMessageHandler {
can_client.send_can_message(can::ids::NodeId::host, response);
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
void clear_move_groups() {
for (auto& group : move_groups) {
group.clear();
}
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
this->clear_move_groups();
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ack_from_request(m));
}
Expand All @@ -102,9 +106,7 @@ class MoveGroupMessageHandler {

void handle(const can::messages::StopRequest& m) {
LOG("Received StopRequest in MoveGroup");
auto clear_req =
can::messages::ClearAllMoveGroupsRequest{.message_index = 0};
this->handle(clear_req);
this->clear_move_groups();
// pass the stop message to motion controller to kill pwm
// and any running moves
mc_client.send_motion_controller_queue(m);
Expand Down
12 changes: 7 additions & 5 deletions include/pipettes/core/tasks/move_group_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ class MoveGroupMessageHandler {
can_client.send_can_message(can::ids::NodeId::host, response);
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
void clear_move_groups() {
for (auto& group : move_groups) {
group.clear();
}
}

void handle(const can::messages::ClearAllMoveGroupsRequest& m) {
LOG("Received clear move groups request");
this->clear_move_groups();
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ack_from_request(m));
}
Expand All @@ -94,9 +98,7 @@ class MoveGroupMessageHandler {

void handle(const can::messages::StopRequest& m) {
LOG("Received StopRequest in MoveGroup");
auto clear_req =
can::messages::ClearAllMoveGroupsRequest{.message_index = 0};
this->handle(clear_req);
this->clear_move_groups();
// pass the stop message to motion controller to kill pwm
// and any running moves
mc_client.send_motion_controller_queue(m);
Expand Down

0 comments on commit a3cd34c

Please sign in to comment.