c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
79 stars 44 forks source link

Fix attitude indicator and heading indicator in replay mode #293

Open onox opened 9 years ago

onox commented 9 years ago

Investigate if we can use the trick with using a <filter> which is enabled if /sim/freeze/replay-state is false to pass-through the values /instrumentation/attitude-indicator/indicated-pitch-deg and /instrumentation/attitude-indicator/indicated-roll-deg to two new values. See Systems/gearAGL.xml. The instruments and the flight recorder must then use these two new values.

Currently, the values are not recorded because the flight recorder seems to lose when fighting with the actual instruments in FlightGear. The result is that during replay the instruments are operating and mostly display the correct attitude. However, if you crash or go back to when starting the engine, it seems the attitude indicator instrument doesn't work 100 % of the time in replay mode.

The same problem happens with the heading indicator.

onox commented 9 years ago

I'm not sure whether I should commit the fix for this issue. I can work around it by using /instrumentation/heading-indicator/indicated-heading-deg in the instruments and then adding a <filter> that connects /instrumentation/heading-indicator/indicated-heading-deg to /instrumentation/heading-indicator/indicated-heading-deg-actual if /sim/freeze/replay-state is false.

The work around does work (it shows the correct pitch/roll/heading during replay), but it feels kinda hacky. Furthermore, the instruments show the correct state 9 out of 10 times after ending replay mode, but sometimes the instruments are different (I tested by doing barrel rolls and crashing and then entering replay mode).

This is (I think) because the instruments (AI and HI) are still active and changing their state even during replay. If they would fully compute their state from the properties in the property tree, then this wouldn't be a problem. But they only use some properties (like the spin property which I have already added to the flight recorder). And the rest of it is (probably) read from C++ variables.

I have fixed the AI and HI in the cockpit and HSI in the high-res panel. The AI in the high-res panel doesn't use parameterization, which means I would have to copy a complete .xml file just to change some properties.

I'm not sure if there's code outside the c172p project that uses the indicated properties of the AI and HI, and using these -actual properties feels too hacky to use for the critical 6 instruments.

The real fix should be by fixing the C++ instruments. (JSBSim has the same problem that it cannot be disabled during replay mode)