-
Notifications
You must be signed in to change notification settings - Fork 82
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
Use angle between quaternions in OrientationGoal? #31
Comments
Let me suggest an alternative. This takes a tolerance which defaults to 0.1 rad.
|
It might make sense in some cases to have the additional tolerance in rad though you would need some other objective to get a gradient in this area if you want to avoid the additional noise from the plateau.
Philipp investigated the different formulations for the OrientationGoal in depth when he benchmarked for his thesis and worked quite a bit to avoid trigonometic methods and taking roots.
In his benchmarks using the squared angle instead of the squared distance (with a 5ms timeout) yielded almost 3% less success rate for random UR5 targets because of the additional computational complexity.
From the [associated thesis](https://tams.informatik.uni-hamburg.de/publications/2017/MSc_Philipp_Ruppel.pdf):
Rotational distances between rotation quaternions can also be computed via the dot product. The angle between two normalized rotation quaternions is a = acos(Q1·Q2). A distance measure which does not require trigonometric operations can be defined as d = 1−(Q1·Q2). However, these methods can be less stable if the quaternions are not exactly normalized. For example, the dot product could become slightly larger than one, in which case the arcus cosine in the first formula would be undefined, and the second formula would compute a negative distance. Also, if denormalization of the quaternions is proportional to their magnitudes, the results could be inverted. For two zero-rotation quaternions, the result would be 0, but for slightly larger (proportinally denormalized) quaternions, the dot product could become larger than 1, and the result could become less than zero. This can be the case even for very small errors, since cos′(0) = 0 and limα→0acos(α)′=−∞. These issues are usually solved by explicitly normalizing the quaternions before computing the dot product. However, this would involve calculating computationally expensive square roots. Also, if the dot product is used as a distance measure, the gradient becomes zero if the angle between both quaternions is 180◦. If the minimum square distance is used instead, the gradient is always large if both quaternions are pointing away from each other, ensuring fast divergence away from incorrect solutions. This would also be the case if the square angle would be used, but computing the exact angle via trigonometry would be computationally more expensive.
That being said, if you deem the exact angular tolerance worth the lower performance you can still use it of course, but you might want to benchmark.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the orientation goal looks like this:
I don't know a ton about quaternions but this seems like a nonlinear function so it might behave kind of funky:
(getOrientation() - context.getLinkFrame().getOrientation()).length2()
Would it be better to use the angle between the quaternions? That would increase in a nice, linear fashion from 0 to pi.
https://math.stackexchange.com/a/90098/448782
The text was updated successfully, but these errors were encountered: