Repository navigation
Added check for invalid quaternions. - #1167
Conversation
|
Thanks for pr, one of us will get to it asap. |
|
@wjwwood can this PR be merged? It's quite annoying to crash RViz because of this :) |
Apparently keeping "Willow Garage, Inc" (ros-visualization#1142) was not the right thing (ros-visualization#1113).
|
After reading #1113, I changed the copyright statement. |
dhood
left a comment
There was a problem hiding this comment.
Thank you for the patch, overall it looks good. Only one point of concern regarding the tolerance
|
|
||
| inline bool validateQuaternions( float w, float x, float y, float z ) | ||
| { | ||
| return std::abs( w * w + x * x + y * y + z * z - 1.0f ) < 10e-5f; |
There was a problem hiding this comment.
Was there a particular reason you switched to using 10e-5? If not, in tf2 they found the tolerance had to be relaxed it to 10e-3 (ros/geometry2@634fd0c), so please stick with 10e-3
There was a problem hiding this comment.
Not really, I just felt like 10e-3 was a bit too relaxed for my preferences but if empirical evidence proves me wrong, I'll change it back to 10e-3.
|
@ros-pull-request-builder retest this please |
|
I'm very happy that this might fix problems with IMs crashing RViz that wev'e seen. However, is there a reason why the patch couldn't just normalize the quaternion in place? |
|
Good question. |
|
Yes. It took me over an hour after upgrading my home desktop this morning to figure out why my Interactive Markers weren't showing up. It traced back to a bad Quaternion in an IM setup library (not written by me). The fix was trivial, but if you had enforced normalization here instead of checking, my code would have worked as "normal". If you took this to an extreme, you could just always normalize no matter what. Then you wouldn't have to use arbitrary thresholds for the magnitude like 10e-3 (unless that's a threshold that came from OGRE). Of course the issue here would be a minor slowdown to do 4 extra divides, but that's nothing really. |
|
@wjwwood I agree with @davetcoleman #1179 looks much more appropriate. If it’s zero then error otherwise just normalize. |
|
I guess it was actually @dhood that approved and merged the original PR. |
|
I didn't expect this change to impact so many users since quaternions really ought to be normalised (TF will reject them and roswtf will report them). From the number of responses here I can appreciate that it's simply not a reasonable expectation to make. I agree with @rhaschke's note in #1178 (comment) that there should have been a smoother transition phase rather than rejecting them, which I will look into ASAP |
|
First, I want to apologize that my PR caused this many issues. |
|
@StefanFabian This is more or less what I proposed in #1179 ;-) |
This reverts commit b329145.
* Revert "Added checks for invalid quaternions. (#1167)" This reverts commit b329145. * normalize invalid quaternions instead of rejecting them Normalization of quaternions usually is done by rviz::FrameManager::transform() which transforms a ROS pose into an Ogre position + orientation. Only in some rare cases, a ROS quaternion was directly used as an Ogre::Quaternion, which then requires handling of null quaternions (as they arise from uninitialized ROS pose msgs). * addressed Dave's comments * add more verbose warnings ... as suggested in #1182 * Revert "Revert "Added checks for invalid quaternions. (#1167)"" This reverts commit 42a4416. * Minimise diff * Warning will already be output for invalid quats when msg validated * Return pre-normalised length from normalizeQuat Don't mix logic for what is considered a valid quat into this function; matches Ogre * Use validateQuaternions for map Logic of what makes a quaternion valid isn't in normalizeQuaternion; also gets the invalid quaternion value logged to console * Remove unnecessary 0 setting * Reduce number of divisions
…ization#1167) The situation is complicated, but in versions of Ubuntu prior to Focal and versions of Debian prior to Bookworm, the name of the library was 'libfreetype6-dev'. Since Focal and Bookworm, the name of the library is 'libfreetype-dev'. While 'libfreetype-dev' provides a "virtual package" for 'libfreetype6-dev', we should really use the new canonical name. Further, there is currently a bug on ros_buildfarm where it doesn't properly deal with "virtual packages" like this. This is currently preventing this package from building on Ubuntu Noble. That bug is being worked on separately. Finally, I'll note that we already have a libfreetype-dev key in rosdep, so we just switch to using that here which should work around the bug on the buildfarm, and also use the correct canonical name going forward. Signed-off-by: Chris Lalancette <[email protected]>
Added checks for quaternions before passing them to OGRE to fix crashes due to unnormalized quaternions as described in #1142.