Class NonLinearLeastSquaresLaterationSolver<P extends com.irurueta.geometry.Point<?>>
java.lang.Object
com.irurueta.navigation.lateration.LaterationSolver<P>
com.irurueta.navigation.lateration.NonLinearLeastSquaresLaterationSolver<P>
- Type Parameters:
P
- aPoint
type.
- Direct Known Subclasses:
NonLinearLeastSquaresLateration2DSolver
,NonLinearLeastSquaresLateration3DSolver
public abstract class NonLinearLeastSquaresLaterationSolver<P extends com.irurueta.geometry.Point<?>>
extends LaterationSolver<P>
Solves a Trilateration problem with an instance of the least squares optimizer.
By solving the lateration problem linearly, this class is able to estimate
the covariance of estimated position.
To achieve better results, it is usually better to provide an initial coarse
solution.
This class is base on the implementation found at:
https://github.com/lemmingapex/trilateration
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
Estimated chi square value.private com.irurueta.algebra.Matrix
Estimated covariance matrix for estimated position.static final double
Default standard deviation assumed for provided distances when none is explicitly provided.private double[]
Standard deviations of provided distances.private final com.irurueta.numerical.fitting.LevenbergMarquardtMultiDimensionFitter
Levenberg-Marquardt fitter to find a non-linear solution.private P
Initial position to start lateration solving.Fields inherited from class com.irurueta.navigation.lateration.LaterationSolver
distances, EPSILON, estimatedPositionCoordinates, listener, locked, positions
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P initialPosition) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations, LaterationSolverListener<P> listener) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations, P initialPosition) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations, P initialPosition, LaterationSolverListener<P> listener) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, LaterationSolverListener<P> listener) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, P initialPosition) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P[] positions, double[] distances, P initialPosition, LaterationSolverListener<P> listener) Constructor.protected
NonLinearLeastSquaresLaterationSolver
(P initialPosition, LaterationSolverListener<P> listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getChiSq()
Gets estimated chi square value.com.irurueta.algebra.Matrix
Gets estimated covariance matrix for estimated position.double[]
Gets standard deviations of provided distances.Gets initial position to start lateration solving.getType()
Gets lateration solver type.protected void
internalSetPositionsAndDistances
(P[] positions, double[] distances) Internally sets known positions and Euclidean distances.protected void
internalSetPositionsDistancesAndStandardDeviations
(P[] positions, double[] distances, double[] distanceStandardDeviations) Internally sets known positions, Euclidean distances and the respective standard deviations of measured distances.void
setInitialPosition
(P initialPosition) Sets initial position to start lateration solving.void
setPositionsAndDistances
(P[] positions, double[] distances) Sets known positions and Euclidean distances.void
setPositionsDistancesAndStandardDeviations
(P[] positions, double[] distances, double[] distanceStandardDeviations) Sets known positions, Euclidean distances and the respective standard deviations of measured distances.private void
Setups fitter to solve lateration problem.void
solve()
Solves the lateration problem.Methods inherited from class com.irurueta.navigation.lateration.LaterationSolver
getDistances, getEstimatedPosition, getEstimatedPosition, getEstimatedPositionCoordinates, getListener, getMinRequiredPositionsAndDistances, getNumberOfDimensions, getPositions, isLocked, isReady, setListener
-
Field Details
-
DEFAULT_DISTANCE_STANDARD_DEVIATION
public static final double DEFAULT_DISTANCE_STANDARD_DEVIATIONDefault standard deviation assumed for provided distances when none is explicitly provided.- See Also:
-
fitter
private final com.irurueta.numerical.fitting.LevenbergMarquardtMultiDimensionFitter fitterLevenberg-Marquardt fitter to find a non-linear solution. -
covariance
private com.irurueta.algebra.Matrix covarianceEstimated covariance matrix for estimated position. -
chiSq
private double chiSqEstimated chi square value. -
initialPosition
Initial position to start lateration solving. If not defined, centroid of provided position points will be used. -
distanceStandardDeviations
private double[] distanceStandardDeviationsStandard deviations of provided distances.
-
-
Constructor Details
-
NonLinearLeastSquaresLaterationSolver
protected NonLinearLeastSquaresLaterationSolver()Constructor. -
NonLinearLeastSquaresLaterationSolver
Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required 2 points.
-
NonLinearLeastSquaresLaterationSolver
Constructor.- Parameters:
initialPosition
- initial position to start lateration solving.
-
NonLinearLeastSquaresLaterationSolver
protected NonLinearLeastSquaresLaterationSolver(P[] positions, double[] distances, P initialPosition) Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.initialPosition
- initial position to start lateration solving.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (3 for 2D points or 4 for 3D points) or fitter is null.
-
NonLinearLeastSquaresLaterationSolver
protected NonLinearLeastSquaresLaterationSolver(P[] positions, double[] distances, double[] distanceStandardDeviations) Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length of their length is smaller than required (2 points).
-
NonLinearLeastSquaresLaterationSolver
protected NonLinearLeastSquaresLaterationSolver(P[] positions, double[] distances, double[] distanceStandardDeviations, P initialPosition) Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.initialPosition
- initial position to start lateration solving.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length of their length is smaller than required (2 points).
-
-
Method Details
-
setPositionsAndDistances
Sets known positions and Euclidean distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Overrides:
setPositionsAndDistances
in classLaterationSolver<P extends com.irurueta.geometry.Point<?>>
- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).LockedException
- if instance is busy solving the lateration problem.
-
setPositionsDistancesAndStandardDeviations
public void setPositionsDistancesAndStandardDeviations(P[] positions, double[] distances, double[] distanceStandardDeviations) throws LockedException Sets known positions, Euclidean distances and the respective standard deviations of measured distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length of their length is smaller than required (2 points).LockedException
- if instance is busy solving the trilateration problem.
-
getDistanceStandardDeviations
public double[] getDistanceStandardDeviations()Gets standard deviations of provided distances.- Returns:
- standard deviations of provided distances.
-
getCovariance
public com.irurueta.algebra.Matrix getCovariance()Gets estimated covariance matrix for estimated position.- Returns:
- estimated covariance matrix for estimated position.
-
getChiSq
public double getChiSq()Gets estimated chi square value.- Returns:
- estimated chi square value.
-
getInitialPosition
Gets initial position to start lateration solving. If not defined, centroid of provided position points will be used to start lateration.- Returns:
- initial position to start lateration.
-
setInitialPosition
Sets initial position to start lateration solving. If not defined, centroid of provided position points will be used to start lateration.- Parameters:
initialPosition
- initial position to start lateration.- Throws:
LockedException
- if instance is busy solving the lateration problem.
-
solve
Solves the lateration problem.- Specified by:
solve
in classLaterationSolver<P extends com.irurueta.geometry.Point<?>>
- Throws:
LaterationException
- if lateration fails.NotReadyException
- is solver is not ready.LockedException
- if instance is busy solving the lateration problem.
-
getType
Gets lateration solver type.- Specified by:
getType
in classLaterationSolver<P extends com.irurueta.geometry.Point<?>>
- Returns:
- lateration solver type.
-
internalSetPositionsAndDistances
Internally sets known positions and Euclidean distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Overrides:
internalSetPositionsAndDistances
in classLaterationSolver<P extends com.irurueta.geometry.Point<?>>
- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).
-
internalSetPositionsDistancesAndStandardDeviations
protected void internalSetPositionsDistancesAndStandardDeviations(P[] positions, double[] distances, double[] distanceStandardDeviations) Internally sets known positions, Euclidean distances and the respective standard deviations of measured distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length of their length is smaller than required (2 points).
-
setupFitter
private void setupFitter() throws com.irurueta.numerical.fitting.FittingExceptionSetups fitter to solve lateration problem.- Throws:
com.irurueta.numerical.fitting.FittingException
- if Levenberg-Marquardt fitting fails.
-