Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
935a7eb
Added SMCPHD implementation
sglvladi Aug 15, 2022
0b90c50
Add n_particles as optional argument to SystematicResampler
sglvladi Aug 15, 2022
9ea0ce8
Add SMCPHD example script
sglvladi Aug 15, 2022
9635556
Add metadata property to SingleHypothesis
sglvladi Sep 23, 2022
41d6184
Added IPDA and JIPDAWithEHM2 classes
sglvladi Sep 23, 2022
8f78a39
SMCPHD update + Added SMCPHDInitiator
sglvladi Sep 23, 2022
1561a38
Added SMCPHD initiator example
sglvladi Sep 23, 2022
aac33f4
Added actionable pan-tilt camera sensors
sglvladi Sep 26, 2022
72aeb25
Added UAV camera example
sglvladi Sep 26, 2022
65821a6
Restructure custom module and tidy up defined actionable sensors
sglvladi Sep 26, 2022
a195405
Ensure default action in also returned when iterating generator in Pa…
sglvladi Sep 27, 2022
bb0e493
Doc update for fov_angle in PanTiltUAVCamera
sglvladi Sep 27, 2022
25737b2
Split pan and tilt into seperate actionables
sglvladi Sep 27, 2022
7a73825
Added SMCPHD_JIPDA tracker component
sglvladi Sep 27, 2022
cac2398
Added sensor management examples
sglvladi Sep 27, 2022
dcfc30a
Add position dependent probability of detection capability
sglvladi Sep 29, 2022
bbcd7fa
Add missing __init__.py files
sglvladi Sep 29, 2022
4ad2b74
Position dependent probability of detection fix
sglvladi Oct 26, 2022
4697fa5
Fix wrong action class in AngleUAVActionsGenerator default_action() o…
sglvladi Oct 31, 2022
5c742ee
WIP: Correct implementation of calculating camera footprint
sglvladi Nov 6, 2022
a99de2a
Increase default resolution of AngleUAVActionsGenerator
sglvladi Nov 9, 2022
5aaee57
Added pyehm and vector3d to dependencies
sglvladi Nov 15, 2022
f5c0cf6
Use log-probability calculations in SMCPHDFilter
sglvladi Nov 15, 2022
a1111a2
Added camera actions example
sglvladi Nov 21, 2022
02c7907
Added MoveableUAVCamera
sglvladi Dec 5, 2022
1527111
Added Sensor Management example with MoveableUAVCamera
sglvladi Dec 5, 2022
76feb86
Renamed minmax to limits and changed data type for MovableUAVCamera a…
sglvladi Dec 5, 2022
cff691b
Renamed radius property to fov_radius in MovableUAVCamera
sglvladi Dec 5, 2022
3fdc853
Tidy up code for MovableUAVCamera
sglvladi Dec 5, 2022
a506c50
Added RolloutUncertaintyRewardFunction
sglvladi Dec 8, 2022
aa6960e
Fix minor bug for SMCPHD_JIPDA tracker which prevented update when no…
sglvladi Dec 15, 2022
281d376
Add RolloutPriorityRewardFunction reward
sglvladi Dec 15, 2022
2f3f8ef
Monir fix in calculate_num_targets_dist() function
sglvladi Dec 15, 2022
d829f32
Patch for false initiation of closely spaced targets
sglvladi Dec 15, 2022
09caf11
Code refactoring
sglvladi Dec 21, 2022
27ff1fa
Fix issue with shapely 2.0
sglvladi Jan 3, 2023
a8413b3
Fix possible values bug in location action generators
sglvladi Jan 6, 2023
94cd65d
Reduce gate threshold for distance gater in SMCPHD_JIPDA tracker
sglvladi Jan 6, 2023
0bcb911
Add timestamp debugging
sglvladi Jan 11, 2023
3e7efa9
Remove timestamp debugging
sglvladi Jan 13, 2023
9f1333f
Fix: timezone aware timestmap in SMCPHD_JIPDA
sglvladi Jan 11, 2023
0430200
Fix wrong weighing of measurements in SMC_PHD
sglvladi Jan 17, 2023
41f8069
Increase gate threshold distance in SMCPHD_JIPDA track
sglvladi Jan 23, 2023
f5463f3
Added fov_in_km to MoveableUAVSensor
sglvladi Jan 23, 2023
f4e8b01
Rollout updates and FOLLOW RFI
sglvladi Jan 23, 2023
f485961
Minor correction to calculate_num_targets_dist
sglvladi Jan 26, 2023
34156f3
Remove unnecessary imports
sglvladi Jan 26, 2023
9fa177b
Implement Gaussian Mixture based birth intensity in SMCPHDFilter
sglvladi Jan 30, 2023
4a34b81
Add implementation of Improved SMCPHD Filter (ISMCPHDFilter) and init…
sglvladi Jan 30, 2023
a56e196
Replaced SMCPHD(Initiator) with ISMCPHD(Initiator) in SMCPHD_JIPDA tr…
sglvladi Jan 31, 2023
898b744
Remove duplicated code
sglvladi Feb 1, 2023
ec1abeb
Create custom PDAHypothesiser and use it in defined tracker(s)
sglvladi Feb 1, 2023
9b761bc
Tidy up custom/tracker.py
sglvladi Feb 1, 2023
bd48d98
Ensure trackers are picklable
sglvladi Feb 1, 2023
1dc3600
Fix StateVector has no state_vector error in SMCPHD_IGNN tracker
sglvladi Feb 2, 2023
2afa5f0
fov_in_km now defaults to True for MoveableUAVSensor
sglvladi Feb 3, 2023
a00ffe2
Added shapely and geopy to dependencies
sglvladi Feb 3, 2023
4e085fa
Updated distance calculation when fov_in_km is True in MovableUAVSensor
sglvladi Feb 3, 2023
bd77181
Added pyproj to dependencies and pinned version of shapely
sglvladi Feb 3, 2023
2830dbf
Correctly implemented prob detect functions for fov in km
sglvladi Feb 3, 2023
f3ad30d
Fix minor bug in LocationActionGenerator
sglvladi Feb 5, 2023
cbde933
Added eval_rfi function, that also attempts to reward actions that lo…
sglvladi Feb 5, 2023
a61239e
Bugfixes in RolloutPriorityRewardFunction2
sglvladi Feb 5, 2023
0a893ec
Remove unnecessary predicts in RolloutPriorityRewardFunction2
sglvladi Feb 6, 2023
18fcfa7
Sensor footprint is now a property of MovableUAVSensor, that gets aut…
sglvladi Feb 6, 2023
0423edb
Ensure MovableUAVSensor footprint is calculated correctly
sglvladi Mar 20, 2023
08c2db5
SensorManager bugfix
sglvladi Mar 20, 2023
478552b
Added rective_ist/risr-demo.py example
sglvladi Mar 20, 2023
b8d83ca
Add FuseTracker components
sglvladi May 17, 2023
88d1486
ISMCPHD fix
sglvladi May 18, 2023
2d06355
Added example fusion scenario
sglvladi May 22, 2023
e3280b2
Added MovableUAVCamera actions demo script
sglvladi May 26, 2023
8584b0c
Added MovableUAVCamera actions demo script
sglvladi Jun 5, 2023
6436aa5
ISMCPHDFilter fix for no detections
sglvladi Jun 7, 2023
0ace0b1
Add hierarchical tracking example
sglvladi Jun 9, 2023
019fb08
Hierarchical tracking example update
sglvladi Jun 15, 2023
787ccac
Add fix for non-positive/non-semi-definite measurement prediction cov…
sglvladi Jul 17, 2023
30e5396
WIP: Comms & Processing
sglvladi Jul 4, 2023
9576e70
Fix issue with fuse tracker sometimes not updating when no scans exist
sglvladi Jul 27, 2023
5b277ba
Fix/Patch LinAlgError in PDAHypothesiser
sglvladi Jul 31, 2023
5316708
Add ability to enable/disable birth weights weighting by birth densit…
sglvladi Aug 6, 2023
3afa140
Added comms & processing example
sglvladi Aug 22, 2023
ebbb74c
Minor fixes to port from RISR
sglvladi Mar 8, 2024
5f7dcef
PRH backup
paulhorridge Nov 5, 2024
6d71783
Updated example comments
paulhorridge Nov 5, 2024
12faf33
Removed unused files
paulhorridge Nov 5, 2024
ec683e5
Added missing files
paulhorridge Nov 5, 2024
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
71 changes: 71 additions & 0 deletions examples/prh_example/fusion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import numpy as np

