-
Notifications
You must be signed in to change notification settings - Fork 45
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
Added support for "large limits" #16
Conversation
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 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.
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. |
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 the updates this looks good.
Thanks to you for the review! |
* Added support for "large limits" * shortest_angle_with_large_limits in python
This PR proposes a new function to deal with shortest angle calculations in presence of "large limits", i.e., when either
left_limit
orright_limit
are 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_limits
was 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-pi
and+pi
and 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_limits
to 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_limits
is 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*pi
is 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
x
such thatfmod(from+x, 2*pi)
equalsfmod(to, 2*pi)
also ensuring thatleft_limit <= from+x <= right_limit
. Note thatto
does 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 returntrue
withsa=0.5*pi
, whileshortest_angular_distance_with_limits(0, 0.5*pi, -2*pi, 0.1*pi, sa)
will returntrue
withsa=-1.5*pi
(since0.5*pi
is larger thanright_limit
).I propose to let
shortest_angular_distance_with_limits
automatically 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
pthread
flag in angles/test/CMakeLists.txt - I had linker errors while building the tests, and followed what reported in gtest's wiki page