Replies: 22 comments 14 replies
-
@miju70 I'm a bit confused, the code you show for It looks like your code snippet's call to Do you have some updated/customised version? |
Beta Was this translation helpful? Give feedback.
-
Okay, your original comment made it sound like you had found some existing code, as opposed to this being new customised code you've developed.
Correct, that's where I first looked, in particular in the landing gear code, where the angular velocity is ignored - Lines 287 to 298 in 8e4803b The Lines 351 to 356 in 8e4803b |
Beta Was this translation helpful? Give feedback.
-
@miju70 FlightGear supports take-offs and landings on aircraft carriers. I'm not aware of them making any specific changes to JSBSim in order to support this, in which case making use of the |
Beta Was this translation helpful? Give feedback.
-
Hmm, taking a quick look at the history for Which added support for |
Beta Was this translation helpful? Give feedback.
-
When I first looked into this, see my comment - #1158 (comment) I looked at the gear contact code and sure enough in that code the angular velocity is ignored, only the translational velocity of the ground is used. However, on further inspection after finding @bcoconni's commit I mentioned above I see that JSBSim does make use of the ground's angular velocity. First off, it's queried in jsbsim/src/models/FGPropagate.cpp Lines 592 to 598 in 8e4803b Then it's sent as an input to the accelerations code. Line 614 in 8e4803b Where, if at least one gear is in contact with the ground. jsbsim/src/models/FGAccelerations.cpp Lines 241 to 242 in 8e4803b Then the ground's angular velocity is finally used. jsbsim/src/models/FGAccelerations.cpp Lines 273 to 274 in 8e4803b |
Beta Was this translation helpful? Give feedback.
-
@miju70 any feedback? |
Beta Was this translation helpful? Give feedback.
-
You implement the ground callback, and if for example you determine that callback is for a point above an object like say an aircraft carrier, then you return the aircraft carrier's velocity as the |
Beta Was this translation helpful? Give feedback.
-
No, take a look at comment - #1158 (comment) and in particular the So all you need to do is set it. JSBSim will then make use of it, no need to modify any JSBSim source code. Take note of the angular terrain velocity, the 5th argument. The same applies to this. |
Beta Was this translation helpful? Give feedback.
-
Yep, but note that I also mentioned the terrain's angular velocity. Also look at my other previous comment - #1158 (comment) where I mention how JSBSim makes use of the terrain's angular velocity. Plus the explicit comment in the source code that I listed:
|
Beta Was this translation helpful? Give feedback.
-
So are you saying that everything is working now? |
Beta Was this translation helpful? Give feedback.
-
From the JSBSim source code snippets I listed in comments above you'll note vBodyWhlVel += in.UVW - in.Tec2b * terrainVel;
wdot += (in.vPQR - in.Tec2b * in.TerrainAngularVel) / dt; Where: /** Retrieves the ECEF-to-body transformation matrix.
@return a reference to the ECEF-to-body transformation matrix. */
const FGMatrix33& GetTec2b(void) const { return Tec2b; } |
Beta Was this translation helpful? Give feedback.
-
That was my point, JSBSim is expecting ECEF based velocities. And in terms of linear velocity JSBSim is expecting feet per second, whereas it looks like UE uses meters etc. Your JF-17 MP4 file, or link to it didn't work in your comment above. |
Beta Was this translation helpful? Give feedback.
-
Are @miju70 and you working together on the same project? To calculate the terrain's (ship's) angular velocity are you using the code that @miju70 showed in the original post above? |
Beta Was this translation helpful? Give feedback.
-
But as I pointed out to @miju70 the original plugin logic doesn't compute the angular velocity at all. |
Beta Was this translation helpful? Give feedback.
-
@jijnt12345 the reason I'm asking about your implementation of the carrier rotation is so that if someone else has this same issue months later and does a search and comes across this discussion then they can see an example of some working code that they could use. |
Beta Was this translation helpful? Give feedback.
-
Okay, so the only change you made to Just a bit surprised, given @miju70's original issue, plus @bcoconni's comment at the time he added support for the rotational velocity for the terrain to JSBSim:
Maybe your aircraft carrier isn't turning, or maybe you immediately start a take-off getting off the carrier before it becomes an issue? |
Beta Was this translation helpful? Give feedback.
-
Rad/s. Are you definitely also updating the aircraft carrier's pose for every JSBSim time step and not at a slower rate like the configured UE graphics update rate? |
Beta Was this translation helpful? Give feedback.
-
@jijnt12345 The way I have managed to send properly the linear velocity of the carrier to JSBSim is by creating a component of the carrier that does the velocity calculation and then JSBSim asks the ship for this velocity and send to the accelerations via double UJSBSimMovementComponent::GetAGLevel(
const FVector& StartECEFLocation,
FVector& ECEFContactPoint,
FVector& ECEFNormal,
FVector& ECEFVel,
FVector& ECEFAngularVel)
{
if (GetWorld()->LineTraceSingleByObjectType(HitResult, LineCheckStart, LineCheckEnd, ObjectParams, CollisionParams))
{
LineTraceImpactPoint = HitResult.ImpactPoint;
LineTraceImpactNormal = HitResult.ImpactNormal;
if (AActor* HitActor = HitResult.GetActor())
{
if (UJSBSimMovingGroundComponent* MovingGroundComponent =
HitActor->FindComponentByClass<UJSBSimMovingGroundComponent>())
{
ECEFVel = MovingGroundComponent->GetVelocity();
ECEFAngularVel = MovingGroundComponent->GetAngularVelocity();
}
}
}
} And this const FVector CurrentLocationUE = GetOwner()->GetActorLocation();
FVector CurrentLocationECEF;
GeoReferencingSystem->EngineToECEF(CurrentLocationUE, CurrentLocationECEF);
Velocity = (CurrentLocationECEF - LastTickLocation) / DeltaTime;
LastTickLocation = CurrentLocationECEF; |
Beta Was this translation helpful? Give feedback.
-
However, I'm still working on a solution for the angular velocity, I have an aproximation that works if the plane pivot is aligned with the carrier pivot on Z axis: FQuat CurrentRotationQuat = GetOwner()->GetActorQuat();
FQuat DeltaQuat = CurrentRotationQuat * PreviousRotationQuat.Inverse();
FVector RotationAxis;
float RotationAngle;
DeltaQuat.ToAxisAndAngle(RotationAxis, RotationAngle);
float RotationAngleDegrees = FMath::RadiansToDegrees(RotationAngle);
FVector AngularVelocityDegrees = (RotationAxis * RotationAngleDegrees) / DeltaTime;
AngularVelocityRadians.X = AngularVelocityDegrees.X * (PI / 180);
AngularVelocityRadians.Y = AngularVelocityDegrees.Y * (PI / 180);
AngularVelocityRadians.Z = AngularVelocityDegrees.Z * (PI / 180);
AngularVelocityRadians.X = -AngularVelocityRadians.X;
AngularVelocityRadians.Y = -AngularVelocityRadians.Y;
AngularVelocity = - 2.25 * AngularVelocityRadians;
PreviousRotationQuat = CurrentRotationQuat; But I can't achieve to make it works if the plane is on the carrier corner, as I need to add an aditional lateral velocity that matches the pivots diference. |
Beta Was this translation helpful? Give feedback.
-
@miju70 @jijnt12345 when you post C++ code snippets make use of Github's C++ formatting, you'll see I've been editing your posts to enable it so that it's easier to read for everyone. Basically you use 3 back ticks followed by the coding language, c++ in this case, then paste your code followed by 3 back ticks again. ```c++
some c++ code...
some c++ code...
``` - finish with 3 back ticks |
Beta Was this translation helpful? Give feedback.
-
@miju70 you could take a look at how FlightGear calculates the angular velocity for an aircraft carrier. |
Beta Was this translation helpful? Give feedback.
-
Just a small note to be aware that Flightgear is GPL licensed code. If planning to release a UE5 product to the public, then I would avoid copying any Flightgear code. If not planning to release UE5 product to public, then it's okay to copy. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to takeoff and land planes over ships that are moving in an Unreal Engine 5 level, in order to use JSBSim flight dynamics I have found there is a function inside UEGroundCallback which gets the angular velocity on ECEF coordinates and send it to accelerations.cpp to zero the relative angular velocity between the plane and the terrain:
Well in order to get the ship angular velocity from the plane, I have created a component called MovingGroundComponent and have attached it to the ship, this component provides the angular velocity of its owner the next way:
This last AngularVelocity variable is sent to JSBSim as ECEFAngularVel.
However, the relative rotation between plane and ship still not 0.
Has anyone tried to send angular velocity of the terrain from UE5 to JSBSim before?
Beta Was this translation helpful? Give feedback.
All reactions