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

Add is_clutter_detectable method to sensors #787

Merged
merged 4 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions stonesoup/sensor/passive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ..models.measurement.nonlinear import CartesianToElevationBearing
from ..sensor.sensor import SimpleSensor
from ..types.array import CovarianceMatrix
from ..types.detection import Detection
from ..types.groundtruth import GroundTruthState


Expand Down Expand Up @@ -40,3 +41,6 @@ def measurement_model(self):

def is_detectable(self, state: GroundTruthState) -> bool:
return True

def is_clutter_detectable(self, state: Detection) -> bool:
return True
19 changes: 18 additions & 1 deletion stonesoup/sensor/radar/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ...sensor.actionable import ActionableProperty
from ...sensor.sensor import Sensor, SimpleSensor
from ...types.array import CovarianceMatrix
from ...types.detection import TrueDetection
from ...types.detection import TrueDetection, Detection
from ...types.groundtruth import GroundTruthState
from ...types.numeric import Probability
from ...types.state import StateVector
Expand Down Expand Up @@ -63,6 +63,9 @@ def is_detectable(self, state: GroundTruthState) -> bool:
true_range = measurement_vector[1, 0] # Bearing(0), Range(1)
return true_range <= self.max_range

def is_clutter_detectable(self, state: Detection) -> bool:
return state.state_vector[1, 0] <= self.max_range


class RadarBearing(SimpleSensor):
"""A simple radar sensor that generates measurements of targets, using a
Expand Down Expand Up @@ -110,6 +113,9 @@ def is_detectable(self, state: GroundTruthState) -> bool:
true_range = measurement_vector[1, 0] # Bearing(0), Range(1)
return true_range <= self.max_range

def is_clutter_detectable(self, state: Detection) -> bool:
return True


class RadarRotatingBearingRange(RadarBearingRange):
"""A simple rotating radar, with set field-of-view (FOV) angle, range and\
Expand Down Expand Up @@ -179,6 +185,17 @@ def is_detectable(self, state: GroundTruthState) -> bool:

return fov_min <= bearing_t <= fov_max and true_range <= self.max_range

def is_clutter_detectable(self, state: Detection) -> bool:
measurement_vector = state.state_vector

# Check if state falls within sensor's FOV
fov_min = -self.fov_angle / 2
fov_max = +self.fov_angle / 2
bearing_t = measurement_vector[0, 0]
true_range = measurement_vector[1, 0]

return fov_min <= bearing_t <= fov_max and true_range <= self.max_range


class RadarRotatingBearing(RadarBearing):
"""A simple rotating radar, with set field-of-view (FOV) angle, range and\
Expand Down
2 changes: 1 addition & 1 deletion stonesoup/sensor/radar/tests/test_radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,4 @@ def test_clutter_model(radar, clutter_params):
truth = State(StateVector([1, 1, 1, 1]), timestamp=datetime.datetime.now())
measurements = radar.measure({truth})
assert len([target for target in measurements if (isinstance(target, TrueDetection))]) == 1
assert len(measurements) > 1
assert len(measurements) >= 1
10 changes: 8 additions & 2 deletions stonesoup/sensor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .base import PlatformMountable
from ..base import Property
from ..models.clutter.clutter import ClutterModel
from ..types.detection import TrueDetection
from ..types.detection import TrueDetection, Detection
from ..types.groundtruth import GroundTruthState


Expand Down Expand Up @@ -119,14 +119,20 @@ def measure(self, ground_truths: Set[GroundTruthState], noise: Union[np.ndarray,
if self.clutter_model is not None:
self.clutter_model.measurement_model = measurement_model
clutter = self.clutter_model.function(ground_truths)
detections = set.union(detections, clutter)
detectable_clutter = [cltr for cltr in clutter
if self.is_clutter_detectable(cltr)]
detections = set.union(detections, detectable_clutter)

return detections

@abstractmethod
def is_detectable(self, state: GroundTruthState) -> bool:
raise NotImplementedError

@abstractmethod
def is_clutter_detectable(self, state: Detection) -> bool:
raise NotImplementedError


class SensorSuite(Sensor):
"""Sensor composition type
Expand Down