-
Notifications
You must be signed in to change notification settings - Fork 935
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
Fix orientation constraints failing on satisfied configurations #2434
Fix orientation constraints failing on satisfied configurations #2434
Conversation
…on to check if the constraint is satisfied
@JeroenDM this is relevant for you, too. |
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.
This is some nice detective work, @JafarAbdi!
@JafarAbdi Wow, thank you for figuring this out! Since #2414 was merged my tests for #2402 failed. I suspect you also found the solution to my problem :) |
ad5d69f
to
2c703b9
Compare
2c703b9
to
d3b5147
Compare
Codecov Report
@@ Coverage Diff @@
## master #2434 +/- ##
==========================================
- Coverage 60.47% 60.30% -0.16%
==========================================
Files 351 351
Lines 26434 26452 +18
==========================================
- Hits 15982 15949 -33
- Misses 10452 10503 +51
Continue to review full report at Codecov.
|
+1 For explicitly handling and explaining the singular case, great work! @JafarAbdi I was thinking the following case could maybe surprise some users:
Is this a correct interpretation? Edit: |
Sorry, I missed this comment, I'm okay with adding them here, or if you prefer I could open my PR against your branch to merge them together |
As you can see in the image below given the tolerances this should pass, I added it as a test case Also, I forgot to mention that in the last commits I reverted my previous approach and used the error rotation matrix to check for tolerances since it's easier to handle singularities |
Co-authored-by: Jeroen <jeroendemaeyer@live.be>
robot_state.update(); | ||
EXPECT_TRUE(oc.configure(ocm, tf)); | ||
EXPECT_FALSE(oc.decide(robot_state).satisfied); | ||
|
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.
// In the non-singular case the absolute_x_axis_tolerance is not violated | |
robot_state.setVariablePositions(getJointValues(0.0, boost::math::constants::half_pi<double>() - 0.01, 0.21)); | |
robot_state.update(); | |
EXPECT_TRUE(oc.configure(ocm, tf)); | |
EXPECT_TRUE(oc.decide(robot_state).satisfied); | |
Ah, ok, now I understand it :) I glanced over that change :s
Given you already wrote extensive tests now, I don't' think my other tests would add value here. I will just extend your test file for the new parameterization once this is merged. |
ocm.weight = 1.0; | ||
|
||
moveit::core::RobotState robot_state(robot_model_); | ||
// Singularity: roll + yaw = theta |
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.
// Singularity: roll + yaw = theta | |
// Singularity: roll - yaw = theta |
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.
Because the tests below use -pi / 2.
Also, next time I will properly organize my comments in a review... sorry. |
I just want to make sure you have especially tested several values around pitch = pi/2. That's where singularities occur for the Euler angle roll/pitch/yaw convention, I believe. See here, page 13. |
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.
Overall I think a better way to do this would be to convert to a rotation vector because it is unique and does not have singularities.
Never mind, that doesn't help because orientation constraints are specified in RPY.
Looks good to me!
@@ -58,6 +58,58 @@ static double normalizeAngle(double angle) | |||
return v; | |||
} | |||
|
|||
// Normalizes an angle to the interval [-pi, +pi] and then take the absolute value | |||
// The returned values will be in the following range [0, +pi] |
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.
Minor correction, just to get the order of operations straight:
// Normalizes the absolute value of an angle to [0, +pi]
// Returned values will be in the range [0, +pi]
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 reasonable. Will fix #2449 as well.
However, there is a failing (ikfast) test here. Not sure that is related. I retriggered Travis.
Let's run CI one more time |
This comment has been minimized.
This comment has been minimized.
I should have squash-merged :/ |
* Add tests that trigger the bug * Use the angle differece between the desired and the current orientation to check if the constraint is satisfied * Handle singularities
Yes, indeed. I cleaned up and force-pushed. Please update your devel branches @tylerjw, @AndyZe, @JafarAbdi. |
@AndyZe: You pushed a branch |
done! |
Description
After applying the following fix #2414 a pipeline I’m working on isn’t working anymore (with a bunch of errors about constraints not statisfied one of them is
ros.moveit_planners_ompl.constrained_goal_sampler: More than 80% of the sampled goal states fail to satisfy the constraints imposed on the goal sampler. Is the constrained sampler working correctly?
)The reason is, right now we're calculating the error rotation matrix and call eulerAngles from Eigen to find the angles’ errors which return them in the following ranges
[0:pi]x[-pi:pi]x[-pi:pi]
(link)The issues are
1- As shown in the first test, despite the error is 1.57rad around Z-axis, eulerAngles will return x=3.139981, y=3.139841, z=1.570810 causing the constraint to fail
2- Another example in the second test
0.15, -pi/2, 0.15
eulerAngles will return3.05343, -1.5708, 3.05343
which again will cause the constraint to fail (link)3- This function isn’t stable around the identity rotation link#1 and link#2
Even if we use the function fromunsupported/Eigen
it will cause similar problems but in different orientations for example if the error rotation matrix correspond to pure rotation about Y with angles bigger than pi/2 the returned roll/yaw angles will cause a satisfied constraint to fails againTo fix this I used the Euler angles of the desired and the current orientations to find the angles’ errorsTo fix this I did copy the implementation from unsupported/Eigen/EulerSystem.h since it’s not released yet which will return the angles in the following ranges
[-pi:pi]x[-pi/2:pi/2]x[-pi:pi]
and handled the singularities differently when we compare the error with the tolerancesTODO: I need to add more tests before merging thisChecklist