Class KnownFrameMagnetometerLinearLeastSquaresCalibrator

java.lang.Object
com.irurueta.navigation.inertial.calibration.magnetometer.KnownFrameMagnetometerLinearLeastSquaresCalibrator
All Implemented Interfaces:
KnownFrameMagnetometerCalibrator<FrameBodyMagneticFluxDensity,KnownFrameMagnetometerLinearLeastSquaresCalibratorListener>, MagnetometerCalibrator, UnknownHardIronMagnetometerCalibrator, UnorderedFrameBodyMagneticFluxDensityMagnetometerCalibrator

Estimates magnetometer hard-iron biases, soft-iron cross couplings and scaling factors.

This calibrator uses a linear approach to find a minimum least squared error solution.

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_USE_COMMON_Z_AXIS

      public static final boolean DEFAULT_USE_COMMON_Z_AXIS
      Indicates whether by default a common z-axis is assumed for the accelerometer, gyroscope and magnetometer.
      See Also:
    • MINIMUM_MEASUREMENTS

      public static final int MINIMUM_MEASUREMENTS
      Required minimum number of measurements.
      See Also:
    • EQUATIONS_PER_MEASUREMENT

      private static final int EQUATIONS_PER_MEASUREMENT
      Number of equations generated for each measurement.
      See Also:
    • COMMON_Z_AXIS_UNKNOWNS

      private static final int COMMON_Z_AXIS_UNKNOWNS
      Number of unknowns when common z-axis is assumed for the accelerometer, gyroscope and magnetometer.
      See Also:
    • GENERAL_UNKNOWNS

      private static final int GENERAL_UNKNOWNS
      Number of unknowns for the general case.
      See Also:
    • measurements

      Contains a collection of body magnetic flux density measurements taken at different frames (positions and orientations). If a single device magnetometer needs to be calibrated, typically all measurements are taken at the same position, with zero velocity and multiple orientations. However, if we just want to calibrate a given magnetometer model (e.g. obtain an average and less precise calibration for the magnetometer of a given phone model), we could take measurements collected throughout the planet at multiple positions while the phone remains static (e.g. while charging), hence each measurement position will change, velocity will remain zero and orientation will be typically constant at horizontal orientation while the phone remains on a flat surface.
    • commonAxisUsed

      private boolean commonAxisUsed
      This flag indicates whether z-axis is assumed to be common for accelerometer, gyroscope and magnetometer. When enabled, this eliminates 3 variables from Mm matrix.
    • listener

      Listener to handle events raised by this calibrator.
    • estimatedHardIron

      private double[] estimatedHardIron
      Estimated magnetometer hard-iron biases for each magnetometer axis expressed in Teslas (T).
    • estimatedMm

      private com.irurueta.algebra.Matrix estimatedMm
      Estimated magnetometer soft-iron matrix containing scale factors and cross coupling errors. This is the product of matrix Tm containing cross coupling errors and Km containing scaling factors. So tat:
           Mm = [sx    mxy  mxz] = Tm*Km
                [myx   sy   myz]
                [mzx   mzy  sz ]
       
      Where:
           Km = [sx 0   0 ]
                [0  sy  0 ]
                [0  0   sz]
       
      and
           Tm = [1          -alphaXy    alphaXz ]
                [alphaYx    1           -alphaYz]
                [-alphaZx   alphaZy     1       ]
       
      Hence:
           Mm = [sx    mxy  mxz] = Tm*Km =  [sx             -sy * alphaXy   sz * alphaXz ]
                [myx   sy   myz]            [sx * alphaYx   sy              -sz * alphaYz]
                [mzx   mzy  sz ]            [-sx * alphaZx  sy * alphaZy    sz           ]
       
      This instance allows any 3x3 matrix however, typically alphaYx, alphaZx and alphaZy are considered to be zero if the accelerometer z-axis is assumed to be the same as the body z-axis. When this is assumed, myx = mzx = mzy = 0 and the Mm matrix becomes upper diagonal:
           Mm = [sx    mxy  mxz]
                [0     sy   myz]
                [0     0    sz ]
       
      Values of this matrix are unit-less.
    • running

      private boolean running
      Indicates whether calibrator is running.
    • magneticModel

      private WorldMagneticModel magneticModel
      Contains Earth's magnetic model.
  • Constructor Details

    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator()
      Constructor.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      listener - listener to handle events raised by this calibrator.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      listener - listener to handle events raised by this calibrator.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

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

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(boolean commonAxisUsed, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener 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.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements 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.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(WorldMagneticModel magneticModel)
      Constructor.
      Parameters:
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(WorldMagneticModel magneticModel, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
      listener - listener to handle events raised by this calibrator.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, WorldMagneticModel magneticModel)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, WorldMagneticModel magneticModel, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
      listener - listener to handle events raised by this calibrator.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(boolean commonAxisUsed, WorldMagneticModel magneticModel)
      Constructor.
      Parameters:
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(boolean commonAxisUsed, WorldMagneticModel magneticModel, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
      listener - listener to handle events raised by this calibrator.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed, WorldMagneticModel magneticModel)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
    • KnownFrameMagnetometerLinearLeastSquaresCalibrator

      public KnownFrameMagnetometerLinearLeastSquaresCalibrator(Collection<? extends FrameBodyMagneticFluxDensity> measurements, boolean commonAxisUsed, WorldMagneticModel magneticModel, KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener)
      Constructor.
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions and orientations).
      commonAxisUsed - indicates whether z-axis is assumed to be common for the accelerometer, gyroscope and magnetometer.
      magneticModel - Earth's magnetic model. If null, a default model will be used instead.
      listener - listener to handle events raised by this calibrator.
  • Method Details

    • getMeasurements

      public Collection<FrameBodyMagneticFluxDensity> getMeasurements()
      Gets a collection of body magnetic flux density measurements taken at different frames (positions, orientations and velocities). If a single device IMU needs to be calibrated, typically all measurements are taken at the same position, with zero velocity and multiple orientations. However, if we just want to calibrate a given IMU model (e.g. obtain an average and less precise calibration for the IMU of a given phone model), we could take measurements collected throughout the planet at multiple positions while the phone remains static (e.g. while charging), hence each measurement position will change, velocity will remain zero and orientation will be typically constant at horizontal orientation while the phone remains on a flat surface.
      Specified by:
      getMeasurements in interface KnownFrameMagnetometerCalibrator<FrameBodyMagneticFluxDensity,KnownFrameMagnetometerLinearLeastSquaresCalibratorListener>
      Specified by:
      getMeasurements in interface UnorderedFrameBodyMagneticFluxDensityMagnetometerCalibrator
      Returns:
      a collection of body magnetic flux density measurements taken at different frames (positions, orientations and velocities).
    • setMeasurements

      public void setMeasurements(Collection<? extends FrameBodyMagneticFluxDensity> measurements) throws com.irurueta.navigation.LockedException
      Sets a collection of body magnetic flux density measurements taken at different frames (positions, orientations and velocities). If a single device IMU needs to be calibrated, typically all measurements are taken at the same position, with zero velocity and multiple orientations. However, if we just want to calibrate the a given IMU model (e.g. obtain an average and less precise calibration for the IMU of a given phone model), we could take measurements collected throughout the planet at multiple positions while the phone remains static (e.g. while charging), hence each measurement position will change, velocity will remain zero and orientation will be typically constant at horizontal orientation while the phone remains on a flat surface.
      Specified by:
      setMeasurements in interface KnownFrameMagnetometerCalibrator<FrameBodyMagneticFluxDensity,KnownFrameMagnetometerLinearLeastSquaresCalibratorListener>
      Specified by:
      setMeasurements in interface UnorderedFrameBodyMagneticFluxDensityMagnetometerCalibrator
      Parameters:
      measurements - collection of body magnetic flux density measurements taken at different frames (positions, orientations and velocities).
      Throws:
      com.irurueta.navigation.LockedException - if estimator is currently running.
    • getMeasurementType

      public MagnetometerCalibratorMeasurementType getMeasurementType()
      Indicates the type of measurement used by this calibrator.
      Specified by:
      getMeasurementType in interface MagnetometerCalibrator
      Returns:
      type of measurement used by this calibrator.
    • isOrderedMeasurementsRequired

      public boolean isOrderedMeasurementsRequired()
      Indicates whether this calibrator requires ordered measurements in a list or not.
      Specified by:
      isOrderedMeasurementsRequired in interface MagnetometerCalibrator
      Returns:
      true if measurements must be ordered, false otherwise.
    • isQualityScoresRequired

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

      public boolean isCommonAxisUsed()
      Indicates whether z-axis is assumed to be common for accelerometer, gyroscope and magnetometer. When enabled, this eliminates 3 variables from Mm (soft-iron) matrix.
      Specified by:
      isCommonAxisUsed in interface MagnetometerCalibrator
      Returns:
      true if z-axis is assumed to be common for accelerometer, gyroscope and magnetometer, false otherwise.
    • setCommonAxisUsed

      public void setCommonAxisUsed(boolean commonAxisUsed) throws com.irurueta.navigation.LockedException
      Specifies whether z-axis is assumed to be common for accelerometer and gyroscope. When enabled, this eliminates 3 variables from Mm matrix.
      Specified by:
      setCommonAxisUsed in interface MagnetometerCalibrator
      Parameters:
      commonAxisUsed - true if z-axis is assumed to be common for accelerometer, gyroscope and magnetometer, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is currently running.
    • getListener

      Gets listener to handle events raised by this calibrator.
      Specified by:
      getListener in interface KnownFrameMagnetometerCalibrator<FrameBodyMagneticFluxDensity,KnownFrameMagnetometerLinearLeastSquaresCalibratorListener>
      Returns:
      listener to handle events raised by this calibrator.
    • setListener

      public void setListener(KnownFrameMagnetometerLinearLeastSquaresCalibratorListener listener) throws com.irurueta.navigation.LockedException
      Sets listener to handle events raised by this calibrator.
      Specified by:
      setListener in interface KnownFrameMagnetometerCalibrator<FrameBodyMagneticFluxDensity,KnownFrameMagnetometerLinearLeastSquaresCalibratorListener>
      Parameters:
      listener - listener to handle events raised by this calibrator.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is currently running.
    • getMinimumRequiredMeasurements

      public int getMinimumRequiredMeasurements()
      Gets minimum number of required measurements.
      Specified by:
      getMinimumRequiredMeasurements in interface MagnetometerCalibrator
      Returns:
      minimum number of required measurements.
    • isReady

      public boolean isReady()
      Indicates whether calibrator is ready to start the estimator.
      Specified by:
      isReady in interface MagnetometerCalibrator
      Returns:
      true if calibrator is ready, false otherwise.
    • isRunning

      public boolean isRunning()
      Indicates whether calibrator is currently running or no.
      Specified by:
      isRunning in interface MagnetometerCalibrator
      Returns:
      true if calibrator is running, false otherwise.
    • getMagneticModel

      public WorldMagneticModel getMagneticModel()
      Gets Earth's magnetic model.
      Returns:
      Earth's magnetic model or null if not provided.
    • setMagneticModel

      public void setMagneticModel(WorldMagneticModel magneticModel) throws com.irurueta.navigation.LockedException
      Sets Earth's magnetic model. If not provided a default model will be loaded internally.
      Parameters:
      magneticModel - Earth's magnetic model to be set.
      Throws:
      com.irurueta.navigation.LockedException - if calibrator is currently running.
    • calibrate

      public void calibrate() throws com.irurueta.navigation.LockedException, com.irurueta.navigation.NotReadyException, CalibrationException
      Estimates accelerometer calibration parameters containing scale factors and cross-coupling errors.
      Specified by:
      calibrate in interface MagnetometerCalibrator
      Throws:
      com.irurueta.navigation.LockedException - if calibrator is currently running.
      com.irurueta.navigation.NotReadyException - if calibrator is not ready.
      CalibrationException - if calibration fails for numerical reasons.
    • getEstimatedHardIron

      public double[] getEstimatedHardIron()
      Gets array containing x,y,z components of estimated magnetometer hard-iron biases expressed in Teslas (T).
      Specified by:
      getEstimatedHardIron in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      array containing x,y,z components of estimated magnetometer hard-iron biases.
    • getEstimatedHardIron

      public boolean getEstimatedHardIron(double[] result)
      Gets array containing x,y,z components of estimated magnetometer hard-iron biases expressed in Teslas (T).
      Specified by:
      getEstimatedHardIron in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where estimated magnetometer biases will be stored.
      Returns:
      true if result instance was updated, false otherwise (when estimation is not yet available).
    • getEstimatedHardIronAsMatrix

      public com.irurueta.algebra.Matrix getEstimatedHardIronAsMatrix()
      Gets column matrix containing x,y,z components of estimated magnetometer hard-iron biases expressed in Teslas (T).
      Specified by:
      getEstimatedHardIronAsMatrix in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      column matrix containing x,y,z components of estimated magnetometer hard-iron biases.
    • getEstimatedHardIronAsMatrix

      public boolean getEstimatedHardIronAsMatrix(com.irurueta.algebra.Matrix result) throws com.irurueta.algebra.WrongSizeException
      Gets column matrix containing x,y,z components of estimated magnetometer hard-iron biases expressed in Teslas (T).
      Specified by:
      getEstimatedHardIronAsMatrix in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where result data will be stored.
      Returns:
      true if result was updated, false otherwise.
      Throws:
      com.irurueta.algebra.WrongSizeException - if provided result instance has invalid size.
    • getEstimatedHardIronX

      public Double getEstimatedHardIronX()
      Gets x coordinate of estimated magnetometer bias expressed in Teslas (T).
      Specified by:
      getEstimatedHardIronX in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      x coordinate of estimated magnetometer bias or null if not available.
    • getEstimatedHardIronY

      public Double getEstimatedHardIronY()
      Gets y coordinate of estimated magnetometer bias expressed in Teslas (T).
      Specified by:
      getEstimatedHardIronY in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      y coordinate of estimated magnetometer bias or null if not available.
    • getEstimatedHardIronZ

      public Double getEstimatedHardIronZ()
      Gets z coordinate of estimated magnetometer bias expressed in Teslas (T).
      Specified by:
      getEstimatedHardIronZ in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      z coordinate of estimated magnetometer bias or null if not available.
    • getEstimatedHardIronXAsMagneticFluxDensity

      public com.irurueta.units.MagneticFluxDensity getEstimatedHardIronXAsMagneticFluxDensity()
      Gets x coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronXAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      x coordinate of estimated magnetometer bias.
    • getEstimatedHardIronXAsMagneticFluxDensity

      public boolean getEstimatedHardIronXAsMagneticFluxDensity(com.irurueta.units.MagneticFluxDensity result)
      Gets x coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronXAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where result will be stored.
      Returns:
      true if estimated magnetometer bias is available, false otherwise.
    • getEstimatedHardIronYAsMagneticFluxDensity

      public com.irurueta.units.MagneticFluxDensity getEstimatedHardIronYAsMagneticFluxDensity()
      Gets y coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronYAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      y coordinate of estimated magnetometer bias.
    • getEstimatedHardIronYAsMagneticFluxDensity

      public boolean getEstimatedHardIronYAsMagneticFluxDensity(com.irurueta.units.MagneticFluxDensity result)
      Gets y coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronYAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where result will be stored.
      Returns:
      true if estimated magnetometer bias is available, false otherwise.
    • getEstimatedHardIronZAsMagneticFluxDensity

      public com.irurueta.units.MagneticFluxDensity getEstimatedHardIronZAsMagneticFluxDensity()
      Gets z coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronZAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      z coordinate of estimated magnetometer bias.
    • getEstimatedHardIronZAsMagneticFluxDensity

      public boolean getEstimatedHardIronZAsMagneticFluxDensity(com.irurueta.units.MagneticFluxDensity result)
      Gets z coordinate of estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronZAsMagneticFluxDensity in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where result will be stored.
      Returns:
      true if estimated magnetometer bias is available, false otherwise.
    • getEstimatedHardIronAsTriad

      public MagneticFluxDensityTriad getEstimatedHardIronAsTriad()
      Gets estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronAsTriad in interface UnknownHardIronMagnetometerCalibrator
      Returns:
      estimated magnetometer bias or null if not available.
    • getEstimatedHardIronAsTriad

      public boolean getEstimatedHardIronAsTriad(MagneticFluxDensityTriad result)
      Gets estimated magnetometer bias.
      Specified by:
      getEstimatedHardIronAsTriad in interface UnknownHardIronMagnetometerCalibrator
      Parameters:
      result - instance where result will be stored.
      Returns:
      true if estimated magnetometer bias is available and result was modified, false otherwise.
    • getEstimatedMm

      public com.irurueta.algebra.Matrix getEstimatedMm()
      Gets estimated magnetometer soft-iron matrix containing scale factors and cross coupling errors. This is the product of matrix Tm containing cross coupling errors and Km containing scaling factors. So tat:
           Mm = [sx    mxy  mxz] = Tm*Km
                [myx   sy   myz]
                [mzx   mzy  sz ]
       
      Where:
           Km = [sx 0   0 ]
                [0  sy  0 ]
                [0  0   sz]
       
      and
           Tm = [1          -alphaXy    alphaXz ]
                [alphaYx    1           -alphaYz]
                [-alphaZx   alphaZy     1       ]
       
      Hence:
           Mm = [sx    mxy  mxz] = Tm*Km =  [sx             -sy * alphaXy   sz * alphaXz ]
                [myx   sy   myz]            [sx * alphaYx   sy              -sz * alphaYz]
                [mzx   mzy  sz ]            [-sx * alphaZx  sy * alphaZy    sz           ]
       
      This instance allows any 3x3 matrix however, typically alphaYx, alphaZx and alphaZy are considered to be zero if the accelerometer z-axis is assumed to be the same as the body z-axis. When this is assumed, myx = mzx = mzy = 0 and the Mm matrix becomes upper diagonal:
           Mm = [sx    mxy  mxz]
                [0     sy   myz]
                [0     0    sz ]
       
      Values of this matrix are unit-less.
      Specified by:
      getEstimatedMm in interface MagnetometerCalibrator
      Returns:
      estimated magnetometer soft-iron scale factors and cross coupling errors, or null if not available.
    • getEstimatedSx

      public Double getEstimatedSx()
      Gets estimated x-axis scale factor.
      Specified by:
      getEstimatedSx in interface MagnetometerCalibrator
      Returns:
      estimated x-axis scale factor or null if not available.
    • getEstimatedSy

      public Double getEstimatedSy()
      Gets estimated y-axis scale factor.
      Specified by:
      getEstimatedSy in interface MagnetometerCalibrator
      Returns:
      estimated y-axis scale factor or null if not available.
    • getEstimatedSz

      public Double getEstimatedSz()
      Gets estimated z-axis scale factor.
      Specified by:
      getEstimatedSz in interface MagnetometerCalibrator
      Returns:
      estimated z-axis scale factor or null if not available.
    • getEstimatedMxy

      public Double getEstimatedMxy()
      Gets estimated x-y cross-coupling error.
      Specified by:
      getEstimatedMxy in interface MagnetometerCalibrator
      Returns:
      estimated x-y cross-coupling error or null if not available.
    • getEstimatedMxz

      public Double getEstimatedMxz()
      Gets estimated x-z cross-coupling error.
      Specified by:
      getEstimatedMxz in interface MagnetometerCalibrator
      Returns:
      estimated x-z cross-coupling error or null if not available.
    • getEstimatedMyx

      public Double getEstimatedMyx()
      Gets estimated y-x cross-coupling error.
      Specified by:
      getEstimatedMyx in interface MagnetometerCalibrator
      Returns:
      estimated y-x cross-coupling error or null if not available.
    • getEstimatedMyz

      public Double getEstimatedMyz()
      Gets estimated y-z cross-coupling error.
      Specified by:
      getEstimatedMyz in interface MagnetometerCalibrator
      Returns:
      estimated y-z cross-coupling error or null if not available.
    • getEstimatedMzx

      public Double getEstimatedMzx()
      Gets estimated z-x cross-coupling error.
      Specified by:
      getEstimatedMzx in interface MagnetometerCalibrator
      Returns:
      estimated z-x cross-coupling error or null if not available.
    • getEstimatedMzy

      public Double getEstimatedMzy()
      Gets estimated z-y cross-coupling error.
      Specified by:
      getEstimatedMzy in interface MagnetometerCalibrator
      Returns:
      estimated z-y cross-coupling error or null if not available.
    • calibrateCommonAxis

      private void calibrateCommonAxis() throws com.irurueta.algebra.AlgebraException, IOException
      Internal method to perform calibration when common z-axis is assumed for the accelerometer, gyroscope and magnetometer.
      Throws:
      com.irurueta.algebra.AlgebraException - if there are numerical errors.
      IOException - if world magnetic model cannot be loaded.
    • calibrateGeneral

      private void calibrateGeneral() throws com.irurueta.algebra.AlgebraException, IOException
      Internal method to perform general calibration.
      Throws:
      com.irurueta.algebra.AlgebraException - if there are numerical errors.
      IOException - if world magnetic model cannot be loaded.
    • fillHardIronBiases

      private void fillHardIronBiases(double bx, double by, double bz)
      Fills estimated biases array with estimated values.
      Parameters:
      bx - x coordinate of bias.
      by - y coordinate of bias.
      bz - z coordinate of bias.
    • fillMm

      private void fillMm(double sx, double sy, double sz, double mxy, double mxz, double myx, double myz, double mzx, double mzy) throws com.irurueta.algebra.WrongSizeException
      Fills scale factor and cross coupling error matrix with estimated values.
      Parameters:
      sx - x scale factor
      sy - y scale factor
      sz - z scale factor
      mxy - x-y cross coupling
      mxz - x-z cross coupling
      myx - y-x cross coupling
      myz - y-z cross coupling
      mzx - z-x cross coupling
      mzy - z-y cross coupling
      Throws:
      com.irurueta.algebra.WrongSizeException - never happens.