from stonesoup.custom.types.tracklet import SensorTracks


# Create a class to represent a node in a fusion hierarchy,
class FusionNode:
"""
Class to represent a node in a fusion hierarchy
"""
def __init__(self, tracker, children, statedim, use_two_state_tracks=True):
# Tracker used at this node
self.tracker = tracker
# Child nodes used to supply tracks for fusion
self.children = children
# The dimension of a (single) target state
self.statedim = statedim
# Whether to propagate two-state tracks
self.use_two_state_tracks = use_two_state_tracks

@property
def tracks(self):
return self.tracker.tracks

@property
def detections(self):
if self.is_leaf():
return self.tracker.detector.detections
else:
sensor_scans = [d for scan in self.tracker._scans for d in scan.sensor_scans]
detections = set([d for sscan in sensor_scans for d in sscan.detections])
return detections

# Process the tracks at this node by reading in the child tracks, creating pseudomeasurements and performing
# tracking
def process_tracks(self, timestamp):
child_tracks = [child.tracker.tracks for child in self.children]
input_tracks = [SensorTracks(tracks, i) for i, tracks in enumerate(child_tracks)]
if not self.use_two_state_tracks:
input_tracks = [SensorTracks(to_single_state(track, self.statedim), i) for i, track in enumerate(input_tracks)]
two_state_tracks = self.tracker.process_tracks(input_tracks, timestamp)
if not self.use_two_state_tracks:
return to_single_state(two_state_tracks, self.statedim)
else:
return two_state_tracks

