# Kalman Filter and INS

Started by April 13, 2009
```> Two questions:
>
> One: Why is acceleration a state? &#2013266080;I thought you were measuring it.

Acceleration should definitely be one of the states.  Simply because
you are measuring acceleration does not somehow disqualify it from
also being a state.

>
> Two: If you _are_ measuring acceleration, how do you know what direction
> it's coming from? &#2013266080;IOW with an accelerometer you can measure
> acceleration with respect to your vehicle frame of motion, but doesn't
> that rotate with respect to the local inertial frame?
>

As posed by the OP, the problem is one of estimating distance
travelled along the frame of reference defined by the heading of the
vehicle/robot/whatever.  Currently, the OP has not asked for an
estimation of current position in some inertial frame.

If it were, then your point is completely valid, and changes the
design of the state model etc., such that roll pitch and heading etc
would probably form part of the state vector.

In answer to the original question, which is:

"Here is what i have, a measurement of a distance from an external
sensor at
a lower sampling rate and acceleration measurements from accelerometer
(
IMU at a higher rate). How can i use a kalman filter to fuse these to
produce a good estimate of the position travelled."

Ans: Change your H matrix each time interval so that it matches to the
current measurement(s) being taken.  For example, if your current
measurement is a high-rate measurement of acceleration only, then your
H matrix is [0 0 1].  If your current measurement is both position and
acceleration, then your H matrix is [1 0 1] (correct dimensionality
omitted for purposes of emphasis).

```
```Malachy Moses wrote:
>> Two questions:
>>
>> One: Why is acceleration a state?  I thought you were measuring it.
>
> Acceleration should definitely be one of the states.  Simply because
> you are measuring acceleration does not somehow disqualify it from
> also being a state.

That would depend on how you're modeling the system, and how you're
measuring acceleration.  If the higher-order inputs and dynamics are
unknown then you probably want to treat acceleration as a measurement,
not a state.

>> Two: If you _are_ measuring acceleration, how do you know what direction
>> it's coming from?  IOW with an accelerometer you can measure
>> acceleration with respect to your vehicle frame of motion, but doesn't
>> that rotate with respect to the local inertial frame?
>>
>
> As posed by the OP, the problem is one of estimating distance
> travelled along the frame of reference defined by the heading of the
> vehicle/robot/whatever.  Currently, the OP has not asked for an
> estimation of current position in some inertial frame.

As posed by the OP, frames of reference are not mentioned.  In other
posts on similar topics this same OP has shown confusion about the need
for tracking heading along with position and velocity.

> If it were, then your point is completely valid, and changes the
> design of the state model etc., such that roll pitch and heading etc
> would probably form part of the state vector.
>
> In answer to the original question, which is:
>
> "Here is what i have, a measurement of a distance from an external
> sensor at
> a lower sampling rate and acceleration measurements from accelerometer
> (
> IMU at a higher rate). How can i use a kalman filter to fuse these to
> produce a good estimate of the position travelled."
>
> Ans: Change your H matrix each time interval so that it matches to the
> current measurement(s) being taken.  For example, if your current
> measurement is a high-rate measurement of acceleration only, then your
> H matrix is [0 0 1].  If your current measurement is both position and
> acceleration, then your H matrix is [1 0 1] (correct dimensionality
> omitted for purposes of emphasis).
>
Or find a good treatment of a mixed continuous/discrete Kalman filter,
extend it to a multi-rate filter, and find how you can avoid a lot of
computations when you're not getting position fixes.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```>As posed by the OP, frames of reference are not mentioned.  In other
>posts on similar topics this same OP has shown confusion about the need
>for tracking heading along with position and velocity.
>

Thanks for all the replies guys. As Tim has mentioned, i have had other
posts in the forum talking about using just accelerometer ( 3 axis) to
measure distance without any external sensor and that idea for valid
reasons was quashed to death ( such as the bias grows at 1/2*t^2 when
integrated etc). I am relatively new at the INS ( less than 6 weeks) and i
am involved in a project of developing a low cost INS to measure the
distance travelled, hence trying to get as much info as possible.

IMU i am using spits out 3 axis acc, gyro readings. This coupled with
another external sensor i have and 3d compass, i am trying to develop a low
cost robust INS.

Ideally i would have liked to just use the MEMS unit without any external
sensors for ease of installation but as i mentioned Tim and others who have
more experience than i do in this have strongly suggested thats not
possible with low cost IMU.

Can you guys think of any non-contact speed sensors which i might be able
to replace my current speed sensor which has some tedious installation?

```
```On Wed, 15 Apr 2009 11:29:00 -0500, arvkr wrote:

