diff --git a/libraries/AP_Compass/AP_Compass_SITL.cpp b/libraries/AP_Compass/AP_Compass_SITL.cpp index aa4823876f..d059e4cc49 100644 --- a/libraries/AP_Compass/AP_Compass_SITL.cpp +++ b/libraries/AP_Compass/AP_Compass_SITL.cpp @@ -126,7 +126,12 @@ void AP_Compass_SITL::_timer() if (i == 0) { // rotate the first compass, allowing for testing of external compass rotation f.rotate_inverse((enum Rotation)_sitl->mag_orient.get()); - f.rotate(get_board_orientation()); + // and add in AHRS_ORIENTATION setting if not an external compass + if (get_board_orientation() == ROTATION_CUSTOM) { + f = _sitl->ahrs_rotation * f; + } else { + f.rotate(get_board_orientation()); + } // scale the first compass to simulate sensor scale factor errors f *= _sitl->mag_scaling;