AP_NavEKF3: correct initialisation of BeaconFusion data structure

the fusionReport object is not being cleared when the filter undergoes a forced reset.

So delete and recreate the object.  Will also make this sensitive to the number of beacons changing.

Also don't attempt to allocate zero bytes.
This commit is contained in:
Peter Barker 2024-02-26 14:17:54 +11:00 committed by Andrew Tridgell
parent 749c7428dd
commit a517d5fed1

View File

@ -37,10 +37,11 @@ void NavEKF3_core::BeaconFusion::InitialiseVariables()
posOffsetMinVar = 0.0f;
minOffsetStateChangeFilt = 0.0f;
fuseDataReportIndex = 0;
if (AP::dal().beacon()) {
if (fusionReport == nullptr) {
fusionReport = new BeaconFusion::FusionReport[AP::dal().beacon()->count()];
}
delete[] fusionReport;
fusionReport = nullptr;
auto *beacon = AP::dal().beacon();
if (beacon != nullptr) {
fusionReport = new BeaconFusion::FusionReport[beacon->count()];
}
posOffsetNED.zero();
originEstInit = false;