diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index c6c3e58877..f468578deb 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -1677,7 +1677,7 @@ const Vector3f& Compass::getHIL(uint8_t instance) const void Compass::_setup_earth_field(void) { // assume a earth field strength of 400 - _hil.Bearth(400, 0, 0); + _hil.Bearth = {400, 0, 0}; // rotate _Bearth for inclination and declination. -66 degrees // is the inclination in Canberra, Australia diff --git a/libraries/AP_Compass/AP_Compass_LIS3MDL.cpp b/libraries/AP_Compass/AP_Compass_LIS3MDL.cpp index f65a07e218..0afa3d3a8c 100644 --- a/libraries/AP_Compass/AP_Compass_LIS3MDL.cpp +++ b/libraries/AP_Compass/AP_Compass_LIS3MDL.cpp @@ -138,7 +138,6 @@ void AP_Compass_LIS3MDL::timer() int16_t magz; } data; const float range_scale = 1000.0f / 6842.0f; - Vector3f field; // check data ready uint8_t status; @@ -154,9 +153,15 @@ void AP_Compass_LIS3MDL::timer() goto check_registers; } - field(data.magx * range_scale, data.magy * range_scale, data.magz * range_scale); + { + Vector3f field{ + data.magx * range_scale, + data.magy * range_scale, + data.magz * range_scale, + }; - accumulate_sample(field, compass_instance); + accumulate_sample(field, compass_instance); + } check_registers: dev->check_next_register(); diff --git a/libraries/AP_Compass/AP_Compass_RM3100.cpp b/libraries/AP_Compass/AP_Compass_RM3100.cpp index 3b69a7c19c..2b7b6f206c 100644 --- a/libraries/AP_Compass/AP_Compass_RM3100.cpp +++ b/libraries/AP_Compass/AP_Compass_RM3100.cpp @@ -177,7 +177,6 @@ void AP_Compass_RM3100::timer() uint8_t magz_1; uint8_t magz_0; } data; - Vector3f field; int32_t magx = 0; int32_t magy = 0; @@ -209,10 +208,16 @@ void AP_Compass_RM3100::timer() magy >>= 8; magz >>= 8; - // apply scaler and store in field vector - field(magx * _scaler, magy * _scaler, magz * _scaler); + { + // apply scaler and store in field vector + Vector3f field{ + magx * _scaler, + magy * _scaler, + magz * _scaler + }; - accumulate_sample(field, compass_instance); + accumulate_sample(field, compass_instance); + } check_registers: dev->check_next_register(); diff --git a/libraries/AP_Compass/AP_Compass_SITL.cpp b/libraries/AP_Compass/AP_Compass_SITL.cpp index c9f7f6c975..244c89148e 100644 --- a/libraries/AP_Compass/AP_Compass_SITL.cpp +++ b/libraries/AP_Compass/AP_Compass_SITL.cpp @@ -51,7 +51,7 @@ void AP_Compass_SITL::_setup_eliptical_correcion(uint8_t i) { Vector3f diag = _sitl->mag_diag[i].get(); if (diag.is_zero()) { - diag(1,1,1); + diag = {1,1,1}; } const Vector3f &diagonals = diag; const Vector3f &offdiagonals = _sitl->mag_offdiag[i];