Differences between Quaternion integration methods












7












$begingroup$


I've implemented a Quaternion Kalman filter and i have the choice between multiple way to integrate angular velocities.
The goal is to predict futur orientation $q^{n+1}$ from current orientation $q^{n}$ and angular velocity $vec{r}$. During the time step $Delta_t$ separating $q^{n+1}$ from $q^{n}$, the angular velocity is said to be constant.



The first method transform angular velocity $vec{r}=[r_x r_y r_z]$ into a quaternion $q_r$ and multiply the result with the current orientation quaternion $q^n$ :



$$
q_r =(a,vec{v})\
a = cos{(frac{|vec{r}|Delta_t}{2})} \
vec{v}=sin{(frac{|vec{r}|Delta_t}{2})}frac{vec{r}}{|vec{r}|}\
q^{n+1}=q^{n}q_r
$$



The second method is based on the quaternion derivative formula :
$$
q_r =(0,vec{r})\
q^{n+1}=q^n+ Delta_t(frac{1}{2}q^nq_r)
$$



What are the fundamental differences between the two approach? What are their properties ?



I understand the second one is a simple Euler integration, a crude first order approximation assuming a fixed $q$ and $vec{r}$ during integration. At the end, we can possibly have $|q^{n+1}|$ different from unity so a normalization can be necessary. This kind of approach, based on the derivative, can easily be generalized to higher orders.



On the other hand, i don't know what the first approach really is. It doesn't require any normalization. In which aspect is it an approximation ? If this integration method a numeric approximation, what's its order ? Could a RK4 approximation be better ?



Here is a similar question asked on a programming thread. No clear answer was given.



Here is a patent relative to the first method : http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20080004113.pdf



Best,










share|cite|improve this question











