Different ground elevation for each gear #648
Replies: 9 comments 12 replies
-
I had a quick glance at the code in FGColumnVector3 normal, terrainVel, dummy;
FGLocation gearLoc, contact;
FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg);
vLocalGear = in.Tb2l * vWhlBodyVec; // Get local frame wheel location
gearLoc = in.Location.LocalToLocation(vLocalGear);
// Compute the height of the theoretical location of the wheel (if strut is
// not compressed) with respect to the ground level
double height = fdmex->GetInertial()->GetContactPoint(gearLoc, contact,
normal, terrainVel,
dummy); With the following the code in /** @name Functions that rely on the ground callback
The following functions allow to set and get the vehicle position above
the ground. The ground level is obtained by interrogating an instance of
FGGroundCallback. A ground callback must therefore be set with
SetGroundCallback() before calling any of these functions. */
///@{
/** Get terrain contact point information below the current location.
@param location Location at which the contact point is evaluated.
@param contact Contact point location
@param normal Terrain normal vector in contact point (ECEF frame)
@param velocity Terrain linear velocity in contact point (ECEF frame)
@param ang_velocity Terrain angular velocity in contact point (ECEF frame)
@return Location altitude above contact point (AGL) in feet.
@see SetGroundCallback */
double GetContactPoint(const FGLocation& location, FGLocation& contact,
FGColumnVector3& normal, FGColumnVector3& velocity,
FGColumnVector3& ang_velocity) const
{
return GroundCallback->GetAGLevel(location, contact, normal, velocity,
ang_velocity); } The default GroundCallback implementation being: double FGDefaultGroundCallback::GetAGLevel(double t, const FGLocation& loc,
FGLocation& contact, FGColumnVector3& normal,
FGColumnVector3& vel, FGColumnVector3& angularVel) const
{
vel.InitMatrix();
angularVel.InitMatrix();
FGLocation l = loc;
l.SetEllipse(a,b);
double latitude = l.GetGeodLatitudeRad();
double cosLat = cos(latitude);
double longitude = l.GetLongitude();
normal = FGColumnVector3(cosLat*cos(longitude), cosLat*sin(longitude),
sin(latitude));
contact.SetEllipse(a, b);
contact.SetPositionGeodetic(longitude, latitude, mTerrainElevation);
return l.GetGeodAltitude() - mTerrainElevation;
} So it looks like you simply need to implement your own GroundCallback, which will be called to retrieve the AGL for each gear then. |
Beta Was this translation helpful? Give feedback.
-
No, a single instance, it will be called for each gear instance, with the location of that specific gear. Your code then must return the AGL for that specific location of the gear. |
Beta Was this translation helpful? Give feedback.
-
Foregive me if this is the wrong place to ask... Question: My Context: However, when the GetAGLevel callback is invoked it can't figure out how to map my own above-ground heights to the return value of each GetAGLevel callback. I tried matching each manually calculated AG height to its GetAGLevel return value by comparing the corresponding latitude-longitude values of each. However, this is a course mapping and makes me cringe. |
Beta Was this translation helpful? Give feedback.
-
@sr71684 I'm trying to understand exactly what sort of data and information you have and how you're trying to use it. I sort of assumed you have a high resolution DEM (Digital Elevation Model) which is fine enough such that when JSBSim calls your call back for each gear you can use the latitude longitude of the specific gear to return a distinct AGL value for each gear. In other words there is no need to know exactly which gear's AGL is being queried. |
Beta Was this translation helpful? Give feedback.
-
@sr71684 I pretty much have the exact same setup, i.e. I have a slightly modified JSBSim program (used for test pilot training) which I've then interfaced with Prepar3D for the external visuals and I use Prepar3D to retrieve DEM data. So I retrieve the ground elevation from Prepar3D based on the aircraft's cg latitude, longitude (which comes from JSBSim) with the following code: // Define AIRCRAFT_INFO_DATA_DEFINITION
hr = SimConnect_AddToDataDefinition(hSimConnect, AIRCRAFT_INFO_DATA_DEFINITION, "GROUND ALTITUDE", "meters", SIMCONNECT_DATATYPE_FLOAT64);
.....
.....
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
{
SIMCONNECT_RECV_SIMOBJECT_DATA* pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
if (pObjData->dwRequestID == AIRCRAFT_INFO_REQUEST)
{
AIRCRAFT_INFO_DATA* pInfoData = (AIRCRAFT_INFO_DATA*)&pObjData->dwData;
AircraftInfoData.GroundElevation = pInfoData->GroundElevation * 3.28083989;
Then pass this ground elevation into JSBSim. void copy_to_JSBSim()
{
// Set ground elevation
std::shared_ptr<JSBSim::FGPropagate> Propagate = FDMExec->GetPropagate();
Propagate->SetTerrainElevation(AircraftInfoData.GroundElevation);
.... The default implementation of So in my implementation there is a single ground elevation value for each time step based on the aircraft's cg at that time step. So in effect this implies a level portion of terrain under all the landing gears. So my first question is whether this isn't good enough for your setup? Or do you need finer grained elevation and do you have a DEM that has a resolution finer than the distance between the landing gears? In what sort of environment is your setup being used? |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
Okay thanks for confirming your requirements and what input data you have available. So given your very high resolution DEM then on each call to Do you not have direct access to the high resolution DEM such that you can perform the DEM lookup yourself in program A instead of having to perform an IPC to program B to get it to perform the DEM lookup? What coordinate system are you using in program B to perform the DEM lookup? On the JSBSim side the gear location that is passed into the AGL method includes ECEF coordinates as well as geographic coordinates. So on each time step you could make a single IPC from program A to program B which as you mentioned has enough state information to re-calculate the coordinates of all N gear and then perform the DEM lookups, and program B could then return a list of gear coordinates with associated AGL values which program A stores with the associated simulation time. Note the time argument double FGDefaultGroundCallback::GetAGLevel(double t, const FGLocation& loc,
FGLocation& contact, FGColumnVector3& normal,
FGColumnVector3& vel, FGColumnVector3& angularVel) const So on subsequent (N-1) calls to But I'd measure the time for N IPCs versus the extra work in terms of duplicating the N gear transformations, caching code etc. to see whether it's worth it. Especially if N is only on the order of 3. |
Beta Was this translation helpful? Give feedback.
-
If I recall correctly the ability to add per-gear elevation was added at
the same time FlightGear added aircraft carriers. This made it possible
to push an airplane back to a parking spot on the edge of the deck, and
if the main wheels passed the edge the airplane would fall (rather than
hover).
It's also used in FlightGear for different wheel drag effects, i.e. one
main wheel on the runway and one in the mud.
It's also used for slanted runways, i.e. runways that have a bit of
"roll angle".
…On 6/28/22 13:11, sr71 wrote:
It seems the feature I'm looking for is not currently possible with
JSBSim. I've been thinking about how I might implement this:
Option 1: Create properties that a user can write to that set terrain
elevation under each gear. For instance,
|Exec->SetPropertyValue("gear[0]/mTerrainElevation", x)|
Option 2: Add a new method argument to the AG callback that has a
reference to the gear / contact unit which invoked it.
double JSBSim::GetAGLevel(int contactIndex,const FGLocation& location,
FGLocation& contact,
FGColumnVector3&normal,
FGColumnVector3& vel,
FGColumnVector3& angularVel)const {
mTerrainElevation = contactLookupTable[contactIndex]
...
}
—
Reply to this email directly, view it on GitHub
<#648 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFDBF2LFXZLRAYBZTC3CYTTVRNMAHANCNFSM5YDZRQ7A>.
You are receiving this because you are subscribed to this
thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@sr71684 out of interest is your project a personal hobby project or is it for research or being used in a commercial company? Can you share any more details on the overall project/application? |
Beta Was this translation helpful? Give feedback.
-
Hello all, this is my second question about JSBSim.
I'm working on an integration of JSBSim with X-plane as visual and terrain generator/ Avionics connection/ controls and more.
Everything is working well, but I want to increase the integration.
I was able to develop an X-plane plugin that read the mesh and passed the correct elevation to JSBSim, this is very important in case of sloped runways.
Now I want more.
I was able to read the gear distance and probe the mesh for every single gear, but how to pass these values to the FDM?
In other words, is there a way to set different elevation for every single gear?
In the JSBSim reference Manual in the "ACKNOWLEDGEMENTS" page is written: "Mathias Frölich added a versatile per-gear ground elevation capability, and many other things". How can I have access to these characteristics? As far as I know the only elevation that I can pass is:
FGPropagate::SetTerrainElevation
Thanks!,
Beta Was this translation helpful? Give feedback.
All reactions