TwinFan / LiveTraffic

LiveTraffic is an X-Plane multiplayer plugin, which fills your sky with live air traffic based on public flight tracking data.
https://twinfan.gitbook.io/livetraffic/
Other
99 stars 24 forks source link

Exception occured while creating a/c: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi) #169

Closed TwinFan closed 4 years ago

TwinFan commented 4 years ago

Originally reported in the Support Forum.

Describe the bug Log file fills with error as per above subject. Likely, mentioned aircraft never appeared on screen.

LiveTraffic 1582536044.7 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
a/c 7C617A RSCU203 SimTime: 1582536044.7 - 2020-02-24 09:20:44
pAc == <null>
posDeque:
(-nan(ind), -nan(ind))   225f GND_OFF     {h 124, p -nan(ind), r -nan(ind)} [1582536041.4] Final <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -909ft/m>
(-33.9206, 150.9854)     2f GND_ON      {h 124, p -nan(ind), r -nan(ind)} [1582536056.2] Touch Down
posToAdd:
<empty>
LiveTraffic 1582536044.7 ERROR src\LTFlightData.cpp:2258/CreateAircraft: Exception occured while creating a/c 7C617A of type A139: LiveTraffic 1582536044.7 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
LiveTraffic 1582536044.7 ERROR src\LTFlightData.cpp:2268/CreateAircraft: Could not create new object (memory?): 7C617A

To Reproduce Situation not exactly clear yet. Came up with v1.23. User reporting it had traffic in Sydney. More parameters requested.

Expected behavior No such errors, instead the aircraft shall show up.

Technical Info:

Log.txt Log.txt

TwinFan commented 4 years ago

This block can reappear 3 or 4 times for the very same aircraft. The attached log has in total 63 of these blocks for 15-20 different a/c over a timeframe of 78 minutes.

The error prevents this particular aircraft from showing up but should not hinder other aircraft processing. So while annoying to the Log.txt, LiveTraffic should stay usable.

I noticed that all of these blocks show a "Final" and a "Touch Down" leg, but nothing thereafter. Such legs are inserted by new code introduced with the yet unfinished code for issue #100. (LTFlightData::CalcNextPos, case of no positions left, after the new LTAptFindRwy did return a runway to land on.) But that code can only execute if there is an aircraft (pAc must be defined). On the other hand, in the error message is clearly stated, that pAc == <null> as expected when we are in the process of creating the aircraft.

It is yet unclear how that relates to the creation of aircraft: The error is an exception during creation. And creation should not happen with no data...hence "creation" and "case of no positions left" are supposed to be mutually exclusive.

TwinFan commented 4 years ago

Looking at the log again, need to consider a larger block of messages. Looking at all msgs for one aircraft combined the picture is different:

LiveTraffic 1582534143.0 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
a/c 8964B7 UAE5CL SimTime: 1582534143.0 - 2020-02-24 08:49:03
a/c 8964B7 (A320 UAE5CL) ppos:
(-33.9723, 151.1827)   271f GND_OFF     {h 348, p   3, r   0} [1582534143.0]  Y: -0f 136kn -839ft/m Phase: 61 Final
posList:
(-33.9723, 151.1827)   271f GND_OFF     {h 348, p   3, r   0} [1582534143.0]  <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -839ft/m>
(-nan(ind), -nan(ind))   110f GND_OFF     {h 348, p -nan(ind), r -nan(ind)} [1582534154.5] Final
posDeque:
(-nan(ind), -nan(ind))   110f GND_OFF     {h 348, p -nan(ind), r -nan(ind)} [1582534154.5] Final <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -853ft/m>
(-33.9609, 151.1797)     8f GND_ON      {h 348, p -nan(ind), r -nan(ind)} [1582534161.7] Touch Down
posToAdd:
<empty>
LiveTraffic 1582534143.0 ERROR src\LTAircraft.cpp:2302/GetPlanePosition: Caught top-level exception! LiveTraffic 1582534143.0 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
LiveTraffic 1582534156.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
a/c 8964B7 UAE5CL SimTime: 1582534156.3 - 2020-02-24 08:49:16
pAc == <null>
posDeque:
(-nan(ind), -nan(ind))   110f GND_OFF     {h 348, p -nan(ind), r -nan(ind)} [1582534154.5] Final <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -853ft/m>
(-33.9609, 151.1797)     8f GND_ON      {h 348, p -nan(ind), r -nan(ind)} [1582534161.7] Touch Down
posToAdd:
<empty>
LiveTraffic 1582534156.3 ERROR src\LTFlightData.cpp:2258/CreateAircraft: Exception occured while creating a/c 8964B7 of type A320: LiveTraffic 1582534156.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
LiveTraffic 1582534156.3 ERROR src\LTFlightData.cpp:2268/CreateAircraft: Could not create new object (memory?): 8964B7
LiveTraffic 1582534158.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
a/c 8964B7 UAE5CL SimTime: 1582534158.3 - 2020-02-24 08:49:18
pAc == <null>
posDeque:
(-nan(ind), -nan(ind))   110f GND_OFF     {h 348, p -nan(ind), r -nan(ind)} [1582534154.5] Final <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -853ft/m>
(-33.9609, 151.1797)     8f GND_ON      {h 348, p -nan(ind), r -nan(ind)} [1582534161.7] Touch Down
posToAdd:
<empty>
LiveTraffic 1582534158.3 ERROR src\LTFlightData.cpp:2258/CreateAircraft: Exception occured while creating a/c 8964B7 of type A320: LiveTraffic 1582534158.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
LiveTraffic 1582534158.3 ERROR src\LTFlightData.cpp:2268/CreateAircraft: Could not create new object (memory?): 8964B7
LiveTraffic 1582534160.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
a/c 8964B7 UAE5CL SimTime: 1582534160.3 - 2020-02-24 08:49:20
pAc == <null>
posDeque:
(-nan(ind), -nan(ind))   110f GND_OFF     {h 348, p -nan(ind), r -nan(ind)} [1582534154.5] Final <h -nan(ind), -nan(ind)m @ -nan(ind)kt, -853ft/m>
(-33.9609, 151.1797)     8f GND_ON      {h 348, p -nan(ind), r -nan(ind)} [1582534161.7] Touch Down
posToAdd:
<empty>
LiveTraffic 1582534160.3 ERROR src\LTFlightData.cpp:2258/CreateAircraft: Exception occured while creating a/c 8964B7 of type A320: LiveTraffic 1582534160.3 FATAL src\LTAircraft.cpp:1177/CalcPPos: ASSERT FAILED: !std::isnan(vec.speed) && !std::isnan(vec.vsi)
LiveTraffic 1582534160.3 ERROR src\LTFlightData.cpp:2268/CreateAircraft: Could not create new object (memory?): 8964B7

The first message appears with a flying aircraft that includes the two artificial legs "Final" and "Touch down". But the "Final" position is incomplete. The log clearly shows it is missing location info (lat/lon), which is reported nan, as well as pitch and rotate, both also reported nan.

Subsequently, the aircraft will be declared invalid and removed, which is not tracked in the log, likely due to log settings being at "Warning" level.

Then something weird happens: The aircraft is attempted to be created once again. This is probably due to two positions being available in the posDeque and they span over a valid period of time. Creation certainly fails due to the "Final" position missing its location. That repeats 4 times. Then those positions are finally removed for good because their timestamp is expired.

That leaves us with analysing why the "Final" position in case of an auto-land doesn't properly fill with location, pitch and rotate.

TwinFan commented 4 years ago

The culprit is LTAptFindRwy as expected. The position returned does not fill some fields of positionTy, including heading. Without heading, however, the "Final" position cannot be calculated as that needs to be in the opposite direction of the rwy heading. No heading...no calculation. Can never have worked...who tested that? ;-)

This actually breaks auto-land, so I might publish a fix before v1.5.