$endgroup$

















    7












    $begingroup$


    I've implemented a Quaternion Kalman filter and i have the choice between multiple way to integrate angular velocities.
    The goal is to predict futur orientation $q^{n+1}$ from current orientation $q^{n}$ and angular velocity $vec{r}$. During the time step $Delta_t$ separating $q^{n+1}$ from $q^{n}$, the angular velocity is said to be constant.



    The first method transform angular velocity $vec{r}=[r_x r_y r_z]$ into a quaternion $q_r$ and multiply the result with the current orientation quaternion $q^n$ :



    $$
    q_r =(a,vec{v})\
    a = cos{(frac{|vec{r}|Delta_t}{2})} \
    vec{v}=sin{(frac{|vec{r}|Delta_t}{2})}frac{vec{r}}{|vec{r}|}\
    q^{n+1}=q^{n}q_r
    $$



    The second method is based on the quaternion derivative formula :
    $$
    q_r =(0,vec{r})\
    q^{n+1}=q^n+ Delta_t(frac{1}{2}q^nq_r)
    $$



    What are the fundamental differences between the two approach? What are their properties ?



    I understand the second one is a simple Euler integration, a crude first order approximation assuming a fixed $q$ and $vec{r}$ during integration. At the end, we can possibly have $|q^{n+1}|$ different from unity so a normalization can be necessary. This kind of approach, based on the derivative, can easily be generalized to higher orders.



    On the other hand, i don't know what the first approach really is. It doesn't require any normalization. In which aspect is it an approximation ? If this integration method a numeric approximation, what's its order ? Could a RK4 approximation be better ?



    Here is a similar question asked on a programming thread. No clear answer was given.



    Here is a patent relative to the first method : http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20080004113.pdf



    Best,










    share|cite|improve this question











    $endgroup$















      7












      7








      7


      5



      $begingroup$


      I've implemented a Quaternion Kalman filter and i have the choice between multiple way to integrate angular velocities.
      The goal is to predict futur orientation $q^{n+1}$ from current orientation $q^{n}$ and angular velocity $vec{r}$. During the time step $Delta_t$ separating $q^{n+1}$ from $q^{n}$, the angular velocity is said to be constant.



      The first method transform angular velocity $vec{r}=[r_x r_y r_z]$ into a quaternion $q_r$ and multiply the result with the current orientation quaternion $q^n$ :



      $$
      q_r =(a,vec{v})\
      a = cos{(frac{|vec{r}|Delta_t}{2})} \
      vec{v}=sin{(frac{|vec{r}|Delta_t}{2})}frac{vec{r}}{|vec{r}|}\
      q^{n+1}=q^{n}q_r
      $$



      The second method is based on the quaternion derivative formula :
      $$
      q_r =(0,vec{r})\
      q^{n+1}=q^n+ Delta_t(frac{1}{2}q^nq_r)
      $$



      What are the fundamental differences between the two approach? What are their properties ?



      I understand the second one is a simple Euler integration, a crude first order approximation assuming a fixed $q$ and $vec{r}$ during integration. At the end, we can possibly have $|q^{n+1}|$ different from unity so a normalization can be necessary. This kind of approach, based on the derivative, can easily be generalized to higher orders.



      On the other hand, i don't know what the first approach really is. It doesn't require any normalization. In which aspect is it an approximation ? If this integration method a numeric approximation, what's its order ? Could a RK4 approximation be better ?



      Here is a similar question asked on a programming thread. No clear answer was given.



      Here is a patent relative to the first method : http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20080004113.pdf



      Best,










      share|cite|improve this question











      $endgroup$




      I've implemented a Quaternion Kalman filter and i have the choice between multiple way to integrate angular velocities.
      The goal is to predict futur orientation $q^{n+1}$ from current orientation $q^{n}$ and angular velocity $vec{r}$. During the time step $Delta_t$ separating $q^{n+1}$ from $q^{n}$, the angular velocity is said to be constant.



      The first method transform angular velocity $vec{r}=[r_x r_y r_z]$ into a quaternion $q_r$ and multiply the result with the current orientation quaternion $q^n$ :



      $$
      q_r =(a,vec{v})\
      a = cos{(frac{|vec{r}|Delta_t}{2})} \
      vec{v}=sin{(frac{|vec{r}|Delta_t}{2})}frac{vec{r}}{|vec{r}|}\
      q^{n+1}=q^{n}q_r
      $$



      The second method is based on the quaternion derivative formula :
      $$
      q_r =(0,vec{r})\
      q^{n+1}=q^n+ Delta_t(frac{1}{2}q^nq_r)
      $$



      What are the fundamental differences between the two approach? What are their properties ?



      I understand the second one is a simple Euler integration, a crude first order approximation assuming a fixed $q$ and $vec{r}$ during integration. At the end, we can possibly have $|q^{n+1}|$ different from unity so a normalization can be necessary. This kind of approach, based on the derivative, can easily be generalized to higher orders.



      On the other hand, i don't know what the first approach really is. It doesn't require any normalization. In which aspect is it an approximation ? If this integration method a numeric approximation, what's its order ? Could a RK4 approximation be better ?



      Here is a similar question asked on a programming thread. No clear answer was given.



      Here is a patent relative to the first method : http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20080004113.pdf



      Best,







      integration quaternions bayesian-network kalman-filter runge-kutta-methods






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Apr 13 '17 at 12:18









      Community

      1




      1










      asked Mar 11 '16 at 14:36









      jcolafrancescojcolafrancesco

      613




      613






















          2 Answers
          2






          active

          oldest

          votes


















          0












          $begingroup$

          I can't say much about general approach, but I think I can explain what the first method is.



          When you calculate $q_r$, what you're actually calculating is the rotation undergone by the object with that angular velocity. |r⃗ |Δt is the angle rotated through (since r is degrees/sec or radians/sec). Then you are using that angle to make a quaternion in the standard way ($q = <cos(theta/2), sin(theta/2)*vec{v}$ > with $vec{v}$ being a unit vector).



          When you multiply $q$ by $q_r$, you are applying the rotation $q_r$ to the body that used to have the orientation $q$ (since multiplying by a quaternion applies that rotation). If your angular velocity is constant, then the result should be exact (because $q_r$ will be exactly the rotation undergone). if your angular velocity isn't constant, then it is an approximation.



          I'm not sure what is best to use, sorry.



          sources :
          http://www.cprogramming.com/tutorial/3d/quaternions.html, http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
            $endgroup$
            – Shailesh
            Aug 7 '16 at 18:14



















          0












          $begingroup$

          Method 1:
          As was pointed out the first method uses the angular velocity to calculate a difference-orientation $q_r$, which accumulated as a result of the contant angular velocity.
          This method is an Euler-approximation of the integral of the angular velocity!
          $$Delta alpha = |vec{r}| Delta_t$$
          is a first order approximation of this difference angle! In the next step this angle is transformed into the quaternion $q_r$ and then this difference rotaion is applied to the current rotation.



          The benefit is a correct integration for constant velocities.
          The drawback is a computational effor by using trigonometric functions.



          Method 2: Here, the calculations are ideal up until the derivative of the quaternion
          $$dot{q} = frac{1}{2} q_r , q $$
          which has no simplifications in it. Now at this (later) point you apply the approximations that 1) the angular velocity is constant and 2) that you can integrate this quaternion derivative by a first order method. You can easily use a higher order method for integrating this last equation, yes! RK4 is a valid choice.



          Conclusion: Both methods include a first order integration. However, the first one yields correct rotations for constant velocities and is affecting the norm of the quaternion less than the latter approach. However, using a higher order method I would prefer the second approach, since it is computationally more efficient. This is the main point of method 2! You can implement this on really cheap hardware with high speed even with fixed point arithmetics!






          share|cite|improve this answer









          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "69"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1693067%2fdifferences-between-quaternion-integration-methods%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0












            $begingroup$

            I can't say much about general approach, but I think I can explain what the first method is.



            When you calculate $q_r$, what you're actually calculating is the rotation undergone by the object with that angular velocity. |r⃗ |Δt is the angle rotated through (since r is degrees/sec or radians/sec). Then you are using that angle to make a quaternion in the standard way ($q = <cos(theta/2), sin(theta/2)*vec{v}$ > with $vec{v}$ being a unit vector).



            When you multiply $q$ by $q_r$, you are applying the rotation $q_r$ to the body that used to have the orientation $q$ (since multiplying by a quaternion applies that rotation). If your angular velocity is constant, then the result should be exact (because $q_r$ will be exactly the rotation undergone). if your angular velocity isn't constant, then it is an approximation.



            I'm not sure what is best to use, sorry.



            sources :
            http://www.cprogramming.com/tutorial/3d/quaternions.html, http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
              $endgroup$
              – Shailesh
              Aug 7 '16 at 18:14
















            0












            $begingroup$

            I can't say much about general approach, but I think I can explain what the first method is.



            When you calculate $q_r$, what you're actually calculating is the rotation undergone by the object with that angular velocity. |r⃗ |Δt is the angle rotated through (since r is degrees/sec or radians/sec). Then you are using that angle to make a quaternion in the standard way ($q = <cos(theta/2), sin(theta/2)*vec{v}$ > with $vec{v}$ being a unit vector).



            When you multiply $q$ by $q_r$, you are applying the rotation $q_r$ to the body that used to have the orientation $q$ (since multiplying by a quaternion applies that rotation). If your angular velocity is constant, then the result should be exact (because $q_r$ will be exactly the rotation undergone). if your angular velocity isn't constant, then it is an approximation.



            I'm not sure what is best to use, sorry.



            sources :
            http://www.cprogramming.com/tutorial/3d/quaternions.html, http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
              $endgroup$
              – Shailesh
              Aug 7 '16 at 18:14














            0












            0








            0





            $begingroup$

            I can't say much about general approach, but I think I can explain what the first method is.



            When you calculate $q_r$, what you're actually calculating is the rotation undergone by the object with that angular velocity. |r⃗ |Δt is the angle rotated through (since r is degrees/sec or radians/sec). Then you are using that angle to make a quaternion in the standard way ($q = <cos(theta/2), sin(theta/2)*vec{v}$ > with $vec{v}$ being a unit vector).



            When you multiply $q$ by $q_r$, you are applying the rotation $q_r$ to the body that used to have the orientation $q$ (since multiplying by a quaternion applies that rotation). If your angular velocity is constant, then the result should be exact (because $q_r$ will be exactly the rotation undergone). if your angular velocity isn't constant, then it is an approximation.



            I'm not sure what is best to use, sorry.



            sources :
            http://www.cprogramming.com/tutorial/3d/quaternions.html, http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/






            share|cite|improve this answer











            $endgroup$



            I can't say much about general approach, but I think I can explain what the first method is.



            When you calculate $q_r$, what you're actually calculating is the rotation undergone by the object with that angular velocity. |r⃗ |Δt is the angle rotated through (since r is degrees/sec or radians/sec). Then you are using that angle to make a quaternion in the standard way ($q = <cos(theta/2), sin(theta/2)*vec{v}$ > with $vec{v}$ being a unit vector).



            When you multiply $q$ by $q_r$, you are applying the rotation $q_r$ to the body that used to have the orientation $q$ (since multiplying by a quaternion applies that rotation). If your angular velocity is constant, then the result should be exact (because $q_r$ will be exactly the rotation undergone). if your angular velocity isn't constant, then it is an approximation.



            I'm not sure what is best to use, sorry.



            sources :
            http://www.cprogramming.com/tutorial/3d/quaternions.html, http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Aug 8 '16 at 20:41

























            answered Aug 7 '16 at 17:57









            michael bagherpourmichael bagherpour

            11




            11












            • $begingroup$
              Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
              $endgroup$
              – Shailesh
              Aug 7 '16 at 18:14


















            • $begingroup$
              Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
              $endgroup$
              – Shailesh
              Aug 7 '16 at 18:14
















            $begingroup$
            Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
            $endgroup$
            – Shailesh
            Aug 7 '16 at 18:14




            $begingroup$
            Since this question was asked 4 months ago, you could have just waited and given a comprehensive answer
            $endgroup$
            – Shailesh
            Aug 7 '16 at 18:14











            0












            $begingroup$

            Method 1:
            As was pointed out the first method uses the angular velocity to calculate a difference-orientation $q_r$, which accumulated as a result of the contant angular velocity.
            This method is an Euler-approximation of the integral of the angular velocity!
            $$Delta alpha = |vec{r}| Delta_t$$
            is a first order approximation of this difference angle! In the next step this angle is transformed into the quaternion $q_r$ and then this difference rotaion is applied to the current rotation.



            The benefit is a correct integration for constant velocities.
            The drawback is a computational effor by using trigonometric functions.



            Method 2: Here, the calculations are ideal up until the derivative of the quaternion
            $$dot{q} = frac{1}{2} q_r , q $$
            which has no simplifications in it. Now at this (later) point you apply the approximations that 1) the angular velocity is constant and 2) that you can integrate this quaternion derivative by a first order method. You can easily use a higher order method for integrating this last equation, yes! RK4 is a valid choice.



            Conclusion: Both methods include a first order integration. However, the first one yields correct rotations for constant velocities and is affecting the norm of the quaternion less than the latter approach. However, using a higher order method I would prefer the second approach, since it is computationally more efficient. This is the main point of method 2! You can implement this on really cheap hardware with high speed even with fixed point arithmetics!






            share|cite|improve this answer









            $endgroup$


















              0












              $begingroup$

              Method 1:
              As was pointed out the first method uses the angular velocity to calculate a difference-orientation $q_r$, which accumulated as a result of the contant angular velocity.
              This method is an Euler-approximation of the integral of the angular velocity!
              $$Delta alpha = |vec{r}| Delta_t$$
              is a first order approximation of this difference angle! In the next step this angle is transformed into the quaternion $q_r$ and then this difference rotaion is applied to the current rotation.



              The benefit is a correct integration for constant velocities.
              The drawback is a computational effor by using trigonometric functions.



              Method 2: Here, the calculations are ideal up until the derivative of the quaternion
              $$dot{q} = frac{1}{2} q_r , q $$
              which has no simplifications in it. Now at this (later) point you apply the approximations that 1) the angular velocity is constant and 2) that you can integrate this quaternion derivative by a first order method. You can easily use a higher order method for integrating this last equation, yes! RK4 is a valid choice.



              Conclusion: Both methods include a first order integration. However, the first one yields correct rotations for constant velocities and is affecting the norm of the quaternion less than the latter approach. However, using a higher order method I would prefer the second approach, since it is computationally more efficient. This is the main point of method 2! You can implement this on really cheap hardware with high speed even with fixed point arithmetics!






              share|cite|improve this answer









              $endgroup$
















                0












                0








                0





                $begingroup$

                Method 1:
                As was pointed out the first method uses the angular velocity to calculate a difference-orientation $q_r$, which accumulated as a result of the contant angular velocity.
                This method is an Euler-approximation of the integral of the angular velocity!
                $$Delta alpha = |vec{r}| Delta_t$$
                is a first order approximation of this difference angle! In the next step this angle is transformed into the quaternion $q_r$ and then this difference rotaion is applied to the current rotation.



                The benefit is a correct integration for constant velocities.
                The drawback is a computational effor by using trigonometric functions.



                Method 2: Here, the calculations are ideal up until the derivative of the quaternion
                $$dot{q} = frac{1}{2} q_r , q $$
                which has no simplifications in it. Now at this (later) point you apply the approximations that 1) the angular velocity is constant and 2) that you can integrate this quaternion derivative by a first order method. You can easily use a higher order method for integrating this last equation, yes! RK4 is a valid choice.



                Conclusion: Both methods include a first order integration. However, the first one yields correct rotations for constant velocities and is affecting the norm of the quaternion less than the latter approach. However, using a higher order method I would prefer the second approach, since it is computationally more efficient. This is the main point of method 2! You can implement this on really cheap hardware with high speed even with fixed point arithmetics!






                share|cite|improve this answer









                $endgroup$



                Method 1:
                As was pointed out the first method uses the angular velocity to calculate a difference-orientation $q_r$, which accumulated as a result of the contant angular velocity.
                This method is an Euler-approximation of the integral of the angular velocity!
                $$Delta alpha = |vec{r}| Delta_t$$
                is a first order approximation of this difference angle! In the next step this angle is transformed into the quaternion $q_r$ and then this difference rotaion is applied to the current rotation.



                The benefit is a correct integration for constant velocities.
                The drawback is a computational effor by using trigonometric functions.



                Method 2: Here, the calculations are ideal up until the derivative of the quaternion
                $$dot{q} = frac{1}{2} q_r , q $$
                which has no simplifications in it. Now at this (later) point you apply the approximations that 1) the angular velocity is constant and 2) that you can integrate this quaternion derivative by a first order method. You can easily use a higher order method for integrating this last equation, yes! RK4 is a valid choice.



                Conclusion: Both methods include a first order integration. However, the first one yields correct rotations for constant velocities and is affecting the norm of the quaternion less than the latter approach. However, using a higher order method I would prefer the second approach, since it is computationally more efficient. This is the main point of method 2! You can implement this on really cheap hardware with high speed even with fixed point arithmetics!







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Jun 8 '18 at 10:46









                mikemike

                304214




                304214






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1693067%2fdifferences-between-quaternion-integration-methods%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Redirect URL with Chrome Remote Debugging Android Devices

                    Dieringhausen