ตัวกรองคาลมานสำหรับตำแหน่งและความเร็ว: แนะนำการประมาณความเร็ว


24

ขอบคุณทุกคนที่โพสต์ความเห็น / คำตอบคำถามของฉันเมื่อวานนี้ ( ใช้ตัวกรองคาลมานสำหรับตำแหน่ง, ความเร็ว, ความเร่ง ) ฉันได้รับการมองหาสิ่งที่ได้รับการแนะนำและโดยเฉพาะอย่างยิ่งในการที่ทั้งสอง (ก) ตัวอย่างที่วิกิพีเดียในตำแหน่งมิติหนึ่งและความเร็วและยังเว็บไซต์อื่นที่จะพิจารณาสิ่งที่คล้ายกัน

อัปเดต 26 เม.ย. 2556 : คำถามเดิมที่นี่มีข้อผิดพลาดบางอย่างเกี่ยวข้องกับความจริงที่ว่าฉันไม่เข้าใจตัวอย่างวิกิพีเดียในตำแหน่งมิติและความเร็วอย่างเดียว ด้วยความเข้าใจที่ดีขึ้นของฉันเกี่ยวกับสิ่งที่เกิดขึ้นตอนนี้ฉันได้ร่างคำถามขึ้นใหม่และมุ่งเน้นไปที่มันแน่นขึ้น

ตัวอย่างทั้งสองที่ฉันอ้างถึงในย่อหน้าเบื้องต้นข้างต้นถือว่าเป็นตำแหน่งที่วัดได้เท่านั้น อย่างไรก็ตามไม่มีตัวอย่างใด ๆ ที่มีการคำนวณสำหรับความเร็ว ตัวอย่างเช่นตัวอย่างวิกิพีเดียระบุเมทริกซ์เป็นซึ่งหมายความว่าตำแหน่งเดียวคืออินพุต เพ่งความสนใจไปที่ตัวอย่างของ Wikipedia เวกเตอร์สถานะของตัวกรองคาลมานมีตำแหน่งและความเร็วคือ(xkxk1)/dtHH=[1   0]xkxkx˙k

xk=(xkx˙k)

Suppose the measurement of position at time k is x^k. Then if the position and speed at time k1 were xk1 and x˙k1, and if a is a constant acceleration that applies in the time interval k1 to k, from the measurement of x^ it's possible to deduce a value for a using the formula

x^k=xk1+x˙k1dt+12adt2

This implies that at time k, a measurement x˙^k of the speed is given by

x˙^k=x˙k1+adt=2x^kxk1dtx˙k1

All the quantities on the right hand side of that equation (i.e. x^k, xk1 and x˙k1) are normally distributed random variables with known means and standard deviations, so the R matrix for the measurement vector

x^k=(x^kx˙^k)

can be calculated. Is this a valid way of introducing speed estimates into the process?


2
I didn't look through all of your calculations. However, speaking of the Wikipedia example, you seem to be a bit confused on its structure. You're correct in that only position is measured. However, a so-called "constant-velocity" model is used. This means that the velocity is considered to be constant in the state transition matrix.
Jason R

3
Changes in the velocity are modeled using the process noise matrix. Therefore, you're inherently assuming that the velocity is going to change randomly with some specified covariance. Surprisingly enough, this often works well. It is common to use process noise one derivative above your highest state-variable derivative in this way. For instance, if you included acceleration in your model, then you might have a random jerk component included in your process noise.
Jason R

@JasonR with the wikipedia model (assuming zero initial covariance between position and speed), the speed estimate is always it's initial value (as you say, a "constant-velocity" model). However, the variance of the speed grows monotonically via the process noise, and there are no measurements which can reduce it. What is the advantage of this over a model that only models position and assumes a constant speed?
Stochastically

2
The variance of the velocity estimate shouldn't increase monotonically. Process noise simply introduces a stochastic component to the state transition equation, allowing you to express some uncertainty at exactly how the system state will evolve from time step to time step. If you don't include process noise, then your filter would truly output a constant velocity. That probably isn't what you want.
Jason R

