-
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
Check for empty quaternion message when processing CollisionObjects #2089
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2089 +/- ##
==========================================
+ Coverage 54.08% 54.53% +0.45%
==========================================
Files 319 328 +9
Lines 24997 25661 +664
==========================================
+ Hits 13519 13995 +476
- Misses 11478 11666 +188
Continue to review full report at Codecov.
|
Thank you for taking the initiative! I believe we had partial patches for this around already, but I can't find the corresponding request or issue right now... I am not happy with your method to resolve this though. |
It is kind of common practice in ROS to consider uninitialized quaternions as identity, e.g. in rviz: |
I am aware of that but not happy with it at all 😞 |
This does add extra code in the case where the user did the right thing and didn't give us something invalid. My pain (and other beginner users) over this comes from two places. The first is nearly useless errors in FCL when used on Kinetic and even worse, it silently somehow doesn't complain when using Melodic. The second is that I got here by copy-pasting from our tutorials (I will offer a PR to fix that shortly). Ideally, we'd fix this upstream with default construction of values in ROS messages, which is something we have with ROS2 so hopefully as people migrate it won't matter and this is just one more case of us having to implement something downstream that should have been done upstream at compile time in the messages. As to what the default construction value should be. I don't know enough about quaternions and if {0,0,0,0} would ever actually be valid and therefore we shouldn't stop that from being tested. If we want to be even safer we should probably test for anything that'd cause a math exception on division (nan, inf) too, but I don't think we should try to save users who give us quaternions with values set to nan. Do you propose we set the default quaternion to something other than identity? Maybe {1, 0, 0, 0} is more reasonable, or {1, 1, 1, 1} since we normalize it after all? We could require users to give us normalized quaternions and call abort if they didn't, that would be more performant and would fail sooner which would make it much easier to debug when the user does something invalid. That might make some users more grumpy because we stopped holding their hands by calling normalize ourselves. In the end, thank you for merging this. I hope it saves someone else in the future from copy-pasting from our own tutorials and being greeted by an assert at runtime. 🥇 |
@tylerjw, ROS1 message system will not change anymore. So we need to work with such fixes. |
There is actually some support for adding constructors and other functionality to messages. |
Interesting to know, but this approach doesn't generalize across all supported languages:
|
Adding some convenience constructors to message header does not break compatibility. Other languages will simply not get those conveniences. |
You are right. What I meant is that users will have a different experience across languages and that's probably nothing we should support. |
Description
To avoid issues like the one @tylerjw encountered in #2031, I think we should check for empty quaternions when adding objects to the scene. This is a lightweight operation compared to the
normalize
that we already apply to every message, so it seems reasonable to me. Please share your opinion.Fundamentally this is only an issue because ROS quaternion messages default to an invalid value, but that's neither here nor there.
I'll run clang-format etc. when I am at my home machine.
Checklist