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

Move boxes_overlap tests from obb_test to boxes_overlap_test #21546

Conversation

SeanCurtis-TRI
Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI commented Jun 7, 2024

This resolves a TODO in boxes_overlap.cc. The function is no longer implicitly tested by obb_test.cc, but tested directly.

Furthermore, the test is expanded to provide an affordance for visualizing the configurations (this helped in test authoring, clean up, and, I anticipate, future maintenance).

Relates to #21526


This change is Reviewable

@SeanCurtis-TRI
Copy link
Contributor Author

Note to reviewers. The commits are (currently) curated.

R1: This is a strict cut-and-paste. Code was lifted directly out of obb_test.cc and placed into boxes_overlap_test.cc without modification.
R2: These are the modifications that make the test run and update it for its OBB-less spelling.
R3: This provides a mechanism for visualizing the test scenarios. I'm open to this being frivolous. If we want to keep it, we should modify the test rules to include exercising the gflags to make sure they don't bitrot. Let me know what you think.

Copy link
Contributor Author

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

+@rpoyner-tri for feature review, please.

Reviewable status: LGTM missing from assignee rpoyner-tri(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

Copy link
Contributor

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

:lgtm: except the viz affordances, see below.

Reviewed 2 of 2 files at r1, 3 of 3 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: 1 unresolved discussion, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

a discussion (no related file):
My first several attempts to use the visualization controls failed. I'm not a fan of fixed-delay-time interfaces, I guess.

May I suggest you use the scheme we set up for a bunch of Russ's tests? See drake/common/maybe_pause_for_user.h and the various tests that use it.


Copy link
Contributor Author

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes

a discussion (no related file):

Previously, rpoyner-tri (Rick Poyner (rico)) wrote…

My first several attempts to use the visualization controls failed. I'm not a fan of fixed-delay-time interfaces, I guess.

May I suggest you use the scheme we set up for a bunch of Russ's tests? See drake/common/maybe_pause_for_user.h and the various tests that use it.

None of that worked for me. Believe me, I tried.

The weird timing affordance is the only thing I could do to get the test to stay alive long enough to get a visualizer browser window populated.

Perhaps the simplest solution is to nuke the visualization.


Copy link
Contributor

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

a discussion (no related file):

Previously, SeanCurtis-TRI (Sean Curtis) wrote…

None of that worked for me. Believe me, I tried.

The weird timing affordance is the only thing I could do to get the test to stay alive long enough to get a visualizer browser window populated.

Perhaps the simplest solution is to nuke the visualization.

Nuke is fine with me; now I'm distracted by the fact that all of those other test visualizations appear to broken. But that's not for this PR to worry about.


Copy link
Contributor Author

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

+@xuchenhan-tri for platform review, please.

Reviewable status: 1 unresolved discussion, LGTM missing from assignee xuchenhan-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

a discussion (no related file):

Previously, rpoyner-tri (Rick Poyner (rico)) wrote…

Nuke is fine with me; now I'm distracted by the fact that all of those other test visualizations appear to broken. But that's not for this PR to worry about.

I have an alternative; I actually read the documentation for MaybePauseForUser() and updated the instructions. PTAL.


Copy link
Contributor Author

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, LGTM missing from assignee xuchenhan-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

a discussion (no related file):

Previously, SeanCurtis-TRI (Sean Curtis) wrote…

I have an alternative; I actually read the documentation for MaybePauseForUser() and updated the instructions. PTAL.

BTW My note above about making sure we use the --visualize tag in CI may be incorrect. I don't think that's possible. C'est la vie.


Copy link
Contributor

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

linters are whingeing; I could not quite tell why.

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: LGTM missing from assignee xuchenhan-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @SeanCurtis-TRI)

@xuchenhan-tri xuchenhan-tri added the release notes: none This pull request should not be mentioned in the release notes label Jun 12, 2024
Copy link
Contributor

@xuchenhan-tri xuchenhan-tri left a comment

Choose a reason for hiding this comment

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

Platform :lgtm: pending linter failure and squashing commits.
+(release notes: none)

Reviewed 2 of 2 files at r1, 3 of 3 files at r2, 2 of 2 files at r4, 1 of 2 files at r5, all commit messages.
Reviewable status: 3 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @SeanCurtis-TRI)

a discussion (no related file):
minor, looks like the TODO in boxes_overlap.cc can now be retired.



geometry/proximity/test/boxes_overlap_test.cc line 145 at r5 (raw file):

}

