Browse Source

AP_Compass: remove use of Vector3 as function

zr-v5.1
Peter Barker 5 years ago committed by Andrew Tridgell
parent
commit
0f2bcea647
  1. 2
      libraries/AP_Compass/AP_Compass.cpp
  2. 11
      libraries/AP_Compass/AP_Compass_LIS3MDL.cpp
  3. 13
      libraries/AP_Compass/AP_Compass_RM3100.cpp
  4. 2
      libraries/AP_Compass/AP_Compass_SITL.cpp

2
libraries/AP_Compass/AP_Compass.cpp

@ -1677,7 +1677,7 @@ const Vector3f& Compass::getHIL(uint8_t instance) const @@ -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

11
libraries/AP_Compass/AP_Compass_LIS3MDL.cpp

@ -138,7 +138,6 @@ void AP_Compass_LIS3MDL::timer() @@ -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() @@ -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();

13
libraries/AP_Compass/AP_Compass_RM3100.cpp

@ -177,7 +177,6 @@ void AP_Compass_RM3100::timer() @@ -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() @@ -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();

2
libraries/AP_Compass/AP_Compass_SITL.cpp

@ -51,7 +51,7 @@ void AP_Compass_SITL::_setup_eliptical_correcion(uint8_t i) @@ -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];

Loading…
Cancel
Save