meas_range=np.array([[-1, 1], [-1, 1]]) * 5000, # Area to generate clutter detection_probability=0.9, clutter_rate=1, seed=4 ) # Filter predictor = KalmanPredictor(transition_model) updater = KalmanUpdater(measurement_model) # Data Associator hypothesiser = DistanceHypothesiser(predictor, updater, Mahalanobis(), missed_distance=3) data_associator = GNNWith2DAssignment(hypothesiser) # Initiator & Deleter deleter = CovarianceBasedDeleter(covar_trace_thresh=1E3) initiator = MultiMeasurementInitiator( GaussianState(np.array([[0], [0], [0], [0]]), np.diag([0, 100, 0, 1000])), measurement_model=measurement_model, deleter=deleter, data_associator=data_associator, updater=updater, min_points=3, ) # Tracker tracker = MultiTargetTracker( initiator=initiator, deleter=deleter, detector=detection_sim, data_associator=data_associator,
measure=Mahalanobis(), missed_distance=3) from stonesoup.dataassociator.neighbour import GNNWith2DAssignment data_associator = GNNWith2DAssignment(hypothesiser) # %% # Creating a Deleter # ------------------ # Here we are going to create an error based deleter, which will delete any :class:`~.Track` where # trace of the covariance is over a certain threshold, i.e. when we have a high uncertainty. This # simply requires a threshold to be defined, which will depend on units and number of dimensions of # your state vector. So the higher the threshold value, the longer tracks that haven't been # updated will remain. from stonesoup.deleter.error import CovarianceBasedDeleter deleter = CovarianceBasedDeleter(covar_trace_thresh=4) # %% # Creating an Initiator # --------------------- # Here we are going to use a measurement based initiator, which will create a track from the # unassociated :class:`~.Detection` objects. A prior needs to be defined for the entire state # but elements of the state that are measured are replaced by state of the measurement, including # the measurement's uncertainty (noise covariance defined by the :class:`~.MeasurementModel`). In # this example, as our sensor measures position (as defined in measurement model # :attr:`~.LinearGaussian.mapping` attribute earlier), we only need to modify the values for the # velocity and its variance. # # As we are dealing with clutter, here we are going to be using a multi-measurement initiator. This # requires that multiple measurements are added to a track before being initiated. In this example, # this initiator effectively runs a mini version of the same tracker, but you could use different
updater, measure=Mahalanobis(), missed_distance=3) # %% # Initialise the GNN with the hypothesiser. from stonesoup.dataassociator.neighbour import GNNWith2DAssignment data_associator = GNNWith2DAssignment(hypothesiser) # %% # Initiator and Deleter # ^^^^^^^^^^^^^^^^^^^^^ # Create deleter - get rid of anything with a covariance trace greater than 2 from stonesoup.deleter.error import CovarianceBasedDeleter covariance_limit_for_delete = 2 deleter = CovarianceBasedDeleter(covariance_limit_for_delete) # %% # Set a standard prior state and the minimum number of detections required to qualify for # initiation s_prior_state = GaussianState([[0], [0], [0], [0]], np.diag([0, 0.5, 0, 0.5])) min_detections = 3 # %% # Initialise the initiator - use the 'full tracker' components specified above in the initiator. # But note that other ones could be used if needed. from stonesoup.initiator.simple import MultiMeasurementInitiator initiator = MultiMeasurementInitiator(prior_state=s_prior_state, measurement_model=measurement_model, deleter=deleter, data_associator=data_associator,
updater, measure=Mahalanobis(), missed_distance=3) # %% # Initialise the GNN with the hypothesiser. from stonesoup.dataassociator.neighbour import GNNWith2DAssignment data_associator = GNNWith2DAssignment(hypothesiser) # %% # Initiator and Deleter # ^^^^^^^^^^^^^^^^^^^^^ # Create deleter - get rid of anything with a covariance trace greater than 2 from stonesoup.deleter.error import CovarianceBasedDeleter covariance_limit_for_delete = 2 deleter = CovarianceBasedDeleter( covar_trace_thresh=covariance_limit_for_delete) # %% # Set a standard prior state and the minimum number of detections required to qualify for # initiation s_prior_state = GaussianState([[0], [0], [0], [0]], np.diag([0, 0.5, 0, 0.5])) min_detections = 3 # %% # Initialise the initiator - use the 'full tracker' components specified above in the initiator. # But note that other ones could be used if needed. from stonesoup.initiator.simple import MultiMeasurementInitiator initiator = MultiMeasurementInitiator(prior_state=s_prior_state, measurement_model=measurement_model, deleter=deleter, data_associator=data_associator,
measure=Mahalanobis(), missed_distance=3) from stonesoup.dataassociator.neighbour import GNNWith2DAssignment data_associator = GNNWith2DAssignment(hypothesiser) # %% # Creating a Deleter # ------------------ # Here we are going to create an error based deleter, which will delete any :class:`~.Track` where # trace of the covariance is over a certain threshold, i.e. when we have a high uncertainty. This # simply requires a threshold to be defined, which will depend on units and number of dimensions of # your state vector. So the higher the threshold value, the longer tracks that haven't been # updated will remain. from stonesoup.deleter.error import CovarianceBasedDeleter deleter = CovarianceBasedDeleter(4) # %% # Creating an Initiator # --------------------- # Here we are going to use a measurement based initiator, which will create a track from the # unassociated :class:`~.Detection` objects. A prior needs to be defined for the entire state # but elements of the state that are measured are replaced by state of the measurement, including # the measurement's uncertainty (noise covariance defined by the :class:`~.MeasurementModel`). In # this example, as our sensor measures position (as defined in measurement model # :attr:`~.LinearGaussian.mapping` attribute earlier), we only need to modify the values for the # velocity and its variance. # # As we are dealing with clutter, here we are going to be using a multi-measurement initiator. This # requires that multiple measurements are added to a track before being initiated. In this example, # this initiator effectively runs a mini version of the same tracker, but you could use different