UE5 BUG: The landing gear position will move backward as the airspeed increases #1160
Replies: 5 comments 6 replies
-
I don't see how putting this on a separate thread will change anything regarding the trailing/lagging gear positions. But if you want to easily test this first before you add a separate thread, you can just bypass the fixed rate code and run JSBSim 1:1 with Unreal Tick. Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
double Start = FPlatformTime::Seconds();
if (AircraftLoaded)
{
if (AircraftState.Crashed)
{
// TODO - Send event
UE_LOG(LogJSBSim, Display, TEXT("Aircraft crashed..."));
}
else
{
// TODO - Stepping JSBSim model with a potentially variable step might be a bad idea.
// Maybe step the model with a fixed step in another thread
Exec->Setdt(DeltaTime);
// Send Commands and State to JSBSim
CopyToJSBSim();
// Step model
Exec->Run();
// The CG location in the reference frame can vary over time, for instance when tanks get empty...
// Theoretically, we should update the local transforms. But maybe it's overkill to do it each frame...
UpdateLocalTransforms();
// Get the results from JSBSim
CopyFromJSBSim(); |
Beta Was this translation helpful? Give feedback.
-
You haven't mentioned it explicitly in this discussion, but based on your comments in #1158 (waiting for an answer to my last question there) and I think your issue is that you're only updating the carrier's position, velocity etc. at UE5's game frate rate, e.g. 30Hz and not at JSBSim's frame rate of 120Hz. So you should move the call to //step sim x times per game tick
for (int i = 0; i < simloops; i++)
{
CalculateCarrierVelocity();
Exec->Run();
} That way, during each iteration of JSBSim's time step when JSBSim calls you back in terms of the ground callback the aircraft carrier's position, velocity etc. will be in sync and not be X frames behind. |
Beta Was this translation helpful? Give feedback.
-
Even if the offset of the red lines indicating gear position isn't related to the aircraft carrier, my comment still stands in terms of you are going to have discrepancies in terms of ground reactions if the position of the aircraft carrier is updating at the game frame rate, e.g. 30Hz and not at JSBSim's update rate of 120Hz that is being used. I don't have Unreal installed, so I can't run and double-check things, so just reading the code I wonder if the offset of the red lines relative to the aircraft's 3D model is because the rendering of the gear red lines is done on line 298. But the aircraft's position is updated later on line 323. So the red gear lines are a rendering of the gear's position before the results of multiple, potentially 90 time-steps if for example the game frame rate is 30Hz versus 120Hz for JSBSim is applied. So the red lines are rendered for an old JSBSim position, the aircraft's position is updated, then UE renders the aircraft's 3D model using the updated position. So the faster the aircraft is moving, the larger the delta you'll see. Now @gallonmate mentioned:
However, looking at his 1:1 code above, there is still a difference, albeit of only 1 JSBSim sim frame between the position of the red lines versus the aircraft's latest position. So if my hypothesis is correct @gallonmate would be seeing a much smaller delta between the red lines and the aircraft's 3D model. So I'd suggest moving the |
Beta Was this translation helpful? Give feedback.
-
What did you do to make everything fine? Just move the
Or did you just assume there would be significant collision detection errors based on what you saw with the debug lines being rendered? Or did you also start updating the aircraft carrier's position at 120Hz in sync with JSBSim instead of only updating it based on the graphic engine's frame rate? |
Beta Was this translation helpful? Give feedback.
-
@jijnt12345 @gallonmate I've submitted a pull request, see - #1161 to render the debug data/lines after the actor's pose has been updated. |
Beta Was this translation helpful? Give feedback.
-
I found that in the UE5 JSBSim plugin, the position of the landing gear moves backward as the aircraft's speed increases during flight. This causes a discrepancy between the landing gear position and the 3D model of the aircraft, leading to significant collision detection errors during takeoff and landing. Could this be a frame rate issue? I noticed that JSBSim runs at a fixed 120 FPS, but the UE plugin corrects this in the Tick function. When the game thread's frame rate drops below 120 FPS,Could this be the direct cause of the issue. it achieves this through frame interpolation rather than using a separate multi-threaded FRunable class to run at 120 FPS
JF17.mp4
I would like to move the logic in Tick to run in a separate FRunable thread. Do you have any specific guidance or suggestions on how to do this?
Beta Was this translation helpful? Give feedback.
All reactions