Posts

Showing posts with the label Drone theory

Filters - Theory

Image
 Filters  In this post, I want to present the theory needed for digital filter design. Firstly, a quick description of mainly used filters in the continuous domain - I want to give you some intuition in interpreting the transform functions. Next, I will present practical discretization from the '$s$' domain into the '$z$' (discrete time). Finally, a difference equation will be provided which can be directly programmed on any microprocessor. In a future post, I will show the possible implementation of described filters. In essence, the filter should block undesirable frequencies and let others pass through without distortion. For our applications, we can divide filters into 4 main categories: Low-pass filters High-pass filters Band-pass filters Notch filters Low-pass filter As the name suggests this filter allows low frequencies to pass and suppress high ones. The simplest LPF is a system with one pole: \begin{gather}H(s)=\frac{\omega_{0}}{s+\omega_{0}}\end{gather} A typ

Derivative of quaternion

Image
When I was searching for uses of quaternions in orientation algorithms, there was always one equation that was shown with no explanation:  \begin{gather}\dot{\mathbf{q}}(t)=\frac{1}{2}\boldsymbol{\omega}\mathbf{q}(t) \end{gather} but sometimes it was: \begin{gather}\dot{\mathbf{q}}(t)=-\frac{1}{2}\boldsymbol{\omega}\mathbf{q}(t) \end{gather} or \begin{gather}\dot{\mathbf{q}}(t)=-\frac{1}{2}\mathbf{q}(t) \boldsymbol{\omega}\end{gather} Moreover, when I was looking for any derivation of these formulas I found out that all resources were several pages - not very encouraging for me or derivations were not complete in their own calculations, which was even more frustrating when you were thinking that finally, you would understand this.  So, I decided to do it myself in 2 ways: first more based on quaternion interpretation and the second old-fashion derivative from the definition. Also, I will discuss frames of reference in which all of the elements are presented. I will provide some transfo

Quaternions as rotations in 3D

Just as a unit circle in the complex plane can be used to describe a rotation in one axis, quaternions using 3 imaginary numbers describe a rotation in 3 dimensions. According to Euler's rotation theorem , any complex rotation of any vector $\mathbf{p}\in \mathbb{R}^3$ about any axes can be replaced by a single rotation about the $\mathbf{v}=[v_x,v_y,v_z] $ by an angle $\theta$. Using quaternions, the rotation of a vector $\mathbf{p}$ can be represented by multiplication: \begin{equation}\mathbf{p}'=\mathbf{q}\mathbf{p}\mathbf{q}^{-1}=\mathbf{q}\mathbf{p}\mathbf{q}^*\label{eq:rotation}\end{equation} where vector $\mathbf{p}$ is treated as a pure quaternion - $\mathbf{p}= [0,p_x,p_y,p_z]$, and quaternion $\mathbf{q}$ in trygonmetric form is: \begin{equation}    \mathbf{q}=\cos{\frac{\theta}{2}}+[v_xi,v_yj,v_zk]\sin{\frac{\theta}{2}}\label{eq:trigonometric form written out}\end{equation} It can now be seen that the imaginary part of the quaternion can be treated as the vector def

Quaternions introduction

 Why quaternions? The quaternion notation is the least intuitive solution, but it has several advantages that make it very commonly used in many fields that deal with orientation in 3D space. First, however, the basic operations in the domain of quaternions as well as the assumptions made in the following chapters will be described. The main advantages will be seen in the next chapters, but this part is to give some awareness about quaternions properties used in the next operations. Although it is not necessary to understand quaternions up smallest detail, in my opinion, it is really pleasant to know how some mathematics, used in projects works. Also, I hope that this presentation of quaternions (of course not complete and probably fully correct in math rigor) will be more approachable for non-mathematicians. What are quaternions? Quaternions are just extensions of complex numbers.They have Real part - $Re(\mathbf{q})$ and Imaginary part - $Im(\mathbf{q})$ but instead of 1, there are 3

Transformation matrix

Image
The transformation matrix is a much wider concept but for purpose of orientation in 3D space, we will restrict it into a rotation matrix. So transformation matrix transform (wow) any vector from one reference frame in the other: \begin{gather} \mathbf{v}^{(0)}=\mathbf{R}_{1}^{0}\mathbf{v}^{(1)} \end{gather} Rotation matrix rotate any vector about a specific axis and about a set angle (in this example rotation of vector $\mathbf{v}=\left[\begin{array}{ccc} 1,1,1\end{array}\right]^T$ about $90^{\circ}$  in Z-axis): \begin{gather}\mathbf{v'=\mathbf{R}_z(90^{\circ})\mathbf{v}}=\left[\begin{array}{ccc} 0 & -1 & 0\\ 1 & 0 & 0\\    0 & 0 & 1   \end{array}\right]    \left[\begin{array}{c}1\\1\\1    \end{array}\right]=     \left[\begin{array}{c}      -1\\    1\\    1    \end{array}\right]\end{gather} It is important to see the difference between the transformation of a vector between references frames and the rotation of a vector. These two are related to each other

Euler angles or Tait-Bryan angles or yaw-pitch-roll?

Image
The most intuitive way to describe orientation is through Euler angles. The 3 angles tell about successive rotations about fixed axes. In these free rotations, you can achieve any orientation from every other. There are 12 possible combinations of these rotations. In 6 of them the first and third rotation is performed about the same axis (x-z-x, x-y-x, y-x-y, y-z-y, z-y-z, z-x-z) this convention was introduced by Leonhard Euler and these angles are called Euler angles. The other 6 possible combinations of rotations are about 3 different axes (x-y-z, x-z-y, y-x-z, y-z-x, z-y-x, z-x-y), called Tait-Bryan angles after their creators (these are also sometimes called Euler angles and to make it simpler will be included in this name). Note that each of these rotations can be performed in the system associated with the object (extrinsic rotations) or in an external, static system (intrinsic rotations). The mutual equivalences are as follows (left - rotations about the internal axes, right - r