| Algorithm 1: Pseudo-code of the vector calibration algorithm | ||
|
Input: : A raw 3D vector to be calibrated (e.g., magnetic field vector) : The raw 3D vector from the accelerometer : The current yaw angle of the device : The application-specific reference yaw angle Output: The calibrated 3D vector Constant: (The smoothing coefficient) Persistent State: : The filtered acceleration vector from the previous time step |
||
| 1 | // Stage1: Pitch & Roll Correction | |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 | ||
| 11 | // Stage2: Yaw Correction | |
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|