Is it safe to run JSBSim at a variable timestep? #449
Replies: 2 comments 1 reply
-
Is your issue that there is some amount of jitter between the simulation steps when run in realtime mode? And the amount of jitter was causing an issue with your own code within this loop? I don't have a definitive answer in terms of the potential side-effects of varying the timestep during a simulation run. There could potentially be some code that caches the timestep value when it's initialized with the assumption that it would remain fixed for the run. Coincidentally I was looking at the realtime case in JSBSim not that long ago because I noticed some amount of jitter when using JSBSim to update an aircraft pose in Prepar3d when trying to fly in close formation with a Prepar3d controlled aircraft. JSBSim in realtime mode will basically check for any lag and if it detects any will then run multiple timesteps back to back to try and catch up. Lines 532 to 550 in a35be5c |
Beta Was this translation helpful? Give feedback.
-
Just for the record, using a variable time step with JSBSim is in most cases a terrible idea. The assumption of a constant time step is used almost everywhere in JSBSim code starting with the Adams-Bashforth integration schemes in So the rule of thumb is: unless you exactly know what you are doing (meaning you are very familiar with JSBSim inner workings), don't use a variable time step with JSBSim. Or even simpler, don't use variable time steps with JSBSim. I, for one, wouldn't wander in such murky waters 😉 |
Beta Was this translation helpful? Give feedback.
-
I want to run JSBSim in realtime with some code in the loop. I tried running it with a fixed timestep, but this didn't work reliably. So I tried adjusting the timestep by calling
FGFDMExec.Setdt(...)
on each iteration based on the realtime clock, simulation time and target timestep and it seems like this has done the trick.However I'm not sure whether it's safe to do this, since it may have sideffects depending on what integration scheme is being used in JSBSim. Or maybe there is actual support for this and I need to enable some setting, change integrator, do nothing, etc.
Beta Was this translation helpful? Give feedback.
All reactions