class BoxesOverlapTest_ : public ::testing::Test {

Why the trailing underscore?


geometry/proximity/test/boxes_overlap_test.cc line 198 at r5 (raw file):

// 9 cases use the axes defined by the cross product of axes from Frame A and
// Frame B. We also test that it is robust for the case of parallel boxes.
TEST_F(BoxesOverlapTest_, AllCases) {

BTW, the test name ("AllCases") seems to suggest that the set of one test fixture is closed. In that case you could just use SetUp instead of SetUpTestSuites and get rid of all the static keywords.

Copy link
Contributor

@xuchenhan-tri xuchenhan-tri left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r5.
Reviewable status: 3 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @SeanCurtis-TRI)

Copy link
Contributor

@xuchenhan-tri xuchenhan-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @SeanCurtis-TRI)

a discussion (no related file):
The visualization code path should be somehow exercised in CI.


Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @SeanCurtis-TRI)

a discussion (no related file):

Previously, xuchenhan-tri wrote…

The visualization code path should be somehow exercised in CI.

Suggestion:

I imagine it's easy to only guard the "pause for user" under the visualization gflag. Making the Meshcat and publishing during the test is still even even if nobody is watching.

Or really, I don't know why we have a gflag at all. The maybe-pause-for-user is inert during CI testing.


Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @SeanCurtis-TRI)

a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Suggestion:

I imagine it's easy to only guard the "pause for user" under the visualization gflag. Making the Meshcat and publishing during the test is still even even if nobody is watching.

Or really, I don't know why we have a gflag at all. The maybe-pause-for-user is inert during CI testing.

... is still fine even if ...


@SeanCurtis-TRI SeanCurtis-TRI force-pushed the PR_refactor_obb_overlap_tests branch from 7816034 to a13a00d Compare June 13, 2024 18:13
The code in boxes_overlap.cc was indirectly tested in obb_test.cc.
Now boxes_overlap_test.cc takes the responsibility for testing
the code directly (and obb_test.cc has become that much simpler).

This also includes a tweak to MaybePauseForUser() to include an
optional prompt message. The prompt message only gets printed if
the pause is enabled.
@SeanCurtis-TRI SeanCurtis-TRI force-pushed the PR_refactor_obb_overlap_tests branch from a13a00d to b4e2414 Compare June 13, 2024 18:20
Copy link
Contributor Author

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Thanks.

One additional change for your eyes.

Reviewable status: 2 unresolved discussions

a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

... is still fine even if ...

I've removed the flag, shifted some documentation, and modified MaybePauseForUser to allow for user-defined prompt instructions that only get called if the pause is enabled.



geometry/proximity/test/boxes_overlap_test.cc line 145 at r5 (raw file):

Previously, xuchenhan-tri wrote…

Why the trailing underscore?

Done

It's simply one of life's great mysteries.


geometry/proximity/test/boxes_overlap_test.cc line 198 at r5 (raw file):

Previously, xuchenhan-tri wrote…

BTW, the test name ("AllCases") seems to suggest that the set of one test fixture is closed. In that case you could just use SetUp instead of SetUpTestSuites and get rid of all the static keywords.

I was planning on parameterizing them so that one could chose which case(s) they wanted to run. I think that's still a good idea, but I'm kicking it down the road. So, I'm inclined to leave it as is. However, I've added some documentation explaining the reasoning.

Copy link
Contributor

@xuchenhan-tri xuchenhan-tri left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r6, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees rpoyner-tri(platform),xuchenhan-tri(platform)

@SeanCurtis-TRI SeanCurtis-TRI merged commit 66be6c1 into RobotLocomotion:master Jun 13, 2024
9 checks passed
@SeanCurtis-TRI SeanCurtis-TRI deleted the PR_refactor_obb_overlap_tests branch June 13, 2024 20:52
joemasterjohn pushed a commit to joemasterjohn/drake that referenced this pull request Jul 1, 2024
The code in boxes_overlap.cc was indirectly tested in obb_test.cc.
Now boxes_overlap_test.cc takes the responsibility for testing
the code directly (and obb_test.cc has become that much simpler).

This also includes a tweak to MaybePauseForUser() to include an
optional prompt message. The prompt message only gets printed if
the pause is enabled.
RussTedrake pushed a commit to RussTedrake/drake that referenced this pull request Dec 15, 2024
The code in boxes_overlap.cc was indirectly tested in obb_test.cc.
Now boxes_overlap_test.cc takes the responsibility for testing
the code directly (and obb_test.cc has become that much simpler).

This also includes a tweak to MaybePauseForUser() to include an
optional prompt message. The prompt message only gets printed if
the pause is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: none This pull request should not be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants