Skip to content

Commit 7460ed5

Browse files
committed
downgrade to v1.2.0
1 parent affbd28 commit 7460ed5

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,23 @@
22
This library fuses the outputs of an inertial measurement unit (IMU) and stores the heading as a quaternion. It uses a _modified Mahony_ filter that replaces the PI controller with a damped 2nd-order system. The proportional term was removed and the integral term was forced to decay to damp the system. The correction steps are as follows:
33

44
__Mahony:__
5-
$\ E_{k} = \theta_{accel} - \theta_{k-1} $
5+
$\ E = \theta_{accel} - \theta_{k-1} $
66

7-
$\ I_{k} = I_{k-1} + {E_{k}}{\Delta t} $
7+
$\ I_{k} = I_{k-1} + {E}{\Delta t} $
88

9-
$\ \theta_{k} = \theta_{k-1} + \dot{\theta}{\Delta t} + K_{p}E_{k} + K_{i}I_{k} $
9+
$\ \theta_{k} = \theta_{k-1} + \dot{\theta}{\Delta t} + K_{p}E + K_{i}I_{k} $
1010

1111
__Modified Mahony:__ (this filter)
12-
$\ E_{k} = \theta_{accel} - \theta_{k-1} $
12+
$\ E = \theta_{accel} - \theta_{k-1} $
1313

14-
$\ I_{k} = K_{p}{E_{k}} + (1 - K_{c})I_{k-1} $
14+
$\ I_{k} = K_{p}{E} + (1 - K_{c})I_{k-1} $
1515

1616
$\ \theta_{k} = \theta_{k-1} + \dot{\theta}{\Delta t} + I_{k} $
1717

1818
The behavior of the modified filter is analogous to spring-mass system. Kp (stiffness) and Kc (damping) are related by the [Q-factor](https://en.wikipedia.org/wiki/Q_factor). This value is held constant, so the behavior of the filter is controlled by a single parameter (Kp):
1919

2020
$\ K_{c} = \sqrt{ K_{p}/Q } $
2121

22-
To improve the response of the filter, the acceleration is checked to see if it lies within a given deviation from its steady-state value (1g vertically). If the acceleration is within this band, it will strongly correct the orientation. However, if the acceleration lies outside of this band, it will barely affect the orientation. This is accomplished with a kalman-like filter that uses the deviation from vertical to update its variance and gain:
23-
24-
$\ \overrightarrow{a_{rel}} = \overrightarrow{a_{local}} - (0,0,1) $
25-
26-
$\ K_{\sigma} = 1/(1 + \frac{ {\sigma}^2 }{ {\sigma}_{acc}^2 } ) $
27-
28-
$\ {\sigma}^2 = | \overrightarrow{a_{rel}} |^2 + K_{\sigma}{\sigma}^2 $
29-
30-
$\ E_{k} = K_{\sigma} E_{k} $
31-
3222
As the filter uses a quaternion to encode rotations, it's easy to perform coordinate transformations. The library has functions to:
3323
- Transfor a vector to the local or global frame.
3424
- Get the unit vectors of the X, Y and Z axes in the local or global frame.

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=imuFilter
2-
version=1.3.0
2+
version=1.2.0
33
author=RCmags <[email protected]>
44
maintainer=RCmags <[email protected]>
55
sentence=Sensor fusion for IMU with quaternion based filter.

src/imuFilter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ float imuFilter::updateTimer() {
1010

1111
void imuFilter::setup() {
1212
var = 0;
13-
s = {0,0,0};
1413
q = {1,0,0,0};
1514
last_time = micros();
1615
}

0 commit comments

Comments
 (0)