def is_leaf(self):
return len(self.children) == 0

def get_leaf_trackers(self):
if self.is_leaf():
return [self.tracker]
else:
leaf_trackers = []
for child in self.children:
leaf_trackers += child.get_leaf_trackers()
return leaf_trackers

"""
# TODO: Try to make the fusion engine more pythonic with some class structure (under construction)
def runTracker(self, timestamp):
if not self.is_leaf:
child_tracks = []
for child in self.child_trackers:
child_tracks.append(child.runTracker(timestamp))
else:
for child in self.child_trackers:
child_tracks.append()
child_
two_state_tracks
"""
58 changes: 58 additions & 0 deletions examples/prh_example/output_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import numpy as np


def output_tracks(filename, start_time, all_tracks):
# Output all the tracks from the trackers
f = open(filename, "w")
f.write(str(start_time) + "\n") # start time
f.write(str(len(all_tracks)) + "\n") # number of hierarchy levels
for i_level, level in enumerate(all_tracks):
f.write(str(i_level) + "\n") # index of this level
f.write(str(len(level)) + "\n") # number of trackers at this level
for i_tracker, tracker in enumerate(level):
f.write(str(i_tracker) + "\n") # index of this tracker
f.write(str(len(tracker)) + "\n") # number of tracks
for i_track, track in enumerate(tracker):
f.write(str(len(track)) + "\n") # number of states in track
for x in track:
f.write(str(x.timestamp) + "\n") # state timestamp
f.write(str(x.state_vector.flatten()) + "\n") # state value
f.write(str(x.covar.flatten()) + "\n") # covariance
f.close()


