User Tools

Site Tools


turtlebot:adventures:sensing101_thetaerror

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
turtlebot:adventures:sensing101_thetaerror [2015/10/05 14:34] pvelaturtlebot:adventures:sensing101_thetaerror [2024/08/20 21:38] (current) – external edit 127.0.0.1
Line 1: Line 1:
-The orientation estimate is published as a [[https://en.wikipedia.org/wiki/Quaternion|quaternion]] for the Turtlebot.  However, the turtlebot is a planar creature, so the full quaternion is never used.  What parts are used?+The orientation estimate is published as a [[https://en.wikipedia.org/wiki/Quaternion|quaternion]] for the Turtlebot.  However, the turtlebot is a planar creature, so the full quaternion is never used.  What parts are used? Which of the four values in the odometry quaternion correspond to the real value?  The other one would then be the complex value. Which is it?
  
-It turns out that these two parts used correspond to a planar quaternion, which is basically just a complex number $ z = x + jy$.  Be careful though because the quaternion version has half the phase.  When you unpack the quaternion into a complex number, be sure to square it first so that it has the correct phase. +It turns out that these two parts used correspond to a planar quaternion, which is basically just a complex number $ z = x + jy$.  Be careful though because the quaternion version has half the phase.  When you unpack the quaternion into a complex number, be sure to square it first so that it has the correct phase. Also make sure that you set the proper parts to be the real and the complex coordinates.
 OK, let's assume that you have a desired orientation that gets created as a complex number OK, let's assume that you have a desired orientation that gets created as a complex number
-$$ z_{des} = e^{j \theta_{des}} = \cos(\theta_{dsc}) + j \sin(\theta_{des})$$+$$ z_{des} = e^{j \theta_{des}} = \cos(\theta_{des}) + j \sin(\theta_{des})$$
 In python, one would use the [[https://docs.python.org/2/library/cmath.html|cmath]] package and the ''rect'' function to create the complex number.  Naturally, since only rotations are the concern, the magnitude should be 1 (to create a unit length complex number).  Basically $z_{des}$ lives on the unit circle, which makes it equivalent to an orientation. In python, one would use the [[https://docs.python.org/2/library/cmath.html|cmath]] package and the ''rect'' function to create the complex number.  Naturally, since only rotations are the concern, the magnitude should be 1 (to create a unit length complex number).  Basically $z_{des}$ lives on the unit circle, which makes it equivalent to an orientation.
  
 OK, now that we have $z_des$, and there is a callback function that unpacks the quaternion orientation into a complex number too, called $z_{curr}$ for the current orientation, we need to create the error function.  This is easily done via: OK, now that we have $z_des$, and there is a callback function that unpacks the quaternion orientation into a complex number too, called $z_{curr}$ for the current orientation, we need to create the error function.  This is easily done via:
-$$z_{err} = z_{curr}^{-1} z_{des} = z_{des} / z_{curr},$$+$$z_{err} = z_{curr}^{-1} z_{des} = z_{des} \,/\, z_{curr},$$
 where we took advantage of the fact that complex numbers behave more or less like scalar real number when performing multiplication by the inverse (e.g., performing division). where we took advantage of the fact that complex numbers behave more or less like scalar real number when performing multiplication by the inverse (e.g., performing division).
  
 The variable $z_{err}$ is the orientation error as a complex number.  To get the error in angular units, just recover the phase: The variable $z_{err}$ is the orientation error as a complex number.  To get the error in angular units, just recover the phase:
 $$ \theta_{err} = \text{phase}(z_{err})$$ $$ \theta_{err} = \text{phase}(z_{err})$$
-which also happens to be a ''cmath'' python command.+which also happens to be a ''cmath'' python command.  These units should be in radians which is compatible with the Turtlebots angular command inputs.
  
 The last step is to convert this error into a feedback controlled signal, which is done through a gain The last step is to convert this error into a feedback controlled signal, which is done through a gain
turtlebot/adventures/sensing101_thetaerror.1444070070.txt.gz · Last modified: 2024/08/20 21:38 (external edit)