Skip to content
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

Quaternion weights vs Euler Angles weights? #15

Open
passer-by-Wang opened this issue Mar 29, 2024 · 1 comment
Open

Quaternion weights vs Euler Angles weights? #15

passer-by-Wang opened this issue Mar 29, 2024 · 1 comment

Comments

@passer-by-Wang
Copy link

Hello, I am very happy to try ungar library. It is amazing how efficient it is in solving optimization problems and how concise it is in constructing problems. But I have encountered a small problem now. This problem was discovered when I looked at the MPC case of the quadruped robot example. That is, among the weight of each component in the cost function, the weight of the quaternion seems to be a coupled vector, because quaternion is not intuitive for human. On the contrary, euler angles are relatively intuitive. For example, suppose I have a weight vector that costs Euler angles' error. But in order to achieve the same control effect, how do I obtain the corresponding quaternion weight? In other words, how do I adjust the weight of the quaternion to control the change of the Euler angle? Because the change of euler angles is more observable rather than quaternion. I would be grateful if you could give me some help on this issue.

@fdevinc
Copy link
Owner

fdevinc commented Apr 3, 2024

Hi @passer-by-Wang, thanks for your words and for reaching out! I hope my answer does not come too late! The orientation tracking error in the example is implemented following this paper (eq. 18). It is a pseudometric on the unit quaternions, but a metric on 3D rotations. Unfortunately, the paper does not delve into the effects of weight matrices for assigning different importance to the various components of a rotation; you may want to give this approach a try and see if things work. Alternatively, you could use the function Utils::QuaternionToYawPitchRoll and apply a different weight to the various components of the yaw-pitch-roll (YPR) representation. Beware that this method might give you numerical issues due to the great nonlinearity you would be introducing in the cost function. This would be easily solved by convexifying the Hessian of the corresponding cost terms, but Ungar's optimizer is not mature enough to provide such flexibility and you would have to modify it yourself.

A final option for you would be to have your controller to track three different unit quaternions: one each for yaw, pitch, and roll. Then, you could add a different weight to each tracking term to prioritize one dimension or another. This solution is likely the easiest to implement, so I would try it first. Please let me know if you need further assistance or clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants