Added support for "large limits"#16
Merged
tfoote merged 6 commits intoros:masterfrom Oct 28, 2019
Merged
Conversation
tfoote
requested changes
Oct 17, 2019
Member
tfoote
left a comment
There was a problem hiding this comment.
Thanks for the contribution. Adding support for multiple turn joints makes sense for the use cases that need that. I think that keeping that semantically separate from the existing API is important though. Please see my inline notes.
tfoote
requested changes
Oct 22, 2019
Contributor
Author
|
I followed the reviews and now the changes are limited to the new function and its related tests. I finally added the same function also in the python API for consistency and included the relevant tests. |
tfoote
approved these changes
Oct 28, 2019
Member
tfoote
left a comment
There was a problem hiding this comment.
Thanks for the updates this looks good.
Contributor
Author
|
Thanks to you for the review! |
tfoote
pushed a commit
that referenced
this pull request
Jan 9, 2020
* Added support for "large limits" * shortest_angle_with_large_limits in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes a new function to deal with shortest angle calculations in presence of "large limits", i.e., when either
left_limitorright_limitare outside the range[ -pi , pi ].Motivating example
While using the
effort_controllers/JointGroupPositionController, I experienced an issue similar to #2. In my specific case, a call toshortest_angular_distance_with_limitswas performed with:the function returned
false, and the angle was evaluated to-6.282692. This is not really an error, since it is written in the documentation that limits are supposed to be within-piand+piand in addition the function returnedfalse. However, the validity of the limits is not checked insideshortest_angular_distance_with_limits, and thus it's user's responsibility to make sure that such calls are not performed.I however think that having
shortest_angular_distance_with_limitsto work with bounds in[ -pi , pi ]is a strong limitation. I am aware that having limits in a range such as[ -20*pi , 20*pi ]for a revolute joint is uncommon and that a continuous joint would solve the issue without posing many limitations. Nonetheless, I think it would be more robust to explicitly add support for "large limits".Proposed solution
I implemented the function
shortest_angular_distance_with_large_limits, which is supposed to work with bounds larger thanpi.The main difference with
shortest_angular_distance_with_limitsis that it does not allow "reversed bounds" such as[ 0.75*pi , -0.75*pi ]. Reverse bounds make sense in the unit circle where the rotationx+2*piis considered exactly the same asx. However, I believe the same should not be true when considering larger bounds, and my function thus requiresleft_limit < right_limit.The goal of the function is to return the smallest angle
xsuch thatfmod(from+x, 2*pi)equalsfmod(to, 2*pi)also ensuring thatleft_limit <= from+x <= right_limit. Note thattodoes not need to be in the valid interval. As an example,shortest_angular_distance_with_limits(0, 0.5*pi, -2*pi, 2*pi, sa)will returntruewithsa=0.5*pi, whileshortest_angular_distance_with_limits(0, 0.5*pi, -2*pi, 0.1*pi, sa)will returntruewithsa=-1.5*pi(since0.5*piis larger thanright_limit).I propose to let
shortest_angular_distance_with_limitsautomatically call the new function whenever a bound is larger thanpi(in magnitude). Since I know this might break back-compatibility in many ways, I am open to alternative solutions!Minor changes
pthreadflag in angles/test/CMakeLists.txt - I had linker errors while building the tests, and followed what reported in gtest's wiki page