Well @JasonR, if you look at the wikipedia model, you'll see that monotinically increasing variance of velocity is what it gives you!
Stochastically

คำตอบ:


24

Is this a valid way of introducing speed estimates into the process?

If you choose your state appropriately, then the speed estimates come "for free". See the derivation of the signal model below (for the simple 1-D case we've been looking at).

Signal Model, Take 2

So, we really need to agree on a signal model before we can move this forward. From your edit, it looks like your model of the position, xk, is:

xk+1=xk+x˙kΔt+12a(Δt)2x˙k+1=x˙k+aΔt

If our state is as before:

xk=(xkx˙k)
then the state update equation is just:
xk+1=(1  Δt0  1)xk+((Δt)22Δt)ak
where now our ak is the normally distributed acceleration.

That gives different G matrix from the previous version, but the F and H matrices should be the same.


If I implement this in scilab (sorry, no access to matlab), it looks like:

// Signal Model
DeltaT = 0.1;
F = [1 DeltaT; 0 1];
G = [DeltaT^2/2; DeltaT];
H = [1 0];

x0 = [0;0];
sigma_a = 0.1;

Q = sigma_a^2;
R = 0.1;

N = 1000;

a = rand(1,N,"normal")*sigma_a;

x_truth(:,1) = x0;
for t=1:N,
    x_truth(:,t+1) = F*x_truth(:,t) + G*a(t);
    y(t) = H*x_truth(:,t) + rand(1,1,"normal")*sqrt(R);
end

Then, I can apply the Kalman filter equations to this y (the noisy measurements).

// Kalman Filter
p0 = 100*eye(2,2);

xx(:,1) = x0;
pp = p0;
pp_norm(1) = norm(pp);
for t=1:N,
    [x1,p1,x,p] = kalm(y(t),xx(:,t),pp,F,G,H,Q,R);
    xx(:,t+1) = x1;
    pp = p1;
    pp_norm(t+1) = norm(pp);
end

So we have our noisy measurements y, and we've applied the Kalman filter to them and used the same signal model to generate y as we do to apply the Kalman filter (a pretty big assumption, sometimes!).

Then following plots show the result.

Plot 1: y and xk versus time.

enter image description here

Plot 2: A zoomed view of the first few samples:

enter image description here

Plot 3: Something you never get in real life, the true position vs the state estimate of the position.

enter image description here

Plot 4: Something you also never get in real life, the true velocity vs the state estimate of the velocity.

enter image description here

Plot 5: The norm of the state covariance matrix (something you should always monitor in real life!). Note that it very quickly goes from its initial very large value to something very small, so I've only shown the first few samples.

enter image description here

Plot 6: Plots of the error between the true position and velocity and their estimates.

enter image description here

If you study the case where the position measurements are exact, then you find that the Kalman udpate equations produce exact results for BOTH position and speed. Mathematically it's straightforward to see why. Using the same notation as the wikipedia article, exact measurements mean that zk+1=xk+1. If you assume that the initial position and speed are known so that Pk=0, then Pk+1=Q and the Kalman gain matrix Kk+1 is given by

Kk+1=(12/dt)

This means that the Kalman update procedure produces

x^k+1=Fk+1xk+Kk+1(zk+1Hk+1Fk+1xk)=(xk+x˙kdtx˙k)+(12/dt)(xk+1(xk+x˙kdt))=(xk+12(xk+1xk)/dtx˙k)

As you can see, the value for the speed is given by exactly the formula you were proposing to use for the speed estimate. So although you couldn't see any kind of calculation (xkxk1)/dt for speed, in fact it is hidden in there after all.


Thanks for all your help so far. My original question did contain some misunderstandings, so I've tried to refocus it and with an attempt to answer your question about z_k.
Stochastically

1
thanks vm for all your efforts :-). Your work spurred me on to do a bit of maths which I've tacked on to your answer, hope you don't mind. Anyway, I'm now 100% convinced that the standard method is good, because I can see formulas in there for speed after all. Thanks again
Stochastically

Glad to be able to help! No problem with adding to the answer.
Peter K.
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.