Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hardware): specify nodes when clearing move groups #13072

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,20 @@ async def _clear_groups(self, can_messenger: CanMessenger) -> None:
error = await can_messenger.ensure_send(
node_id=NodeId.broadcast,
message=ClearAllMoveGroupsRequest(payload=EmptyPayload()),
expected_nodes=list(self.all_nodes()),
)
if error != ErrorCode.ok:
log.warning("Clear move group failed")

def all_nodes(self) -> Set[NodeId]:
"""Get all of the nodes in the move group runner's move gruops."""
node_set: Set[NodeId] = set()
for group in self._move_groups:
for sequence in group:
for node in sequence.keys():
node_set.add(node)
return node_set

async def _send_groups(self, can_messenger: CanMessenger) -> None:
"""Send commands to set up the message groups."""
for group_i, group in enumerate(self._move_groups):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ async def test_single_group_clear(
subject = MoveGroupRunner(move_groups=move_group_single)
await subject._clear_groups(can_messenger=mock_can_messenger)
mock_can_messenger.ensure_send.assert_has_calls(
[call(node_id=NodeId.broadcast, message=md.ClearAllMoveGroupsRequest())],
[
call(
node_id=NodeId.broadcast,
message=md.ClearAllMoveGroupsRequest(),
expected_nodes=[NodeId.head],
)
],
)


Expand All @@ -271,8 +277,21 @@ async def test_multi_group_clear(
"""It should send a clear group command before setup."""
subject = MoveGroupRunner(move_groups=move_group_multiple)
await subject.prep(can_messenger=mock_can_messenger)
expected = subject.all_nodes()
# Test that the expected nodes are correct
for group in move_group_multiple:
for step in group:
for node in step.keys():
assert node in expected

mock_can_messenger.ensure_send.assert_has_calls(
[call(node_id=NodeId.broadcast, message=md.ClearAllMoveGroupsRequest())],
[
call(
node_id=NodeId.broadcast,
message=md.ClearAllMoveGroupsRequest(),
expected_nodes=list(expected),
)
],
)


Expand Down