FieldSensorBiasEst: fix bias learning equation

Also compensate the tuned learning gains for the new equation to keep
the same tuning
This commit is contained in:
bresch
2021-10-02 21:25:21 -04:00
committed by Daniel Agar
parent e0bcc17f5b
commit 07e307b074
3 changed files with 3 additions and 3 deletions
@@ -71,7 +71,7 @@ public:
{ {
const matrix::Vector3f field_pred = _field_prev + (-gyro % (_field_prev - _state_bias)) * dt; const matrix::Vector3f field_pred = _field_prev + (-gyro % (_field_prev - _state_bias)) * dt;
const matrix::Vector3f field_innov = field - field_pred; const matrix::Vector3f field_innov = field - field_pred;
_state_bias += _learning_gain * (-gyro % field_innov); _state_bias += _learning_gain * (-gyro % field_innov) * dt;
_field_prev = field; _field_prev = field;
} }
@@ -44,7 +44,7 @@ using namespace matrix;
TEST(MagnetometerBiasEstimatorTest, constantZRotation) TEST(MagnetometerBiasEstimatorTest, constantZRotation)
{ {
FieldSensorBiasEstimator field_sensor_bias_estimator; FieldSensorBiasEstimator field_sensor_bias_estimator;
field_sensor_bias_estimator.setLearningGain(100.f); field_sensor_bias_estimator.setLearningGain(10000.f);
const Vector3f virtual_gyro = Vector3f(0.f, 0.f, 0.1f); const Vector3f virtual_gyro = Vector3f(0.f, 0.f, 0.1f);
Vector3f virtual_unbiased_mag = Vector3f(0.9f, 0.f, 1.79f); // taken from SITL jmavsim initialization Vector3f virtual_unbiased_mag = Vector3f(0.9f, 0.f, 1.79f); // taken from SITL jmavsim initialization
const Vector3f virtual_bias(0.2f, -0.4f, 0.5f); const Vector3f virtual_bias(0.2f, -0.4f, 0.5f);
+1 -1
View File
@@ -55,4 +55,4 @@ PARAM_DEFINE_INT32(MBE_ENABLE, 1);
* @decimal 1 * @decimal 1
* @group Magnetometer Bias Estimator * @group Magnetometer Bias Estimator
*/ */
PARAM_DEFINE_FLOAT(MBE_LEARN_GAIN, 0.4f); PARAM_DEFINE_FLOAT(MBE_LEARN_GAIN, 18.f);