dstl / Stone-Soup

A software project to provide the target tracking community with a framework for the development and testing of tracking algorithms.
https://stonesoup.rtfd.io
MIT License
406 stars 134 forks source link

Issue with track fusion using Particle Filters #854

Closed A-acuto closed 5 months ago

A-acuto commented 1 year ago

Hello, I've been trying to set up a comparison code using track fusion algorithm between Kalman and particle filters. The track fusion seems working fine using the tracks obtained with the Kalman filter, but in the case of Particle filter there is an incompatibility issue between the Gaussian detections and the ParticleStateUpdate, in particular using Tracks2GaussianDetectionFeeder I got this error from types/detection :

super().__init__(state_vector, *args, **kwargs)
TypeError: __init__() missing 1 required positional argument: 'covar'

Example using the kalman filter: here Example using the Particle filter: here

Thanks for any input on this issue

sdhiscocks commented 12 months ago

Tracks2GaussianDetectionFeeder is designed for Gaussian based states only, as well as Chernoff Updater being used. Another approach, not currently implemented would be need to fuse ParticleState.

With small modification, it would be possible to take the ParticleState mean and covariance and assume the ParticleState is representing a GaussianState. We could make change to support that.

diff --git a/stonesoup/feeder/track.py b/stonesoup/feeder/track.py
index a157f4d5..37f2aebe 100644
--- a/stonesoup/feeder/track.py
+++ b/stonesoup/feeder/track.py
@@ -27,6 +27,8 @@ class Tracks2GaussianDetectionFeeder(DetectionFeeder):
                 detections.add(
                     GaussianDetection.from_state(
                         track.state,
+                        state_vector=track.mean,
+                        covar=track.covar,
                         measurement_model=LinearGaussian(
                             dim, list(range(dim)), np.asarray(track.covar)),
                         metadata=metadata,