-
Notifications
You must be signed in to change notification settings - Fork 141
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
Addition of Efficient/Lagrangian Point-Mass Filter #1052
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1052 +/- ##
==========================================
+ Coverage 93.69% 93.72% +0.02%
==========================================
Files 212 214 +2
Lines 13881 13993 +112
Branches 1922 1923 +1
==========================================
+ Hits 13006 13115 +109
- Misses 623 627 +4
+ Partials 252 251 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
functions.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file required? Looks like added functionality from the file e.g. gridCreation has been added to functions/init.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have deleted the file.
stonesoup/functions/__init__.py
Outdated
gridDim = np.zeros((nx, Npa[0])) | ||
gridStep = np.zeros(nx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are unused and so can be removed as they redefined below.
gridDim = np.zeros((nx, Npa[0])) | |
gridStep = np.zeros(nx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
stonesoup/functions/__init__.py
Outdated
combvec_predGrid = np.array(list(itertools.product(*gridDim))) | ||
predGrid_pom = np.dot(eigVect, combvec_predGrid.T) | ||
size_pom = np.size(predGrid_pom, 1) | ||
# Grid rotation by eigenvectors and traslation to the counted unscented mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Grid rotation by eigenvectors and traslation to the counted unscented mean | |
# Grid rotation by eigenvectors and translation to the counted unscented mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
stonesoup/predictor/pointMass.py
Outdated
sFactor: float = Property(default=4, doc="How many sigma to cover by the grid") | ||
|
||
# @profile | ||
def predict(self, prior, timestamp=1, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def predict(self, prior, timestamp=1, **kwargs): | |
def predict(self, prior, timestamp=None, **kwargs): |
Default timestamp is an int, which contradicts documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
stonesoup/predictor/pointMass.py
Outdated
An implementation of a Particle Filter predictor. | ||
""" | ||
|
||
sFactor: float = Property(default=4, doc="How many sigma to cover by the grid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sFactor: float = Property(default=4, doc="How many sigma to cover by the grid") | |
sFactor: float = Property(default=4., doc="How many sigma to cover by the grid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
stonesoup/predictor/pointMass.py
Outdated
"""ParticlePredictor class | ||
|
||
An implementation of a Particle Filter predictor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring is that for the ParticlePredictor, could you change it, even if it's just ParticlePredictor -> PointMassPredictor :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Sorry. As said below. :)
stonesoup/types/state.py
Outdated
"""Sample mean for particles""" | ||
return np.hstack(self.state_vector @ self.weight * np.prod(self.grid_delta)) | ||
|
||
# @profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# @profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted
stonesoup/updater/pointMass.py
Outdated
Perform an update by multiplying grid points weights by PDF of measurement | ||
model | ||
""" | ||
sFactor: float = Property(default=4, doc="How many sigma to cover by the grid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sFactor: float = Property(default=4, doc="How many sigma to cover by the grid") | |
sFactor: float = Property(default=4., doc="How many sigma to cover by the grid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
stonesoup/updater/pointMass.py
Outdated
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
# @profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# @profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted
stonesoup/types/prediction.py
Outdated
"""ParticleStatePrediction type | ||
|
||
This is a simple Particle state prediction object. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring is for ParticleStatePrediction, could you make a minor change to make it relevant for PointMassStatePrediction ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am a bit new to both python and GitHub and getting lost sometimes, so I don't see obvious mistakes. Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also lost what at what is the purpose of the prediction object, but everything seems to be working....
Thank you for your comments. I think I have fixed the codes based on them. I have also merged my branch with the latest changes. And it seems I have fixed all the issues so the code should run all of the testes successfully. Hopefully we can finish the pull request. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final comments - just need to change the name of the predictor and updater files to maintain python naming conventions.
Once that's done I'm happy to approve this. This is some great work!
stonesoup/predictor/pointMass.py
Outdated
A prior state object | ||
timestamp: :class:`datetime.datetime`, optional | ||
A timestamp signifying when the prediction is performed | ||
(the default is `1`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the default is `1`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
stonesoup/updater/pointMass.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to maintain python file naming convention, could you change the name of this file to pointmass.py? Note that the import for this in test_pointmass.py will then need to be changed to reflect this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you for mentioning the test.
stonesoup/predictor/pointMass.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to maintain python file naming convention, could you change the name of this file to pointmass.py? Note that the import for this in test_pointmass.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Comments should be addressed. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor changes needed for matlib
which is deprecated and using meshgrid rather than itertools. But other wise looks good.
diff --git a/stonesoup/functions/__init__.py b/stonesoup/functions/__init__.py
index de1ac82a..aac10c57 100644
--- a/stonesoup/functions/__init__.py
+++ b/stonesoup/functions/__init__.py
@@ -1,20 +1,18 @@
"""Mathematical functions used within Stone Soup"""
import copy
-import itertools
import warnings
from functools import lru_cache
import numpy as np
from numpy import linalg as LA
-from numpy import matlib as matlib
from ..types.array import CovarianceMatrix, StateVector, StateVectors
from ..types.numeric import Probability
from ..types.state import State
-def gridCreation(xp_aux, Pp_aux, sFactor, nx, Npa):
+def grid_creation(xp_aux, Pp_aux, sFactor, nx, Npa):
"""Grid for point mass filter
Create a PMF grid based on center, covariance matrix, and sigma probability
@@ -69,11 +67,10 @@ def gridCreation(xp_aux, Pp_aux, sFactor, nx, Npa):
gridDim.append(np.linspace(-gridBound[ind3], gridBound[ind3], Npa[ind3]))
gridStep.append(np.absolute(gridDim[ind3][0] - gridDim[ind3][1])) # Grid step
- combvec_predGrid = np.array(list(itertools.product(*gridDim)))
- predGrid_pom = np.dot(eigVect, combvec_predGrid.T)
- size_pom = np.size(predGrid_pom, 1)
+ combvec_predGrid = np.array(np.meshgrid(*gridDim, indexing='ij')).reshape(nx, -1).T
+ predGrid = np.dot(eigVect, combvec_predGrid.T)
# Grid rotation by eigenvectors and translation to the counted unscented mean
- predGrid = predGrid_pom + matlib.repmat(xp_aux, 1, size_pom)
+ predGrid += xp_aux
predGridDelta = gridStep # Grid step size
return predGrid, predGridDelta, gridDim, xp_aux, eigVect
There is some issues with some other changes unrealted to this PR scope, I think caused by a merge from main branch. I'll add the change above and resolve this issue with a squash merge.
Thanks for the great contribution @pesslovany and apologies it's taken so long for us to get around to reviewing this.
J. Matoušek, J. Duník and M. Brandner, "Design of Efficient Point-Mass Filter with Terrain Aided Navigation Illustration," 2023 26th International Conference on Information Fusion (FUSION), Charleston, SC, USA, 2023, pp. 1-8, doi: 10.23919/FUSION52260.2023.10224172.
J. Matoušek, J. Duník, M. Brandner, Chan Gook Park, Yeongkwon Choe,
Efficient Point Mass Predictor for Continuous and Discrete Models with Linear Dynamics,IFAC-PapersOnLine,Volume 56, Issue 2,2023,Pages 5937-5942,ISSN 2405-8963,https://doi.org/10.1016/j.ifacol.2023.10.621.
J. Matoušek, J. Duník, O. Straka,
Lagrangian Grid-Based Filters with Application to Terrain-Aided Navigation
IEEE Signal Processing Magazine - Accepted, to be published
Added points mass updater, point mass predictor, and point mass state.