Skip to content

Commit

Permalink
[ardrone2] Fix baro measurement spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
fvantienen authored and flixr committed Feb 27, 2014
1 parent 6a50e31 commit a45d955
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions sw/airborne/boards/ardrone/navdata.c
Expand Up @@ -292,7 +292,6 @@ static void baro_update_logic(void)
// wait for temp again
temp_or_press_was_updated_last = FALSE;
sync_errors++;
navdata_baro_available = TRUE;
printf("Baro-Logic-Error (expected updated temp, got press)\n");
}
}
Expand All @@ -314,13 +313,25 @@ static void baro_update_logic(void)
printf("Baro-Logic-Error (expected updated press, got temp)\n");

}
else {
// We now got valid pressure and temperature
navdata_baro_available = TRUE;
}
}
}

// Detected a pressure switch
if(lastpressval != 0 && lasttempval != 0 && ABS(lastpressval - navdata.pressure) > ABS(lasttempval - navdata.pressure)) {
navdata_baro_available = FALSE;
}

navdata_baro_available = TRUE;
// Detected a temprature switch
if(lastpressval != 0 && lasttempval != 0 && ABS(lasttempval - navdata.temperature_pressure) > ABS(lastpressval - navdata.temperature_pressure)) {
navdata_baro_available = FALSE;
}

lastpressval = navdata.pressure;
lasttempval = navdata.temperature_pressure;
lastpressval = navdata.pressure;

/*
* It turns out that a lot of navdata boards have a problem (probably interrupt related)
Expand Down Expand Up @@ -389,6 +400,7 @@ static void baro_update_logic(void)
lasttempval_nospike = navdata.temperature_pressure;
}

// printf("%d %d %d\r\n", navdata.temperature_pressure, navdata.pressure, spike_detected);
// printf(",%d,%d",spike_detected,spikes);
}

Expand Down

0 comments on commit a45d955

Please sign in to comment.