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

java.lang.Object
com.irurueta.navigation.indoor.WeightedKNearestNeighboursPositionSolver<P>
Type Parameters:
P - a Point type.
Direct Known Subclasses:
WeightedKNearestNeighboursPositionSolver2D, WeightedKNearestNeighboursPositionSolver3D

public abstract class WeightedKNearestNeighboursPositionSolver<P extends com.irurueta.geometry.Point<?>> extends Object
Estimates position using Wi-Fi signals indoor and the Weighted k-Nearest Neighbours (WkNN) algorithm. WkNN algorithm is based on https://github.com/ajnas/WiFiPS.
  • Field Details

    • DEFAULT_EPSILON

      public static final double DEFAULT_EPSILON
      Default minimum allowed distance between received Wi-Fi fingerprints.
      See Also:
    • MIN_FINGERPRINTS

      public static final int MIN_FINGERPRINTS
      Minimum required number of fingerprints and their distances. If only 1 fingerprint is used, this algorithm will return provided fingerprint position, however, some accuracy might be lost due to numerical computations. For that reason, when only one fingerprint is provided, this algorithm will simply return the fingerprint position.
      See Also:
    • fingerprints

      protected RssiFingerprintLocated<WifiAccessPoint,RssiReading<WifiAccessPoint>,P extends com.irurueta.geometry.Point<?>>[] fingerprints
      Known located Wi-Fi fingerprints.
    • distances

      protected double[] distances
      Euclidean distances between WiFi signal fingerprints (expressed in dB's).
    • listener

      protected WeightedKNearestNeighboursPositionSolverListener<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 indoor is being estimated.
    • epsilon

      private double epsilon
      Minimum allowed distance between received Wi-Fi signal strengths.
  • Constructor Details

    • WeightedKNearestNeighboursPositionSolver

      protected WeightedKNearestNeighboursPositionSolver()
      Constructor.
    • WeightedKNearestNeighboursPositionSolver

      protected WeightedKNearestNeighboursPositionSolver(RssiFingerprintLocated<WifiAccessPoint,RssiReading<WifiAccessPoint>,P>[] fingerprints, double[] distances)
      Constructor. Sets known located Wi-Fi fingerprints and Euclidean distances between Wi-Fi signal fingerprints.
      Parameters:
      fingerprints - known located Wi-Fi fingerprints.
      distances - Euclidean distances between Wi-Fi signal fingerprints (expressed in dB's).
      Throws:
      IllegalArgumentException - if either fingerprints or distances are null, don't have the same length or their length is smaller than 1.
    • WeightedKNearestNeighboursPositionSolver

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

      protected WeightedKNearestNeighboursPositionSolver(RssiFingerprintLocated<WifiAccessPoint,RssiReading<WifiAccessPoint>,P>[] fingerprints, double[] distances, WeightedKNearestNeighboursPositionSolverListener<P> listener)
      Constructor. Sets known located Wi-Fi fingerprints and Euclidean distances between Wi-Fi signal fingerprints.
      Parameters:
      fingerprints - known located Wi-Fi fingerprints.
      distances - Euclidean distances between Wi-Fi signal fingerprints (expressed in dB's).
      listener - listener to be notified of events raised by this instance.
      Throws:
      IllegalArgumentException - if either fingerprints or distances are null, don't have the same length or their length is smaller than 1.
  • Method Details

    • 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(WeightedKNearestNeighboursPositionSolverListener<P> listener) throws com.irurueta.navigation.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:
      com.irurueta.navigation.LockedException - if instance is busy solving the position.
    • getFingerprints

      Gets known located Wi-Fi fingerprints.
      Returns:
      known located Wi-Fi fingerprints.
    • getDistances

      public double[] getDistances()
      Gets euclidean distances between WiFi signal fingerprints (expressed in dB's).
      Returns:
      euclidean distances between WiFi signal fingerprints.
    • 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 estimator is locked because estimation is under progress.
      Returns:
      true if solver is locked, false otherwise.
    • setFingerprintsAndDistances

      public void setFingerprintsAndDistances(RssiFingerprintLocated<WifiAccessPoint,RssiReading<WifiAccessPoint>,P>[] fingerprints, double[] distances) throws com.irurueta.navigation.LockedException
      Sets known located Wi-Fi fingerprints and Euclidean distances between Wi-Fi signal fingerprints.
      Parameters:
      fingerprints - known located Wi-Fi fingerprints.
      distances - Euclidean distances between Wi-Fi signal fingerprints (expressed in dB's).
      Throws:
      IllegalArgumentException - if either fingerprints or distances are null, don't have the same length or their length is smaller than 1.
      com.irurueta.navigation.LockedException - if instance is busy solving the position.
    • getEpsilon

      public double getEpsilon()
      Gets minimum allowed distance between Wi-Fi signal fingerprints.
      Returns:
      minimum allowed distance between Wi-Fi signal fingerprints.
    • setEpsilon

      public void setEpsilon(double epsilon) throws com.irurueta.navigation.LockedException
      Sets minimum allowed distance between WiFi signal fingerprints.
      Parameters:
      epsilon - minimum allowed distance between WiFi signal fingerprints. strengths.
      Throws:
      IllegalArgumentException - if provided value is zero or negative.
      com.irurueta.navigation.LockedException - if instance is busy solving the indoor problem.
    • solve

      public void solve() throws com.irurueta.navigation.NotReadyException, com.irurueta.navigation.LockedException
      Estimates position.
      Throws:
      com.irurueta.navigation.NotReadyException - if solver is not ready.
      com.irurueta.navigation.LockedException - if instance is busy solving position.
    • 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 location points.
      Returns:
      number of dimensions of location points.
    • internalSetFingerprintsAndDistances

      protected void internalSetFingerprintsAndDistances(RssiFingerprintLocated<WifiAccessPoint,RssiReading<WifiAccessPoint>,P>[] fingerprints, double[] distances)
      Sets known located Wi-Fi fingerprints and Euclidean distances between Wi-Fi signal fingerprints.
      Parameters:
      fingerprints - known located Wi-Fi fingerprints.
      distances - Euclidean distances between Wi-Fi signal fingerprints (expressed in dB's).
      Throws:
      IllegalArgumentException - if either fingerprints or distances are null, don't have the same length or their length is smaller than 1.