# Glove Prototype for Feature Extraction Applied to Learning by Demonstration Purposes
## 3 Theoretical Concepts
### Orientation Estimation
#### 3.3.2 Accelerometer  
The accelerometer measures acceleration including gravity. It consists of three measurements in three axes and defines an acceleration vector. Intuitively, an object standing still only has gravity acting on it and describes the acceleration vector pointing downwards with a 9.8 norm. However, that is not the correct answer. In the case of gravity, it is interpreted as the surface below the accelerometer that is pushing it upwards at 9.8 m/s\({}^{2}\) counteracting the force of gravity. Therefore, a free falling accelerometer, although being accelerated by gravity, measures 0 acceleration in all axes.  
So, the accelerometer does not measure coordinate acceleration; it actually measures proper acceleration, and that is the acceleration in its own instantaneous rest frame, which is different from coordinate acceleration.  
In this application, only gravity acceleration is relevant because ultimately the goal is to obtain an orientation estimation, and other sources of acceleration will cause errors to that estimation. So, assuming the accelerometer is only being affected by gravity, it is possible to estimate pitch (\(\theta\)) and roll (\(\phi\)).  
The accelerometer measurements should be filtered with a median or mean filter to reduce noise. These filters act as low-pass filters, and because of that they are not best suited for the gyroscope as it degrades its speed advantage and short duration precision.  
It is computed from the filtered readings \(\begin{bmatrix}a_{x}&a_{y}&a_{z}\end{bmatrix}\):  
\[\begin{array}{lcl}\theta&=&\text{arctan}2(\mathbf{a}_{y},\mathbf{a}_{z})\\ \phi&=&\text{arctan}2\big{(}-\mathbf{a}_{x},\sqrt{\mathbf{a}_{y}^{2}+\mathbf{ a}_{z}^{2}}\big{)}\end{array} \tag{5}\]  
and leave the yaw angle (\(\psi\)) as 0 because it cannot be computed without a magnetometer. Roll, pitch, and yaw representation is a common type of Euler angle representation, more specifically Tait-Bryan angles. In navigation systems, the order of rotation is usually ZYX (or yaw, pitch, roll), and we convert to the quaternion form as:  
\[\begin{array}{lcl}\mathbf{q}_{a}=\begin{pmatrix}q_{w}\\ q_{x}\\ q_{y}\\ q_{z}\end{pmatrix}=\begin{pmatrix}\cos\left(\frac{\phi}{2}\right)\cos\left( \frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)+\sin\left(\frac{\phi}{2} \right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ \sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left( \frac{\psi}{2}\right)-\cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2} \right)\sin\left(\frac{\psi}{2}\right)\\ \cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left( \frac{\psi}{2}\right)+\sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2 }\right)\sin\left(\frac{\psi}{2}\right)\\ \cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{ \psi}{2}\right)-\sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\phi}{2}\right) \cos\left(\frac{\psi}{2}\right)\end{pmatrix}\end{array} \tag{6}\]  
This quaternion is most useful to initialize the glove orientation.