-
Notifications
You must be signed in to change notification settings - Fork 246
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
Improve Randomization #68
Comments
Hi Quiang, thanks for pointing this out and for having taken the time to produce this example. Indeed, our sampling method is not good. We started using it in dummy tests and never improved it. We will implement a proper algorithm soon, based on http://planning.cs.uiuc.edu/node198.html. |
Hi Joan. I made a small mistake before. Matlab quaternion is of the form q = [w x y z], rather than q = [x y z w].
However, the result was still not good: Besides, I tested the algorithm of Eigen::Quaterniond::unitRandom(), which is based on http://planning.cs.uiuc.edu/node198.html. This is the result: Finally, I tested the algorithm of Sophus::SO3d::sampleUniform(), which firstly uniformly sample a point on a sphere (unit rotation axis), then uniformly sample rotation angle (but it wrap the angle to [0,pi]). This is the result: I'm not sure which would be better. |
Hello Quiang, I would say Sophus is doing the right thing. We have not yet investigated this issue fully. However, in http://planning.cs.uiuc.edu/node198.html Eq. 5.15, which of the entries did you take as the real part? In my opinion it must be the last one, since it contains a cosinus. But I talk open-loop. |
For http://planning.cs.uiuc.edu/node198.html, the quaternion is in the form of [w, x, y, z], in other word, the first element is the real part. (I find the quaternion definition in http://planning.cs.uiuc.edu/node151.html#12337). This is the Eigen's realization: unitRandom(). (constructor: Eigen::Quaterniond(w, x, y, z)) |
From reading this and this, the Shoemake's algorithm in http://planning.cs.uiuc.edu/node198.html seems to provide uniformly distributed x, y, z components of two randomly-rotated vectors. I tried myself and I seem to agree that the results are indeed uniform. Are you certain on your results for this algorithm? I could not try myself yet. EDIT: I tried. You are right. However, look at my next comment. |
The interpretation of "uniformity" in http://planning.cs.uiuc.edu/node198.html is provided by the Haar measure, which essentially determines that, if The same can be applied to quaternions (We'd have Overall, I find this rather convincing. Moreover, since Sophus deviates from this, it is not respecting the Haar measure condition. Intuitively, it seems that once you have chosen an axis, then you have to chose an angle, and that they are unrelated. However, if you do the opposite, ie you first choose an angle and then the axis, you see that angular uniformity makes little sense: take two small angles separated by a small amount. Take two random axes. The two rotations will be separated by a small angle no matter the axes. Now take two large angles, separated by the same small amount. Take two random axes: in general, the final rotations will be separated by a large angle, since the rotations are large and the axes very different. Therefore, the distribution of angles must have low density at small angles, and this is what you observe in http://planning.cs.uiuc.edu/node198.html. |
You are right. Close this issue. |
Reopen till fix arrives. Fixing involves non-trivial work on the specialization of the Random() function. |
Manif uses random tangent space element and expMap to generate a random Lie group element:
setRandom
coeffs_nonconst() = Tangent::Random().exp().coeffs()
This is not a good idea. Because uniform distribution of tangent space may not lead to uniform distribution of Lie group.
I used the following code to test the Random() function in SO(3) by generating 10000 random elements:
and plotted the axis distribution (on a unit sphere) and angle distribution (with a histogram) in Matlab:
The Random() function cannot generate uniformly distributed SO3 elements.
The text was updated successfully, but these errors were encountered: