Class PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

java.lang.Object
com.irurueta.navigation.inertial.calibration.magnetometer.RobustKnownHardIronAndFrameMagnetometerCalibrator
com.irurueta.navigation.inertial.calibration.magnetometer.PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator
All Implemented Interfaces:
KnownHardIronMagnetometerCalibrator, MagnetometerCalibrator, MagnetometerNonLinearCalibrator, OrderedStandardDeviationFrameBodyMagneticFluxDensityMagnetometerCalibrator, QualityScoredMagnetometerCalibrator

public class PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator extends RobustKnownHardIronAndFrameMagnetometerCalibrator
Robustly estimates magnetometer soft-iron cross couplings and scaling factors using PROMedS algorithm.

To use this calibrator at least 4 measurements at different known frames must be provided. In other words, magnetometer samples must be obtained at 4 different positions or orientations. Notice that frame velocities are ignored by this calibrator.

Measured magnetic flux density is assumed to follow the model shown below:

     mBmeas = bm + (I + Mm) * mBtrue + w
 
Where: - mBmeas is the measured magnetic flux density. This is a 3x1 vector. - bm is magnetometer hard-iron bias. Ideally, on a perfect magnetometer, this should be a 3x1 zero vector. - I is the 3x3 identity matrix. - Mm is the 3x3 soft-iron matrix containing cross-couplings and scaling factors. Ideally, on a perfect magnetometer, this should be a 3x3 zero matrix. - mBtrue is ground-truth magnetic flux density. This is a 3x1 vector. - w is measurement noise. This is a 3x1 vector.
  • Field Details

    • DEFAULT_STOP_THRESHOLD

      public static final double DEFAULT_STOP_THRESHOLD
      Default value to be used for stop threshold. Stop threshold can be used to avoid keeping the algorithm unnecessarily iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      See Also:
    • MIN_STOP_THRESHOLD

      public static final double MIN_STOP_THRESHOLD
      Minimum allowed stop threshold value.
      See Also:
    • stopThreshold

      private double stopThreshold
      Threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
    • qualityScores

      private double[] qualityScores
      Quality scores corresponding to each provided sample. The larger the score value the better the quality of the sample.
  • Constructor Details

    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator()
      Constructor.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(List<StandardDeviationFrameBodyMagneticFluxDensity> measurements)
      Constructor.
      Parameters:
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      listener - listener to handle events raised by this calibrator.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(boolean commonAxisUsed)
      Constructor.
      Parameters:
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(boolean commonAxisUsed, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      listener - listener to handle events raised by this calibrator.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed)
      Constructor.
      Parameters:
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      listener - listener to handle events raised by this calibrator.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, List<StandardDeviationFrameBodyMagneticFluxDensity> measurements)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      listener - listener to handle events raised by this calibrator.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, boolean commonAxisUsed)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, boolean commonAxisUsed, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      listener - listener to handle events raised by this calibrator.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
    • PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator

      public PROMedSRobustKnownHardIronAndFrameMagnetometerCalibrator(double[] qualityScores, List<StandardDeviationFrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed, RobustKnownHardIronAndFrameMagnetometerCalibratorListener listener)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each provided measurement. The larger the score value the better the quality of the sample.
      measurements - list of body magnetic flux density measurements with standard deviations taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      listener - listener to handle events raised by this calibrator.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.
  • Method Details

    • getStopThreshold

      public double getStopThreshold()
      Returns threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm to iterate too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      Returns:
      stop threshold to stop the algorithm prematurely when a certain accuracy has been reached.
    • setStopThreshold

      public void setStopThreshold(double stopThreshold) throws com.irurueta.navigation.LockedException
      Sets threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm to iterate too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      Parameters:
      stopThreshold - stop threshold to stop the algorithm prematurely when a certain accuracy has been reached.
      Throws:
      IllegalArgumentException - if provided value is zero or negative.
      com.irurueta.navigation.LockedException - if calibrator is currently running.
    • getQualityScores

      public double[] getQualityScores()
      Returns quality scores corresponding to each provided sample. The larger the score value the better the quality of the sample.
      Specified by:
      getQualityScores in interface QualityScoredMagnetometerCalibrator
      Overrides:
      getQualityScores in class RobustKnownHardIronAndFrameMagnetometerCalibrator
      Returns:
      quality scores corresponding to each sample.
    • setQualityScores

      public void setQualityScores(double[] qualityScores) throws com.irurueta.navigation.LockedException
      Sets quality scores corresponding to each provided sample. The larger the score value the better the quality of the sample.
      Specified by:
      setQualityScores in interface QualityScoredMagnetometerCalibrator
      Overrides:
      setQualityScores in class RobustKnownHardIronAndFrameMagnetometerCalibrator
      Parameters:
      qualityScores - quality scores corresponding to each sample.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than minimum required samples.
      com.irurueta.navigation.LockedException - if calibrator is currently running.
    • isReady

      public boolean isReady()
      Indicates whether solver is ready to find a solution.
      Specified by:
      isReady in interface MagnetometerCalibrator
      Overrides:
      isReady in class RobustKnownHardIronAndFrameMagnetometerCalibrator
      Returns:
      true if solver is ready, false otherwise.
    • calibrate

      public void calibrate() throws com.irurueta.navigation.LockedException, com.irurueta.navigation.NotReadyException, CalibrationException
      Estimates magnetometer calibration parameters containing soft-iron scale factors and cross-coupling errors.
      Throws:
      com.irurueta.navigation.LockedException - if calibrator is currently running.
      com.irurueta.navigation.NotReadyException - if calibrator is not ready.
      CalibrationException - if estimation fails for numerical reasons.
    • getMethod

      public com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()
      Returns method being used for robust estimation.
      Specified by:
      getMethod in class RobustKnownHardIronAndFrameMagnetometerCalibrator
      Returns:
      method being used for robust estimation.
    • isQualityScoresRequired

      public boolean isQualityScoresRequired()
      Indicates whether this calibrator requires quality scores for each measurement or not.
      Returns:
      true if quality scores are required, false otherwise.
    • internalSetQualityScores

      private void internalSetQualityScores(double[] qualityScores)
      Sets quality scores corresponding to each provided sample. This method is used internally and does not check whether instance is locked or not.
      Parameters:
      qualityScores - quality scores to be set.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than 3 samples.