Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix process noise handling in UKF #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions filterpy/kalman/UKF.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def __init__(self, dim_x, dim_z, dt, hx, fx, points,
self.x_post = self.x.copy()
self.P_post = self.P.copy()

def predict(self, dt=None, UT=None, fx=None, **fx_args):
def predict(self, dt=None, Q=None, UT=None, fx=None, **fx_args):
r"""
Performs the predict step of the UKF. On return, self.x and
self.P contain the predicted state (x) and covariance (P). '
Expand All @@ -376,6 +376,10 @@ def predict(self, dt=None, UT=None, fx=None, **fx_args):
If specified, the time step to be used for this prediction.
self._dt is used if this is not provided.

Q : numpy.array((dim_x, dim_x)), optional
Process noise. If provided, overrides self.Q for
this function call.

fx : callable f(x, dt, **fx_args), optional
State transition function. If not provided, the default
function passed in during construction will be used.
Expand All @@ -393,14 +397,17 @@ def predict(self, dt=None, UT=None, fx=None, **fx_args):
if dt is None:
dt = self._dt

if Q is None:
Q = self.Q

if UT is None:
UT = unscented_transform

# calculate sigma points for given mean and covariance
self.compute_process_sigmas(dt, fx, **fx_args)

#and pass sigmas through the unscented transform to compute prior
self.x, self.P = UT(self.sigmas_f, self.Wm, self.Wc, self.Q,
self.x, self.P = UT(self.sigmas_f, self.Wm, self.Wc, Q,
self.x_mean, self.residual_x)

# update sigma points to reflect the new variance of the points
Expand Down Expand Up @@ -718,7 +725,7 @@ def rts_smoother(self, Xs, Ps, Qs=None, dts=None, UT=None):
sigmas_f[i] = self.fx(sigmas[i], dts[k])

xb, Pb = UT(
sigmas_f, self.Wm, self.Wc, self.Q,
sigmas_f, self.Wm, self.Wc, Qs[k],
self.x_mean, self.residual_x)

# compute cross variance
Expand Down