turtlebot:adventures:sensing101_thetaerror
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
turtlebot:adventures:sensing101_thetaerror [2015/10/02 19:03] – pvela | turtlebot: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:// | + | The orientation estimate is published as a [[https:// |
- | 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. | + | 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. |
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}} = \text{}$$ | + | $$ z_{des} = e^{j \theta_{des}} = \cos(\theta_{des}) + j \sin(\theta_{des})$$ |
In python, one would use the [[https:// | In python, one would use the [[https:// | ||
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, | 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, | ||
- | $$z_{err} = z_{curr}^{-1} z_{des} = z_{des} / z_{curr},$$ | + | $$z_{err} = z_{curr}^{-1} z_{des} = z_{des} |
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. | + | The variable $z_{err}$ is the orientation error as a complex number. |
$$ \theta_{err} = \text{phase}(z_{err})$$ | $$ \theta_{err} = \text{phase}(z_{err})$$ | ||
- | which also happens to be a '' | + | which also happens to be a '' |
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 | ||
$$ \omega = k_{turn} \theta_{err}. $$ | $$ \omega = k_{turn} \theta_{err}. $$ | ||
Of course, in real life, this might lead to crazy-high control signals when executed on the Turtlebot. | Of course, in real life, this might lead to crazy-high control signals when executed on the Turtlebot. | ||
- | $$ \omega = \text{saturate}(\omega, | + | $$ \omega = \text{saturate}(\omega, |
- | which clips the control signal at a max value if it is too high relative to $\omega_{max}$ (or a min value if it is too low relative to $-\omega_max$. Python does not have a saturation function, so you'll have to code one up with '' | + | which clips the control signal at a max value if it is too high relative to $\omega_{max}$ (or a min value if it is too low relative to $-\omega_{max}$. Python does not have a saturation function, so you'll have to code one up with '' |
There are other ways to do this, but the above generalizes to when you have to do full 3D rotations, plus it also is compatible with more complicated nonlinear controllers for the Turtlebot. Thus, it is a simple version of more advanced nonlinear control strategies. | There are other ways to do this, but the above generalizes to when you have to do full 3D rotations, plus it also is compatible with more complicated nonlinear controllers for the Turtlebot. Thus, it is a simple version of more advanced nonlinear control strategies. |
turtlebot/adventures/sensing101_thetaerror.1443826992.txt.gz · Last modified: 2024/08/20 21:38 (external edit)