>>As posed by the OP, frames of reference are not mentioned.  In other
>>posts on similar topics this same OP has shown confusion about the need
>>for tracking heading along with position and velocity.
>>
>>
> Thanks for all the replies guys. As Tim has mentioned, i have had other
> posts in the forum talking about using just accelerometer ( 3 axis) to
> measure distance without any external sensor and that idea for valid
> reasons was quashed to death ( such as the bias grows at 1/2*t^2 when
> integrated etc). I am relatively new at the INS ( less than 6 weeks) and
> i am involved in a project of developing a low cost INS to measure the
> distance travelled, hence trying to get as much info as possible.
>
> IMU i am using spits out 3 axis acc, gyro readings. This coupled with
> another external sensor i have and 3d compass, i am trying to develop a
> low cost robust INS.
>
> Ideally i would have liked to just use the MEMS unit without any
> external sensors for ease of installation but as i mentioned Tim and
> others who have more experience than i do in this have strongly
> suggested thats not possible with low cost IMU.
>
> Can you guys think of any non-contact speed sensors which i might be
> able to replace my current speed sensor which has some tedious
> installation?

If you have a 6-axis IMU, a distance measurement from a reference point,
and a vehicle that's moving enough, you should be able to settle to an
trajectory that is accurate but for a cylindrically symmetric uncertainty
centered around the reference point (i.e., you'll have the right shape
with respect to the reference point but you won't know which way north
is).

Add in a compass or distances to two references, and you should be there.

--
http://www.wescottdesign.com
```
```
>If you have a 6-axis IMU, a distance measurement from a reference point,

>and a vehicle that's moving enough, you should be able to settle to an
>trajectory that is accurate but for a cylindrically symmetric uncertainty

>centered around the reference point (i.e., you'll have the right shape
>with respect to the reference point but you won't know which way north
>is).
>
>Add in a compass or distances to two references, and you should be
there.
>
>--
>http://www.wescottdesign.com
>

Thanks Tim. I have a slightly off topic question. Do you know of any good
doppler radar based speed sensor which consumes the lowest power and lowest
in size etc?
```
```
Tim Wescott wrote:

> If you have a 6-axis IMU, a distance measurement from a reference point,
> and a vehicle that's moving enough, you should be able to settle to an
> trajectory that is accurate but for a cylindrically symmetric uncertainty
> centered around the reference point (i.e., you'll have the right shape
> with respect to the reference point but you won't know which way north
> is).
>
> Add in a compass or distances to two references, and you should be there.

