Class LaterationSolver<P extends com.irurueta.geometry.Point<?>>

java.lang.Object
com.irurueta.navigation.lateration.LaterationSolver<P>
Type Parameters:
P - a Point type.
Direct Known Subclasses:
HomogeneousLinearLeastSquaresLaterationSolver, InhomogeneousLinearLeastSquaresLaterationSolver, NonLinearLeastSquaresLaterationSolver

public abstract class LaterationSolver<P extends com.irurueta.geometry.Point<?>> extends Object
Solves the lateration problem. This is a formulation for a nonlinear least squares optimizer. This class is base on the implementation found at: https://github.com/lemmingapex/trilateration
  • Field Details

    • EPSILON

      public static final double EPSILON
      Minimum allowed distance for a given circle or sphere.
      See Also:
    • positions

      protected P extends com.irurueta.geometry.Point<?>[] positions
      Known positions of static nodes.
    • distances

      protected double[] distances
      Euclidean distances from static nodes to mobile node.
    • listener

      protected LaterationSolverListener<P extends com.irurueta.geometry.Point<?>> listener
      Listener to be notified of events raised by this instance.
    • estimatedPositionCoordinates

      protected double[] estimatedPositionCoordinates
      Estimated inhomogeneous position coordinates.
    • locked

      protected boolean locked
      Indicates if this instance is locked because lateration is being solved.
  • Constructor Details

    • LaterationSolver

      protected LaterationSolver()
      Constructor.
    • LaterationSolver

      protected LaterationSolver(P[] positions, double[] distances)
      Constructor. Sets known positions and Euclidean distances.
      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 (3 for 2D points or 4 for 3D points).
    • LaterationSolver

      protected LaterationSolver(LaterationSolverListener<P> listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events raised by this instance.
    • LaterationSolver

      protected LaterationSolver(P[] positions, double[] distances, LaterationSolverListener<P> listener)
      Constructor. Sets known positions and Euclidean distances.
      Parameters:
      positions - known positions of static nodes.
      distances - euclidean distances from static nodes to mobile node.
      listener - listener to be notified of events raised by this instance.
      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).
  • Method Details

    • getListener

      public LaterationSolverListener<P> getListener()
      Gets listener to be notified of events raised by this instance.
      Returns:
      listener to be notified of events raised by this instance.
    • setListener

      public void setListener(LaterationSolverListener<P> listener) throws LockedException
      Sets listener to be notified of events raised by this instance.
      Parameters:
      listener - listener to be notified of events raised by this instance.
      Throws:
      LockedException - if instance is busy solving the lateration problem.
    • getPositions

      public P[] getPositions()
      Gets known positions of static nodes.
      Returns:
      known positions of static nodes.
    • getDistances

      public double[] getDistances()
      Gets euclidean distances from static nodes to mobile node.
      Returns:
      euclidean distances from static nodes to mobile node.
    • isReady

      public boolean isReady()
      Indicates whether solver is ready to find a solution.
      Returns:
      true if solver is ready, false otherwise.
    • isLocked

      public boolean isLocked()
      Returns boolean indicating if solver is locked because estimation is under progress.
      Returns:
      true if solver is locked, false otherwise.
    • setPositionsAndDistances

      public void setPositionsAndDistances(P[] positions, double[] distances) throws LockedException
      Sets known positions and Euclidean 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.
      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.
    • getEstimatedPositionCoordinates

      public double[] getEstimatedPositionCoordinates()
      Gets estimated inhomogeneous position coordinates.
      Returns:
      estimated inhomogeneous position coordinates.
    • getEstimatedPosition

      public void getEstimatedPosition(P estimatedPosition)
      Gets estimated position and stores result into provided instance.
      Parameters:
      estimatedPosition - instance where estimated position will be stored.
    • getEstimatedPosition

      public abstract P getEstimatedPosition()
      Gets estimated position.
      Returns:
      estimated position.
    • getNumberOfDimensions

      public abstract int getNumberOfDimensions()
      Gets number of dimensions of provided points.
      Returns:
      number of dimensions of provided points.
    • solve

      public abstract void solve() throws LaterationException, NotReadyException, LockedException
      Solves the lateration problem.
      Throws:
      LaterationException - if lateration fails.
      NotReadyException - is solver is not ready.
      LockedException - if instance is busy solving the lateration problem.
    • getType

      public abstract LaterationSolverType getType()
      Gets lateration solver type.
      Returns:
      lateration solver type.
    • getMinRequiredPositionsAndDistances

      public abstract int getMinRequiredPositionsAndDistances()
      Minimum required number of positions and distances. This value will depend on actual implementation and whether we are solving a 2D or 3D problem.
      Returns:
      minimum required number of positions and distances.
    • internalSetPositionsAndDistances

      protected void internalSetPositionsAndDistances(P[] positions, double[] distances)
      Internally sets known positions and Euclidean 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.
      Throws:
      IllegalArgumentException - if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).