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

Error in RTS equations #278

Open
andrewjlock opened this issue Sep 16, 2022 · 0 comments
Open

Error in RTS equations #278

andrewjlock opened this issue Sep 16, 2022 · 0 comments

Comments

@andrewjlock
Copy link

Thanks for the useful repository.

It seems there is an error in the RTS smoother equations which causes errors for systems with varying state transition matrices (i.e. EKF).

Replacing it with the formulation using a-priori state and covariance estimates produces the correct solution. I.e., minimal example:

def rts_smoother(x_s, P_s, x_prs, P_prs, F_s):                                                                                                                                                                                                                                                                                                     
    x_rts = [None]*n                                                                                                                                                                                                         
    P_rts = [None]*n                                                                                                                                                                                                         
    x_rts[-1] = x_s[-1]                                                                                                                                                                                                       
    P_rts[-1] = P_s[-1]                                                                                                                                                                                                       
    for k in range(n-2, -1, -1):                                                                                                                                                                                                                                                                                                                                                                                                                         
        C = P_s[k]@(F_s[k+1].T)@np.linalg.inv(P_prs[k+1])                                                                                                                                                                      
        x_rts[k] = x_s[k] + C@(x_rts[k+1] - x_prs[k+1])                                                                                                                                                                       
        P_rts[k] = P_s[k] + C@(P_rts[k+1] - P_prs[k+1])@(C.T)                                                                                                                                                                                                                                                                                                                                                                                                return x_rts, P_rts    

where for an EKF the state transition $F_k( \hat{x}_{k/k-1})$ is calculated for timestep $k$ using the a-priori state estimate of that timestep. This produces the expected RTS smoothing result for me.

Source: Wikipedia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant