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

[PN-68] Refactor _robot_command_goal_complete #167

Merged
merged 31 commits into from
Dec 14, 2023

Conversation

abaker-bdai
Copy link
Contributor

@abaker-bdai abaker-bdai commented Oct 19, 2023

Merge #179 before merging this PR.

Adds unit test for _robot_command_goal_complete and refactors the function so that it is easier to read.

While writing the test, I spotted a few statuses that potentially return the incorrect value. I'll implement some of these test cases in a follow up PR.

Copy link
Collaborator

@jbarry-bdai jbarry-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just made comments on the test because I suggest doing this PR in three pieces:

  1. Only commit the test to reflect the current behavior of the function (but not the changes to the function included in this PR).
  2. Commit a refactor to the function that behaves exactly as the old function did - confirmed by the test committed in 1
  3. Commit changes to the refactor that fix the bugs discovered by the test.

This PR combines 1 and 2 - I suggest splitting it into two PRs.

Of the comments I made here, only the ones relevant to the actual test file (one typo, one place where I think a test is missing) should be updated in this PR. The others should wait for the third step where we fix the implementation.

Thanks for this!

spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
spot_driver/test/test_spot_driver.py Outdated Show resolved Hide resolved
@abaker-bdai
Copy link
Contributor Author

I've just made comments on the test because I suggest doing this PR in three pieces:

  1. Only commit the test to reflect the current behavior of the function (but not the changes to the function included in this PR).
  2. Commit a refactor to the function that behaves exactly as the old function did - confirmed by the test committed in 1
  3. Commit changes to the refactor that fix the bugs discovered by the test.

This PR combines 1 and 2 - I suggest splitting it into two PRs.

Of the comments I made here, only the ones relevant to the actual test file (one typo, one place where I think a test is missing) should be updated in this PR. The others should wait for the third step where we fix the implementation.

Thanks for this!

So the idea is that if you return None, the synchronous commands will return GoalResponse.SUCCESS later on, as long as no other commands return GoalResponse.IN_PROGRESS or GoalResponse.FAILED. What I can do is revert the test refactor to the initial test that I wrote to capture the pre-refactor state of the function. In a follow up PR, I'll address the bugs and potentially refactor the tests so that they are more thorough.

@abaker-bdai abaker-bdai force-pushed the abaker/PN-68-refactor-_robot_command_goal_complete branch from 420164d to 1ab3556 Compare October 23, 2023 18:33
@jbarry-bdai
Copy link
Collaborator

I think we should commit the test first and separately from changes to spot ros2.

@abaker-bdai
Copy link
Contributor Author

@jbarry-bdai Now that #179 has been merged into this branch, this is ready for review/stamp.

Copy link
Collaborator

@jbarry-bdai jbarry-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all the way through but sending what I have so far.

spot_driver/spot_driver/spot_ros2.py Outdated Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
Copy link
Collaborator

@jbarry-bdai jbarry-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my only substantive comment is the confusion over _process functions not returning success.

spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Outdated Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Outdated Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Outdated Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
spot_driver/spot_driver/spot_ros2.py Outdated Show resolved Hide resolved
@abaker-bdai
Copy link
Contributor Author

@amessing-bdai so it would be easier to review, I added the new feedback statuses and updated the tests here: #204

def _robot_command_goal_complete(self, feedback: RobotCommandFeedback) -> GoalResponse:
if feedback is None:
# NOTE: it takes an iteration for the feedback to get set.
def _process_feedback_status(self, status: int) -> Optional[GoalResponse]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a little doc string on these functions to just say they return IN_PROGRESS, FAILURE, or NONE would be helpful

@jbarry-bdai jbarry-bdai merged commit 39f2a4a into main Dec 14, 2023
2 checks passed
@jbarry-bdai jbarry-bdai deleted the abaker/PN-68-refactor-_robot_command_goal_complete branch December 14, 2023 16:17
marlow-fawn pushed a commit to marlow-fawn/spot_ros2 that referenced this pull request Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants