SITL: fixed running of example programs

This commit is contained in:
Andrew Tridgell 2018-11-04 16:31:13 +11:00
parent 5480479e73
commit 366361f0bb
1 changed files with 5 additions and 0 deletions

View File

@ -215,6 +215,11 @@ void Aircraft::update_mag_field_bf()
// calculate frame height above ground
const float frame_height_agl = fmaxf((-position.z) + home.alt * 0.01f - ground_level, 0.0f);
if (!sitl) {
// running example program
return;
}
// calculate scaling factor that varies from 1 at ground level to 1/8 at sitl->mag_anomaly_hgt
// Assume magnetic anomaly strength scales with 1/R**3
float anomaly_scaler = (sitl->mag_anomaly_hgt / (frame_height_agl + sitl->mag_anomaly_hgt));