1
0
Fork 0

autopilot filter deque fixes

Thanks to Vivian Meazza for debugging this. The output deque for
FGDigitalFilter was not being kept long enough for the
doubleExponential filter. Reads from output[1] could cause a crash.
This commit is contained in:
timoore 2008-03-24 22:46:47 +00:00
parent 575320c325
commit d28b509e5f
3 changed files with 8 additions and 7 deletions

View file

@ -742,7 +742,6 @@ void FGDigitalFilter::update(double dt)
// first time being enabled, initialize output to the
// value of the output property to avoid bumping.
output.push_front(output_list[0]->getDoubleValue());
output.resize(1);
}
enabled = true;
@ -821,7 +820,7 @@ void FGDigitalFilter::update(double dt)
for ( i = 0; i < output_list.size(); ++i ) {
output_list[i]->setDoubleValue( output[0] );
}
output.resize(1);
output.resize(2);
if (debug)
{

View file

@ -1008,7 +1008,7 @@ MK_VIII::IOHandler::TerrainClearanceFilter::update (double agl)
// [PILOT] page 20 specifies that the terrain clearance is equal to
// 75% of the radio altitude, averaged over the previous 15 seconds.
deque< Sample<double> >::iterator iter;
samples_type::iterator iter;
// remove samples older than 15 seconds
for (iter = samples.begin(); iter != samples.end() && globals->get_sim_time_sec() - (*iter).timestamp >= 15; iter = samples.begin())
@ -1267,8 +1267,8 @@ MK_VIII::IOHandler::update_inputs ()
// Erase everything from the beginning of the list up to the sample
// preceding the most recent sample whose age is >= 1 second.
deque< Sample< Parameter<double> > >::iterator erase_last = altitude_samples.begin();
deque< Sample< Parameter<double> > >::iterator iter;
altitude_samples_type::iterator erase_last = altitude_samples.begin();
altitude_samples_type::iterator iter;
for (iter = altitude_samples.begin(); iter != altitude_samples.end(); iter++)
if (globals->get_sim_time_sec() - (*iter).timestamp >= 1)

View file

@ -621,7 +621,8 @@ public:
class TerrainClearanceFilter
{
deque< Sample<double> > samples;
typedef deque< Sample<double> > samples_type;
samples_type samples;
double value;
public:
@ -654,7 +655,8 @@ public:
bool last_landing_gear;
bool last_real_flaps_down;
deque< Sample< Parameter<double> > > altitude_samples;
typedef deque< Sample< Parameter<double> > > altitude_samples_type;
altitude_samples_type altitude_samples;
struct
{