But would the INS be any useful if you have compass (or a steering wheel
reckoning is many orders more accurate then MEMS INS.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```arvkr wrote:
>> Two questions:
>>
>> One: Why is acceleration a state?  I thought you were measuring it.
>
> You are right. I am measuring it and prob should have the state as acc
> bias to estimate the bias. This is where i am struggling with since i don't
> seem to understand kalman filter fully and i have read several articles on
> the web, still haven't been able to fully get a grip on it.

I have one book that talks about nothing but optimal state estimation
(i.e. the Kalman filter and it's extended family), another that goes
into detection, estimation and modulation theory (which has you derive
Kalman filters as homework problems in at least two places), a couple of
adaptive control books (that treat the system identification phase of
adaptive control as a Kalman filtering problem), a book on strapdown
excellent section on translating combined gyro and accelerometer data
into just the sort of model you need), and access to the entire world
wide web.

This is backed up by a career doing various sorts of signal detection
and estimation problems, building advanced control systems from scratch,
and other related activity.

After all this, while I feel that I'm more than good enough to charge
people money to design Kalman filtering algorithms I still don't feel I
have wrapped my arms completely around the problem.  I doubt that I
would even if I won the lottery tomorrow, got my PhD in optimal
estimation, and spent the rest of my life teaching and doing research.

So I don't know if it's realistic for anyone to expect to figure this
out by asking questions on USENET and reading web pages.  I'm not even
sure if I can recommend just one book -- I think to do what you want to
do you need at least Dan Simon's book and a good book on strapdown
inertial nav systems.

Even then you'll find Simon's book to be an uphill battle unless you
have a good grounding in stochastic process theory and state-space
control -- so expect to do some supplementary reading.  Further, I have
yet to find a book on strapdown inertial navigation theory that gives a
blow-by-blow analysis of an inertial navigation Kalman solution -- the
one I have is the best of the lot, but it sure doesn't give an ABC
description.

Here's my bibliography -- the two end ones are currently on my
'essential reading' list for inertial nav stuff.

Dan Simon, "Optimal State Estimation", Wiley 2006:
http://www.powells.com/partner/30696/biblio/9780471708582

Harry Van Trees, "Detection, Estimation, and Modulation Theory", Wiley,
1968: http://www.powells.com/partner/30696/biblio/9780471463825

1995: http://www.powells.com/partner/30696/biblio/9780486462783

GPC", Prentice-Hall, 1990:
http://www.powells.com/partner/30696/biblio/0139468234

Titterton, D. H. and Weston, J. L., "Strapdown Inertial Navigation
Technology", AIAA, 2004:
http://www.powells.com/partner/30696/biblio/9780863413582

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```>Two questions:
>
>One: Why is acceleration a state?  I thought you were measuring it.

You are right. I am measuring it and prob should have the state as acc
bias to estimate the bias. This is where i am struggling with since i don't
seem to understand kalman filter fully and i have read several articles on
the web, still haven't been able to fully get a grip on it.

```
```arvkr wrote:
>> First, why don't you model the system?  Model it as if you weren't using
>
>> the Kalman, but as if you cared about the quantity that the Kalman is
>> measuring.  This means you should include the outputs that you really
>> care about (or just note them if they're states), and include an output
>> of the predicted value of the measurement that you're going to take.
>>
>> --
>> http://www.wescottdesign.com
>>
>
> My states would be
> x(k) = [pos
>      vel
>      acc];
> state equations would be
> x(k) = A*x(k-1) + B * u(k) + w(k)
>
> Measurement equations
> z(k) = H*x(k) + v(k) ( process noise)
>
> now if we assume the model to be
> pos(k) = pos(k-1) + deltaT*vel(k-1) + deltaT^2/2*acc(k-1);
> vel(k) = vel(k-1)+ deltaT*acc(k-1)
> acc(k) = acc(k)
>
> then A would be
> A = [1	&Delta;t	&Delta;t^2/2
>      0	1	&Delta;t
>      0	0	1   ]
>
> would my H be
> H = [ 1 0 0
>       0 0 1]
> and my Z be
> Z = [ distMeasured 0
>       0            accMeasured]
>
> R = [var(distMeasured) 0
>      0                var(accMeasured)]
>
> Q = ?
> and what would be my initial covariance as initializing values seem
> crucial.
>
Two questions:

One: Why is acceleration a state?  I thought you were measuring it.

Two: If you _are_ measuring acceleration, how do you know what direction
it's coming from?  IOW with an accelerometer you can measure
acceleration with respect to your vehicle frame of motion, but doesn't
that rotate with respect to the local inertial frame?

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```>
>First, why don't you model the system?  Model it as if you weren't using

>the Kalman, but as if you cared about the quantity that the Kalman is
>measuring.  This means you should include the outputs that you really
>care about (or just note them if they're states), and include an output
>of the predicted value of the measurement that you're going to take.
>
>--
>http://www.wescottdesign.com
>

My states would be
x(k) = [pos
vel
acc];
state equations would be
x(k) = A*x(k-1) + B * u(k) + w(k)

Measurement equations
z(k) = H*x(k) + v(k) ( process noise)

now if we assume the model to be
pos(k) = pos(k-1) + deltaT*vel(k-1) + deltaT^2/2*acc(k-1);
vel(k) = vel(k-1)+ deltaT*acc(k-1)
acc(k) = acc(k)

then A would be
A = [1	&Delta;t	&Delta;t^2/2
0	1	&Delta;t
0	0	1   ]

would my H be
H = [ 1 0 0
0 0 1]
and my Z be
Z = [ distMeasured 0
0            accMeasured]

R = [var(distMeasured) 0
0                var(accMeasured)]

Q = ?
and what would be my initial covariance as initializing values seem
crucial.

```
```On Mon, 13 Apr 2009 14:04:18 -0500, arvkr wrote:

> Here is what i have, a measurement of a distance from an external sensor
> at a lower sampling rate and acceleration measurements from
> accelerometer ( IMU at a higher rate). How can i use a kalman filter to
> fuse these to produce a good estimate of the position travelled. What
> would be A, B, H, R, Q if i were to use a kalman filter. Any help will
> be appreciated.

First, why don't you model the system?  Model it as if you weren't using
the Kalman, but as if you cared about the quantity that the Kalman is
measuring.  This means you should include the outputs that you really
care about (or just note them if they're states), and include an output
of the predicted value of the measurement that you're going to take.

--
http://www.wescottdesign.com
```
```Here is what i have, a measurement of a distance from an external sensor at
a lower sampling rate and acceleration measurements from accelerometer (
IMU at a higher rate). How can i use a kalman filter to fuse these to
produce a good estimate of the position travelled. What would be A, B, H,
R, Q if i were to use a kalman filter. Any help will be appreciated.

```