def output_meas(filename, start_time, platform_positions, all_detections):
np.set_printoptions(linewidth=np.inf)
f = open(filename, "w")
f.write(str(start_time) + "\n")
f.write(str(len(platform_positions)) + "\n")
for pos in platform_positions:
f.write(str(pos.flatten()) + "\n")
f.write(str(len(all_detections)) + "\n")
for i_level, level_det in enumerate(all_detections):
f.write(str(i_level) + "\n")
f.write(str(len(level_det)) + "\n")
for i_node, node_det in enumerate(level_det):
f.write(str(i_node) + "\n")
f.write(str(len(node_det)) + "\n")
for det in node_det:
f.write(str(det.timestamp) + "\n")
f.write(str(np.array(det.state_vector).flatten()) + "\n")
f.write(str(np.array(det.measurement_model.noise_covar).flatten()) + "\n")
if i_level > 0:
f.write(str(np.array(det.measurement_model.h_matrix.shape)) + "\n")
f.write(str(np.array(det.measurement_model.h_matrix).flatten()) + "\n")
f.close()


def output_truth(filename, start_time, truth):
# Output the truth
f = open(filename, "w")
f.write(str(start_time) + "\n")
f.write(str(len(truth)) + "\n")
for target in truth:
f.write(str(len(target.states)) + "\n")
for x in target.states:
f.write(str(x.timestamp) + "\n")
f.write(str(x.state_vector.flatten()) + "\n")
f.close()
65 changes: 65 additions & 0 deletions examples/prh_example/prh_funcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import numpy as np
from stonesoup.types.array import StateVector, CovarianceMatrix

def tile_with_circles(minpos, maxpos, numx, numy):
"""
Return centres and radius of a grid of circles with numx columns and numy rows which tile the region defined
by minpos and maxpos
"""
field_size = maxpos - minpos
grid_size = max(field_size[0] / numx, field_size[1] / numy)
radius = grid_size / np.sqrt(2);
grid_start = (field_size - np.array([numx - 1, numy - 1]) * grid_size) / 2.0 + minpos
centres = []
for i in range(numx):
for j in range(numy):
centres.append(grid_start + np.array([i, j]) * grid_size)
return centres, radius


def merge_position_and_velocity(position, velocity, statedim, position_mapping, velocity_mapping):
"""
Create a state by merging a position and a velocity
"""
state = StateVector(np.zeros((1, statedim)))
state[position_mapping, :] = StateVector(position)
state[velocity_mapping, :] = StateVector(velocity)
return state


def merge_position_and_velocity_covariance(poscov, velcov, statedim, position_mapping, velocity_mapping):
"""
Create a state covariance by merging a position covariance and a velocity covariance
"""
covariance = CovarianceMatrix(np.zeros((statedim, statedim)))
covariance[np.ix_(position_mapping, position_mapping)] = poscov
covariance[np.ix_(velocity_mapping, velocity_mapping)] = velcov
return covariance


def fit_normal_to_uniform(minval, maxval):
"""
"""
mean = StateVector((minval + maxval)/2.0)
cov = CovarianceMatrix(np.diag(np.power(maxval - minval, 2.0)/12.0))
return mean, cov


def to_single_state(tracks, statedim):
"""
Convert a set of tracks with two-state vectors to a set of tracks with one-state vectors
"""
new_tracks = set()
for track in tracks:
states = []
for state in track.states:
if isinstance(state, Update):
new_state = GaussianStateUpdate(state.state_vector[-statedim:], state.covar[-statedim:, -statedim:],
hypothesis=state.hypothesis,
timestamp=state.timestamp)
else:
new_state = GaussianState(state.state_vector[-statedim:], state.covar[-statedim:, -statedim:],
timestamp=state.timestamp)
states.append(new_state)
new_tracks.add(Track(id=track.id, states=states))
return new_tracks
Loading