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

Introduce 2D Obstacles, handling for sensors and the Visibility Informed Bernoulli Filter #1096

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

timothy-glover
Copy link
Contributor

This pull request introduces a number of new features, focussed around the idea of obstacles in the environment and the impact that this has on blocking sensor line of sight to targets. The contributions are categorised below:

  1. Obstacle platform. A new base Platform type, Obstacle, is introduced. The class is designed to allow the user to place obstacles in the environment by specifying the shape of the obstacle as polygon vertices, the position and orientation of the obstacle and any other Platform related properties for the obstacle. Moving obstacles should be possible with this implementation but this has not been tested at this stage. Obstacle also calculates some properties that are relevant for estimating visibility of targets and does so by caching the property and only recalculating it when necessary (i.e. obstacle position and orientation changes). A from_obstacle class method has also been created that allows for creating multiple obstacles that share properties, such as shape data, and redefining others, such as position or orientation.
  2. VisibilityInformed2DSensor is a new base sensor class that inherits from SimpleSensor and is intended to be inherited by 2D sensors (such as those adopting range-bearing and bearing-only sensor models) such that they can call the method is_visible, which evaluates the visibility of states by checking whether the line of sight intersects any Obstacle edges. This sensor base class allows the user to specify an obstacle list which is used for this purpose, but can be left undefined to resume the original functionality of the sensors before introducing this new base class. RadarBearing, RadarBearingRange, RadarRotatingBearing and RadarRotatingBearingRange have all been modified to inherit from this base class and each call is_visible from within is_detectable meaning that there are no changes to how these sensors are implemented. In order to evaluate the visibility of multiple states at the same time (relevant for the next point), is_detectable has been modified to handle arrays of states as well as single states.
  3. VisibilityInformedBernoulliParticlePredictor and VisibilityInformedBernoulliParticleUpdater have been introduced and modify the predict_log_weights and get_detection_probability methods of BernoulliParticlePredictor and BernoulliParticleUpdater respectively. This filter modifies the transition likelihood, birth likelihood and detection probability according to whether particles are inside obstacles or in not visible free space, which prevents the estimated existence from decaying quickly when a target travels behind and Obstacle and improves the resulting estimation performance when compared to the original Bernoulli filter.
  4. plot_obstacles is a method introduced for Plotterly and AnimatedPlotterly to allow the user to plot lists of, or single, Obstacle. The plotting of obstacles assumes that they are closed polygons which are filled accordingly, however, it is possible to specify open obstacles.
  5. Tests for each of the above contributions and modifications have also been completed.

@timothy-glover timothy-glover requested a review from a team as a code owner October 23, 2024 14:09
@timothy-glover timothy-glover requested review from sdhiscocks and jswright-dstl and removed request for a team October 23, 2024 14:09
@timothy-glover timothy-glover changed the title Introduce 2D Obstacles, Handling for sensors and the Visibility Informed Bernoulli Filter Introduce 2D Obstacles, handling for sensors and the Visibility Informed Bernoulli Filter Oct 23, 2024
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 95.08197% with 9 lines in your changes missing coverage. Please review.

Project coverage is 94.25%. Comparing base (92dae99) to head (b784de3).
Report is 155 commits behind head on main.

Files with missing lines Patch % Lines
stonesoup/plotter.py 86.84% 1 Missing and 4 partials ⚠️
stonesoup/sensor/sensor.py 90.00% 2 Missing and 1 partial ⚠️
stonesoup/predictor/particle.py 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1096      +/-   ##
==========================================
+ Coverage   94.19%   94.25%   +0.06%     
==========================================
  Files         207      207              
  Lines       13465    13626     +161     
  Branches     2740     2237     -503     
==========================================
+ Hits        12683    12843     +160     
- Misses        530      533       +3     
+ Partials      252      250       -2     
Flag Coverage Δ
integration 67.29% <36.61%> (-0.42%) ⬇️
unittests 90.35% <95.08%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1508,6 +1508,34 @@ def plot_sensors(self, sensors, mapping=[0, 1], sensor_label="Sensors", **kwargs
sensor_xy = np.array([sensor.position[mapping, 0] for sensor in sensors])
self.fig.add_scatter(x=sensor_xy[:, 0], y=sensor_xy[:, 1], **sensor_kwargs)

def plot_obstacles(self, obstacles, mapping=[0, 1], obstacle_label='obstacles', **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to other methods in this class, a short docstring explaining the method and the parameters and their datatypes would be useful

stonesoup/predictor/particle.py Outdated Show resolved Hide resolved
stonesoup/sensor/radar/radar.py Show resolved Hide resolved
stonesoup/sensor/radar/radar.py Outdated Show resolved Hide resolved
stonesoup/sensor/radar/radar.py Outdated Show resolved Hide resolved
stonesoup/sensor/radar/radar.py Outdated Show resolved Hide resolved
stonesoup/sensor/sensor.py Outdated Show resolved Hide resolved
stonesoup/sensor/sensor.py Outdated Show resolved Hide resolved
stonesoup/sensor/sensor.py Outdated Show resolved Hide resolved
stonesoup/updater/particle.py Outdated Show resolved Hide resolved
timothy-glover and others added 2 commits October 24, 2024 14:18
Co-authored-by: Henry Pritchett <87075245+hpritchett-dstl@users.noreply.github.com>
@timothy-glover
Copy link
Contributor Author

Docs appear to have failed due to an exception raised with an unrelated example

stonesoup/plotter.py Outdated Show resolved Hide resolved
stonesoup/plotter.py Outdated Show resolved Hide resolved
stonesoup/plotter.py Outdated Show resolved Hide resolved
stonesoup/plotter.py Outdated Show resolved Hide resolved
stonesoup/plotter.py Outdated Show resolved Hide resolved
stonesoup/plotter.py Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

3 participants