Class RobustPositionEstimator<P extends com.irurueta.geometry.Point<?>,R extends Reading<? extends RadioSource>,L extends RobustPositionEstimatorListener<? extends RobustPositionEstimator<?,?,?>>>
java.lang.Object
com.irurueta.navigation.indoor.position.RobustPositionEstimator<P,R,L>
- Type Parameters:
P- aPointtype.R- aReadingtype.L- aRobustPositionEstimatorListenertype.
- Direct Known Subclasses:
RobustMixedPositionEstimator,RobustRangingAndRssiPositionEstimator,RobustRangingPositionEstimator,RobustRssiPositionEstimator
public abstract class RobustPositionEstimator<P extends com.irurueta.geometry.Point<?>,R extends Reading<? extends RadioSource>,L extends RobustPositionEstimatorListener<? extends RobustPositionEstimator<?,?,?>>>
extends Object
Base class for robust position estimators using located radio sources and their
readings at unknown locations.
These kind of estimators can be used to robustly determine the position of a given
device by getting readings at an unknown location of different radio sources whose
locations are known.
Implementations of this class should be able to detect and discard outliers in order
to find the best solution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanIndicates that by default readings are distributed evenly among radio sources taking into account quality scores of both radio sources and readings.static final com.irurueta.numerical.robust.RobustEstimatorMethodDefault robust estimator method when none is provided.static final booleanIndicates that by default located radio source position covariance is taken into account (if available) to determine distance standard deviation.private booleanIndicates whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings.static final doubleDistance standard deviation assumed for provided distances as a fallback when none can be determined.private doubleDistance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings.protected Fingerprint<? extends RadioSource, ? extends R> Fingerprint containing readings at an unknown location for provided located radio sources.protected com.irurueta.navigation.lateration.RobustLaterationSolver<P> A robust lateration solver to solve position.protected LListener to be notified of events raised by this instance.protected intSize of subsets to be checked during robust estimation.protected List<? extends RadioSourceLocated<P>> Located radio sources used for lateration.protected com.irurueta.navigation.lateration.RobustLaterationSolverListener<P> Listener for the robust lateration solver.private booleanIndicates whether located radio source position covariances must be taken into account (if available) to determine distance standard deviation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.protectedRobustPositionEstimator(L listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidBuilds positions, distances, standard deviation of distances and quality scores for the internal lateration solver.estimate()Estimates position based on provided located radio sources and readings of such sources at an unknown location.doubleReturns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).com.irurueta.algebra.MatrixGets estimated covariance of estimated position if available.double[]Gets Euclidean distances from known located radio sources to the location of provided readings in a fingerprint.double[]Gets standard deviation distances from known located radio sources to the location of provided readings in a fingerprint.Gets estimated position.booleanIndicates whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings.doubleGets distance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings.Gets fingerprint containing readings at an unknown location for provided located radio sources.double[]Gets quality scores corresponding to each reading within provided fingerprint.Gets initial position to use as a starting point to find a new solution.com.irurueta.numerical.robust.InliersDataGets data related to inliers found after estimation.Gets listener to be notified of events raised by this instance.intReturns maximum allowed number of iterations.abstract com.irurueta.numerical.robust.RobustEstimatorMethodReturns method being used for robust estimation.abstract intGets minimum required number of located radio sources to perform lateration.intGets number of dimensions of provided points.P[]Gets known positions of radio sources used internally to solve lateration.intGets size of subsets to be checked during robust estimation.floatReturns amount of progress variation before notifying a progress change during estimation.double[]Returns quality scores corresponding to each radio source.Gets located radio sources used for lateration.protected voidinternalSetFingerprint(Fingerprint<? extends RadioSource, ? extends R> fingerprint) Internally sets fingerprint containing readings at an unknown location for provided located radio sources.protected voidinternalSetSources(List<? extends RadioSourceLocated<P>> sources) Internally sets located radio sources used for lateration.booleanIndicates whether covariance must be kept after refining result.booleanIndicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.booleanIndicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.booleanisLocked()Returns boolean indicating if estimator is locked because estimation is under progress.booleanIndicates whether preliminary solutions must be refined after an initial linear solution is found.booleanIndicates whether located radio source position covariance must be taken into account (if available) to determine distance standard deviation.booleanisReady()Indicates whether estimator is ready to find a solution.booleanIndicates whether result must be refined using a non-linear estimator over found inliers.voidsetConfidence(double confidence) Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).voidsetCovarianceKept(boolean keepCovariance) Specifies whether covariance must be kept after refining result.voidsetEvenlyDistributeReadings(boolean evenlyDistributeReadings) Specifies whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings.voidsetFallbackDistanceStandardDeviation(double fallbackDistanceStandardDeviation) Sets distance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings.voidsetFingerprint(Fingerprint<? extends RadioSource, ? extends R> fingerprint) Sets fingerprint containing readings at an unknown location for provided located radio sources.voidsetFingerprintReadingsQualityScores(double[] fingerprintReadingsQualityScores) Sets quality scores corresponding to each reading within provided fingerprint.voidsetHomogeneousLinearSolverUsed(boolean useHomogeneousLinearSolver) Specifies whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.voidsetInitialPosition(P initialPosition) Sets initial position to use as a starting point to find a new solution.voidsetLinearSolverUsed(boolean linearSolverUsed) Specifies whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.voidsetListener(L listener) Sets listener to be notified of events raised by this instance.voidsetMaxIterations(int maxIterations) Sets maximum allowed number of iterations.protected abstract voidsetPositionsDistancesDistanceStandardDeviationsAndQualityScores(List<P> positions, List<Double> distances, List<Double> distanceStandardDeviations, List<Double> distanceQualityScores) Sets positions, distances and standard deviations of distances on internal lateration solver.voidsetPreliminarySolutionRefined(boolean preliminarySolutionRefined) Specifies whether preliminary solutions must be refined after an initial linear solution is found.voidsetPreliminarySubsetSize(int preliminarySubsetSize) Sets size of subsets to be checked during robust estimation.voidsetProgressDelta(float progressDelta) Sets amount of progress variation before notifying a progress change during estimation.voidsetRadioSourcePositionCovarianceUsed(boolean useRadioSourcePositionCovariance) Specifies whether located radio source position covariance must be taken into account (if available) to determine distance standard deviation.voidsetResultRefined(boolean refineResult) Specifies whether result must be refined using a non-linear estimator over found inliers.voidsetSourceQualityScores(double[] sourceQualityScores) Sets quality scores corresponding to each radio source.voidsetSources(List<? extends RadioSourceLocated<P>> sources) Sets located radio sources used for lateration.
-
Field Details
-
DEFAULT_ROBUST_METHOD
public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHODDefault robust estimator method when none is provided. -
DEFAULT_USE_RADIO_SOURCE_POSITION_COVARIANCE
public static final boolean DEFAULT_USE_RADIO_SOURCE_POSITION_COVARIANCEIndicates that by default located radio source position covariance is taken into account (if available) to determine distance standard deviation.- See Also:
-
DEFAULT_EVENLY_DISTRIBUTE_READINGS
public static final boolean DEFAULT_EVENLY_DISTRIBUTE_READINGSIndicates that by default readings are distributed evenly among radio sources taking into account quality scores of both radio sources and readings.- See Also:
-
FALLBACK_DISTANCE_STANDARD_DEVIATION
public static final double FALLBACK_DISTANCE_STANDARD_DEVIATIONDistance standard deviation assumed for provided distances as a fallback when none can be determined.- See Also:
-
sources
Located radio sources used for lateration. -
fingerprint
protected Fingerprint<? extends RadioSource,? extends R extends Reading<? extends RadioSource>> fingerprintFingerprint containing readings at an unknown location for provided located radio sources. -
useRadioSourcePositionCovariance
private boolean useRadioSourcePositionCovarianceIndicates whether located radio source position covariances must be taken into account (if available) to determine distance standard deviation. -
evenlyDistributeReadings
private boolean evenlyDistributeReadingsIndicates whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings. -
fallbackDistanceStandardDeviation
private double fallbackDistanceStandardDeviationDistance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings. -
listener
protected L extends RobustPositionEstimatorListener<? extends RobustPositionEstimator<?,?, listener?>> Listener to be notified of events raised by this instance. -
laterationSolver
protected com.irurueta.navigation.lateration.RobustLaterationSolver<P extends com.irurueta.geometry.Point<?>> laterationSolverA robust lateration solver to solve position. -
trilaterationSolverListener
protected com.irurueta.navigation.lateration.RobustLaterationSolverListener<P extends com.irurueta.geometry.Point<?>> trilaterationSolverListenerListener for the robust lateration solver. -
preliminarySubsetSize
protected int preliminarySubsetSizeSize of subsets to be checked during robust estimation.
-
-
Constructor Details
-
RobustPositionEstimator
protected RobustPositionEstimator()Constructor. -
RobustPositionEstimator
Constructor.- Parameters:
listener- listener in charge of handling events.
-
-
Method Details
-
getSources
Gets located radio sources used for lateration.- Returns:
- located radio sources used for lateration.
-
setSources
public void setSources(List<? extends RadioSourceLocated<P>> sources) throws com.irurueta.navigation.LockedException Sets located radio sources used for lateration.- Parameters:
sources- located radio sources used for lateration.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.IllegalArgumentException- if provided value is null or the number of provided sources is less than the required minimum.
-
getFingerprint
Gets fingerprint containing readings at an unknown location for provided located radio sources.- Returns:
- fingerprint containing readings at an unknown location for provided located radio sources.
-
getListener
Gets listener to be notified of events raised by this instance.- Returns:
- listener to be notified of events raised by this instance.
-
setListener
Sets listener to be notified of events raised by this instance.- Parameters:
listener- listener to be notified of events raised by this instance.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
isRadioSourcePositionCovarianceUsed
public boolean isRadioSourcePositionCovarianceUsed()Indicates whether located radio source position covariance must be taken into account (if available) to determine distance standard deviation.- Returns:
- true to take radio source position covariance into account, false otherwise.
-
setRadioSourcePositionCovarianceUsed
public void setRadioSourcePositionCovarianceUsed(boolean useRadioSourcePositionCovariance) throws com.irurueta.navigation.LockedException Specifies whether located radio source position covariance must be taken into account (if available) to determine distance standard deviation.- Parameters:
useRadioSourcePositionCovariance- true to take radio source position covariance into account, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
getEvenlyDistributeReadings
public boolean getEvenlyDistributeReadings()Indicates whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings.- Returns:
- true if readings are evenly distributed, false otherwise.
-
setEvenlyDistributeReadings
public void setEvenlyDistributeReadings(boolean evenlyDistributeReadings) throws com.irurueta.navigation.LockedException Specifies whether readings are evenly distributed among radio sources taking into account quality scores of both radio sources and readings.- Parameters:
evenlyDistributeReadings- true if readings are evenly distributed, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
getFallbackDistanceStandardDeviation
public double getFallbackDistanceStandardDeviation()Gets distance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings.- Returns:
- distance standard deviation to use as fallback.
-
setFallbackDistanceStandardDeviation
public void setFallbackDistanceStandardDeviation(double fallbackDistanceStandardDeviation) throws com.irurueta.navigation.LockedException Sets distance standard deviation fallback value to use when none can be determined from provided radio sources and fingerprint readings.- Parameters:
fallbackDistanceStandardDeviation- distance standard deviation to use as fallback.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
isLocked
public boolean isLocked()Returns boolean indicating if estimator is locked because estimation is under progress.- Returns:
- true if estimator is locked, false otherwise.
-
getProgressDelta
public float getProgressDelta()Returns amount of progress variation before notifying a progress change during estimation.- Returns:
- amount of progress variation before notifying a progress change during estimation.
-
setProgressDelta
public void setProgressDelta(float progressDelta) throws com.irurueta.navigation.LockedException Sets amount of progress variation before notifying a progress change during estimation.- Parameters:
progressDelta- amount of progress variation before notifying a progress change during estimation.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.IllegalArgumentException- if progress delta is less than zero or greater than 1.
-
getConfidence
public double getConfidence()Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Returns:
- amount of confidence as a value between 0.0 and 1.0.
-
setConfidence
public void setConfidence(double confidence) throws com.irurueta.navigation.LockedException Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Parameters:
confidence- confidence to be set as a value between 0.0 and 1.0.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.IllegalArgumentException- if provided value is not between 0.0 and 1.0.
-
getMaxIterations
public int getMaxIterations()Returns maximum allowed number of iterations. If maximum allowed number of iterations is achieved without converging to a result when calling solve(), a RobustEstimatorException will be raised.- Returns:
- maximum allowed number of iterations.
-
setMaxIterations
public void setMaxIterations(int maxIterations) throws com.irurueta.navigation.LockedException Sets maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.- Parameters:
maxIterations- maximum allowed number of iterations to be set.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.IllegalArgumentException- if provided value is less than 1.
-
isResultRefined
public boolean isResultRefined()Indicates whether result must be refined using a non-linear estimator over found inliers.- Returns:
- true to refine result, false to simply use result found by robust estimator without further refining.
-
setResultRefined
public void setResultRefined(boolean refineResult) throws com.irurueta.navigation.LockedException Specifies whether result must be refined using a non-linear estimator over found inliers.- Parameters:
refineResult- true to refine result, false to simply use result found by robust estimator without further refining.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.
-
isCovarianceKept
public boolean isCovarianceKept()Indicates whether covariance must be kept after refining result. This setting is only taken into account if result is refined.- Returns:
- true if covariance must be kept after refining result, false otherwise.
-
setCovarianceKept
public void setCovarianceKept(boolean keepCovariance) throws com.irurueta.navigation.LockedException Specifies whether covariance must be kept after refining result. This setting is only taken into account if result is refined.- Parameters:
keepCovariance- true if covariance must be kept after refining result, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.
-
getInitialPosition
Gets initial position to use as a starting point to find a new solution. This is optional, but if provided, when no linear solvers are used, this is taken into account. If linear solvers are used, this is ignored.- Returns:
- an initial position.
-
setInitialPosition
Sets initial position to use as a starting point to find a new solution. This is optional, but if provided, when no linear solvers are used, this is taken into account. If linear solvers are used, this is ignored.- Parameters:
initialPosition- an initial position.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.
-
isLinearSolverUsed
public boolean isLinearSolverUsed()Indicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.- Returns:
- true if a linear solver is used, false otherwise.
-
setLinearSolverUsed
public void setLinearSolverUsed(boolean linearSolverUsed) throws com.irurueta.navigation.LockedException Specifies whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.- Parameters:
linearSolverUsed- true if a linear solver is used, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.
-
isHomogeneousLinearSolverUsed
public boolean isHomogeneousLinearSolverUsed()Indicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.- Returns:
- true if homogeneous linear solver is used, false otherwise.
-
setHomogeneousLinearSolverUsed
public void setHomogeneousLinearSolverUsed(boolean useHomogeneousLinearSolver) throws com.irurueta.navigation.LockedException Specifies whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.- Parameters:
useHomogeneousLinearSolver- true if homogeneous linear solver is used, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
isPreliminarySolutionRefined
public boolean isPreliminarySolutionRefined()Indicates whether preliminary solutions must be refined after an initial linear solution is found. If no initial solution is found using a linear solver, a non-linear solver will be used regardless of this value using an average solution as the initial value to be refined.- Returns:
- true if preliminary solutions must be refined after an initial linear solution, false otherwise.
-
setPreliminarySolutionRefined
public void setPreliminarySolutionRefined(boolean preliminarySolutionRefined) throws com.irurueta.navigation.LockedException Specifies whether preliminary solutions must be refined after an initial linear solution is found. If no initial solution is found using a linear solver, a non-linear solver will be used regardless of this value using an average solution as the initial value to be refined.- Parameters:
preliminarySolutionRefined- true if preliminary solutions must be refined after an initial linear solution, false otherwise.- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.
-
getInliersData
public com.irurueta.numerical.robust.InliersData getInliersData()Gets data related to inliers found after estimation. Inlier data is related to the internal positions and distances used for solving lateration.- Returns:
- data related to inliers found after estimation.
-
getPositions
Gets known positions of radio sources used internally to solve lateration.- Returns:
- known positions used internally.
-
getDistances
public double[] getDistances()Gets Euclidean distances from known located radio sources to the location of provided readings in a fingerprint. Distance values are used internally to solve lateration.- Returns:
- Euclidean distances used internally.
-
getDistanceStandardDeviations
public double[] getDistanceStandardDeviations()Gets standard deviation distances from known located radio sources to the location of provided readings in a fingerprint. Distance standard deviations are used internally to solve lateration.- Returns:
- standard deviations used internally.
-
isReady
public boolean isReady()Indicates whether estimator is ready to find a solution.- Returns:
- true if estimator is ready, false otherwise.
-
getSourceQualityScores
public double[] getSourceQualityScores()Returns quality scores corresponding to each radio source. The larger the score value the better the quality of the sample. This implementation always returns null. Subclasses using quality scores must implement proper behavior.- Returns:
- quality scores corresponding to each radio source.
-
setSourceQualityScores
public void setSourceQualityScores(double[] sourceQualityScores) throws com.irurueta.navigation.LockedException Sets quality scores corresponding to each radio source. The larger the score value the better the quality of the radio source. This implementation makes no action. Subclasses using quality scores must implement proper behavior.- Parameters:
sourceQualityScores- quality scores corresponding to each radio source.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.IllegalArgumentException- if provided quality scores length is smaller than minimum required samples.
-
getFingerprintReadingsQualityScores
public double[] getFingerprintReadingsQualityScores()Gets quality scores corresponding to each reading within provided fingerprint. The larger the score value the better the quality of the reading. This implementation always returns null. Subclasses using quality scores must implement proper behavior.- Returns:
- quality scores corresponding to each reading within provided fingerprint.
-
setFingerprintReadingsQualityScores
public void setFingerprintReadingsQualityScores(double[] fingerprintReadingsQualityScores) throws com.irurueta.navigation.LockedException Sets quality scores corresponding to each reading within provided fingerprint. The larger the score value the better the quality of the reading. This implementation makes no action. Subclasses using quality scores must implement proper behavior.- Parameters:
fingerprintReadingsQualityScores- quality scores corresponding to each reading within provided fingerprint.- Throws:
com.irurueta.navigation.LockedException- if this instance is locked.IllegalArgumentException- if provided quality scores length is smaller than minimum required samples.
-
getPreliminarySubsetSize
public int getPreliminarySubsetSize()Gets size of subsets to be checked during robust estimation. This has to be at leastgetMinRequiredSources().- Returns:
- size of subsets to be checked during robust estimation.
-
setPreliminarySubsetSize
public void setPreliminarySubsetSize(int preliminarySubsetSize) throws com.irurueta.navigation.LockedException Sets size of subsets to be checked during robust estimation. This has to be at leastgetMinRequiredSources().- Parameters:
preliminarySubsetSize- size of subsets to be checked during robust estimation.- Throws:
com.irurueta.navigation.LockedException- if instance is busy solving the lateration problem.IllegalArgumentException- if provided value is less thangetMinRequiredSources().
-
getCovariance
public com.irurueta.algebra.Matrix getCovariance()Gets estimated covariance of estimated position if available. This is only available when result has been refined and covariance is kept.- Returns:
- estimated covariance or null.
-
getEstimatedPosition
Gets estimated position.- Returns:
- estimated position.
-
getNumberOfDimensions
public int getNumberOfDimensions()Gets number of dimensions of provided points.- Returns:
- number of dimensions of provided points.
-
estimate
public P estimate() throws com.irurueta.navigation.LockedException, com.irurueta.navigation.NotReadyException, com.irurueta.numerical.robust.RobustEstimatorExceptionEstimates position based on provided located radio sources and readings of such sources at an unknown location.- Returns:
- estimated position.
- Throws:
com.irurueta.navigation.LockedException- if estimator is locked.com.irurueta.navigation.NotReadyException- if estimator is not ready.com.irurueta.numerical.robust.RobustEstimatorException- if estimation fails for some other reason.
-
getMinRequiredSources
public abstract int getMinRequiredSources()Gets minimum required number of located radio sources to perform lateration.- Returns:
- minimum required number of located radio sources to perform lateration.
-
getMethod
public abstract com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()Returns method being used for robust estimation.- Returns:
- method being used for robust estimation.
-
internalSetSources
Internally sets located radio sources used for lateration.- Parameters:
sources- located radio sources used for lateration.- Throws:
IllegalArgumentException- if provided value is null or the number of provided sources is less than the required minimum.
-
setPositionsDistancesDistanceStandardDeviationsAndQualityScores
protected abstract void setPositionsDistancesDistanceStandardDeviationsAndQualityScores(List<P> positions, List<Double> distances, List<Double> distanceStandardDeviations, List<Double> distanceQualityScores) Sets positions, distances and standard deviations of distances on internal lateration solver.- Parameters:
positions- positions to be set.distances- distances to be set.distanceStandardDeviations- standard deviations of distances to be set.distanceQualityScores- distance quality scores or null if not required.
-
buildPositionsDistancesDistanceStandardDeviationsAndQualityScores
protected void buildPositionsDistancesDistanceStandardDeviationsAndQualityScores()Builds positions, distances, standard deviation of distances and quality scores for the internal lateration solver.
-