I am developing a C++ SimConnect client (compiled into WASM) that has a requirement to obtain a precise, instantaneous positional and attitude reading of the user’s aircraft’s Nav data on every VISUAL frame (not SIM frame). To test this, I have set up requests to obtain user aircraft nav data (Lat Lon Alt Pitch Bank Heading), and setting it on a spawned SimObject (I am adding 5 ft to the altitude so that the spawned object is visible above the aircraft, and not embedded where its origin is). This works - except, the spawned object follows the aircraft with a slight positional lag, which gets worse and worse as the aircraft gains speed. This lag also manifests in a jerky motion - it is not smooth, as if the object was attached to the aircraft with a rubber band.
I am attributing this to a client-server communication latency… basically, when a request is sent, by the time the data is received and is used to position SimObject (with another request), the user object moved a bit further ahead of the SimObject.
Now, I have searched and came across a post in this forum, where the author is developing INS and encountering a similar problem. However, in their case, they need info on every SIM frame, while I need it on every VISUAL frame.
So, my question is, is it possible to have this data obtained in a way where the position/attitude data will be synced with user aircraft’s position/attitude data on every VISUAL frame, so that there are no latency offsets? I would expect to see SimObject following user aircraft without any positional or attitude lag, or any jerky motion.
I’m using same technique for AirshowAssistant. you will get better result if also apply velocity and rotation velocity values of the aircraft to the dummy object.
Thanks for your answer - I actually tried that. I even applied rotational acceleration AND linear acceleration, even though the documentation is explicitly saying that the linear acceleration is not settable (and the SimConnect didn’t complain - I wonder if that is a typo).
Actually, I tried all the aircraft’s dynamic parameters, in various combinations and various orders. The result was better, but there was still instability, and sometimes a jerking motion which would come and go. Sometimes my spawned object was completely “disconnected” and removed for some reason.
I checked out your AirshowAssistant videos on YT - spectacular! Keep up the great work!
This has been the case ever since FSX and P3D (all versions) and is due to the inherent asynchronous nature of SimConnect. P3D (latest) had a way to ask for synchronous data (which blocked the sim until it finished) but it was far from a perfect solution as well.
I wonder if the best solution wouldn’t be to produce legacy lookup_var() accessible gauge variables that might provide this instantaneously, but that’s up to Asobo to decide.
I’ve made a bit of a headway on this - I’ve implemented a few suggestions provided by @thealx and @simfan. I have managed to stabilize horizontal positioning oscillations (“jerks”) (on Latitude and Longitude), and thigs look much better/smoother.
However, now I can’t get vertical (altitude / sped) to stabilize - the SimObject that I am trying to get to smoothly follow user aircraft is now moving in up/down oscillating motion, and is not clamping its vertical position to the parent aircraft. I am applying both absolute altitude value and the vertical speed to the SimObject. This worked for Lat/Long, where things stabilized, but so far not for altitude (vertical position).
Note: If I am in level flight, the up/down oscillations are minimized - I guess due to the fact that the altitude position is more or less a constant value. However, as soon as I start climbing/diving, the oscillation worsen proportionally.
Considering the fact that the vertical position was somewhat stable, and got worse after Lat/Lon positions stabilized, I am wondering if the order of setting things would matter? @thealx, I would very much be interested to hear if and how you managed to stabilize the object’s motion, and what variables you’ve used to track the parent object? I am using a combo of token and SimVars and testing various parameters and the order of setting them, which for now is an exercise in sheer luck rather than deduction, since we have zero insight into the inner workings and how these parameters are applied inside the sim.