-
Notifications
You must be signed in to change notification settings - Fork 938
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
Constraint samplers with seed #3112
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3112 +/- ##
==========================================
- Coverage 61.60% 61.58% -0.02%
==========================================
Files 376 376
Lines 33309 33317 +8
==========================================
- Hits 20518 20516 -2
- Misses 12791 12801 +10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution. Please adjust your code for a minimal changeset. The comments provided for JointConstraintSampler apply to IKConstraintSampler as well.
int rng_seed; | ||
if (ros::param::get("~constraint_sampler_random_seed", rng_seed)) | ||
{ | ||
ROS_WARN_STREAM_NAMED("constraint_samplers", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you decided for a warning here? This is an info at most, preferably a debug message, isn't it?
ROS_WARN_STREAM_NAMED("constraint_samplers", | |
ROS_INFO_STREAM_NAMED("constraint_samplers", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I had a bias from a production view. Generally, debug messages are not enabled in normal runs, which may cause this to slip away from the eyes. Anyways a simple rosparam lookup would still give the information needed, thus reducing to debug 👍🏼
if (ros::param::get("~constraint_sampler_random_seed", rng_seed)) | ||
{ | ||
ROS_WARN_STREAM_NAMED("constraint_samplers", | ||
"Creating random number generator with seed " << std::to_string(rng_seed)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to convert the int to a string. The streaming operator supports int.
"Creating random number generator with seed " << std::to_string(rng_seed)); | |
"Creating random number generator with seed " << rng_seed); |
...it_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h
Outdated
Show resolved
Hide resolved
...it_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h
Outdated
Show resolved
Hide resolved
@@ -191,7 +203,8 @@ class JointConstraintSampler : public ConstraintSampler | |||
|
|||
void clear() override; | |||
|
|||
random_numbers::RandomNumberGenerator random_number_generator_; /**< \brief Random number generator used to sample */ | |||
std::unique_ptr<random_numbers::RandomNumberGenerator> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to change API? Please revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, random_number_generator_
gets default constructed and the assignment operator of random_numbers::RandomNumberGenerator
is deleted, hence I can't do the following:
random_number_generator_ =random_numbers::RandomNumberGenerator(rng_seed);
This way it enables us to construct it once. This API change is thus necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nicer if you explain why you disagree @v4hn. I'm genuinely curious about how this can be done without API* change.
*random_number_generator_
is fully internal, so it is not an API. This change will have zero effects from the users' perspective. (unless they are using a compute-board that has very limited heap access)
@rhaschke I wanted this capability for both constraint samplers as |
29a2c4f
to
9cb0edc
Compare
Added IKConstraintSampler test. |
9cb0edc
to
2d4a092
Compare
@rhaschke PTAL 🙏🏼 |
@v4hn Please have a look. As time passes, it becomes much more difficult to contribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good after addressing the open issues.
Determinism is sure important! (and sadly by design MoveIt cannot give a lot of that)
...it_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h
Outdated
Show resolved
Hide resolved
...it_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tahsinkose, looks like your new tests are never finishing.
Could you please have another look and fix them?
@rhaschke I just checked. The parameter server manipulation inevitably led to the existence of ROS master, hence the test needed to be updated to be a rostest. PTAL 🙏🏼 |
3c2ab31
to
ea5fc24
Compare
add_rostest_gtest(test_constraint_samplers | ||
test/constraint_samplers.test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhaschke This seems like an unorthodox addition to moveit_core
as I didn't see any instances of rostest
in the package. I guess all rostest
tests are categorized strictly differently than unit tests according to MoveIt conventions, but that's just a hunch regarding the status quo.
If you think this is a serious violation, then I need to move the newly added tests to a convenient place in moveit_ros
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v4hn, could you review as well and comment on this point? IMO, moveit_core
isn't ROS-agnostic for a while already, e.g. using ROS logging in a few places. However, ROS parameters are actually not yet used in moveit_core
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fully agree. If we allow ros parameters here (and we seem to agree we want to do so) then we also need to allow tests for them, so both reading the param as well as adding the ros test are fine by me.
Maybe the ros2 sync will split it out into a separate framework structure, but for this repo I will just merge this as is now.
ea5fc24
to
3f0eb04
Compare
The failing checks seem to be related with https://github.blog/2022-04-12-git-security-vulnerability-announced/. Also see actions/checkout#760 |
Hi @tylerjw,
The problem only arises if the (upstream) cache was restored. |
Closing and reopening to trigger CI. |
@tahsinkose, could you please rebase this onto the latest master (which has fixed CI). |
if the user allowed edits by maintainers I believe you can simply force-push to their PR branch. I wouldn't know how else I would have done that. |
No, that doesn't work. So, @tahsinkose, please rebase yourself. Thanks. |
42b6a2e
to
52d8387
Compare
Rebased @rhaschke 👍🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests pass now. Thanks.
Thanks for your patience with this @tahsinkose 👍 |
No worries @v4hn I got used to the elaborate review process of MoveIt maintainers 😝 |
I'm not sure that's a good thing. ;) But we are volunteers after all 😛 |
Maybe just bad luck. The tests passed in this PR, not sure why they would fail in upstream 🤔 |
Looks like the test is flaky (a manually triggered second run succeeded). @tahsinkose, could you please have another look and make the test more robust? |
It seems, when the true randomness is restored with rosparam deletion, it starts to be flaky 😄 Adding a different seed for the 3rd sampler should solve this issue @rhaschke. |
Description
This PR adds the ability to specify a seed for constraint samplers through the parameter server, which would be useful in deterministic testing and benchmarking of these objects.
Checklist