MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / consistent

Method consistent

libraries/AP_Compass/AP_Compass.cpp:2182–2219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2180}
2181
2182bool Compass::consistent() const
2183{
2184 const Vector3f &primary_mag_field { get_field() };
2185 const Vector2f &primary_mag_field_xy { primary_mag_field.xy() };
2186
2187 for (uint8_t i=0; i<get_count(); i++) {
2188 if (!use_for_yaw(i)) {
2189 // configured not-to-be-used
2190 continue;
2191 }
2192
2193 const Vector3f &mag_field = get_field(i);
2194 const Vector2f &mag_field_xy = mag_field.xy();
2195
2196 if (mag_field_xy.is_zero()) {
2197 return false;
2198 }
2199
2200 // check for gross misalignment on all axes
2201 const float xyz_ang_diff = mag_field.angle(primary_mag_field);
2202 if (xyz_ang_diff > AP_COMPASS_MAX_XYZ_ANG_DIFF) {
2203 return false;
2204 }
2205
2206 // check for an unacceptable angle difference on the xy plane
2207 const float xy_ang_diff = mag_field_xy.angle(primary_mag_field_xy);
2208 if (xy_ang_diff > AP_COMPASS_MAX_XY_ANG_DIFF) {
2209 return false;
2210 }
2211
2212 // check for an unacceptable length difference on the xy plane
2213 const float xy_len_diff = (primary_mag_field_xy-mag_field_xy).length();
2214 if (xy_len_diff > AP_COMPASS_MAX_XY_LENGTH_DIFF) {
2215 return false;
2216 }
2217 }
2218 return true;
2219}
2220
2221bool Compass::healthy(uint8_t i) const
2222{

Callers 3

readMagDataMethod · 0.45
readMagDataMethod · 0.45
compass_checksMethod · 0.45

Calls 3

is_zeroMethod · 0.45
angleMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected