Jump to content

Recommended Posts

Posted (edited)

After searching the entire forums and Google, I have not found discussion about this anywhere, so here is a thread about it. wHumanCustomPhysicsAPI.h refers to the ed_fm_set_surface function as follows:

 

/*
called before simulation to set up your environment for the next step

prototype for

ed_fm_set_surface    give parameters of surface under your aircraft usefull for ground effect
*/
typedef void (*PFN_SET_SURFACE)	  (double		h,//surface height under the center of aircraft
							   double		h_obj,//surface height with objects
							   unsigned		surface_type,
							   double		normal_x,//components of normal vector to surface
							   double		normal_y,//components of normal vector to surface
							   double		normal_z//components of normal vector to surface
							  );

As you can see, it returns information about elevation, the surface type (I presume paved, grass, water, snow, etc.), and the orientation of the surface. This could be useful for ground effect, custom gear effects like skis, custom buoyancy/water modeling, or anything else you might imagine.

 

By default, ed_fm_set_surface is not included in ED_FM_Template.cpp or ED_FM_Template.h. However, it can be added using the following code in ED_FM_Template.h:

 

		ED_FM_TEMPLATE_API void ed_fm_set_surface(double		h,//surface height under the center of aircraft
							   double		h_obj,//surface height with objects
							   unsigned		surface_type,
							   double		normal_x,//components of normal vector to surface
							   double		normal_y,//components of normal vector to surface
							   double		normal_z//components of normal vector to surface
							  );

and in ED_FM_Template.cpp: (I have also attached an example file below)

		void ed_fm_set_surface(double	h,//surface height under the center of aircraft
				double		h_obj,//surface height with objects
				unsigned	surface_type,
				double		normal_x,//components of normal vector to surface
				double		normal_y,//components of normal vector to surface
				double		normal_z//components of normal vector to surface
				)
{
//set the value of some variable in the file here.
}

The following is a table of the surface types discovered so far:

 

[TABLE]#| Surface Type | Ambient

0 | Grass, Mountain, Stream, Forest, Urban, Snow | background

1 | Sea | Sea

5 | Dam, Port | Town

7 | River, Lake | Water

22 | Farm | Field

23 | Tarmac, Runway | background [/TABLE]

  • Roads, rails, and bridges currently appear to take the surface type under them.
  • Weather does not appear to affect surface type.
  • Ambient sounds appear to be based on surface type.
  • Aircraft carrier decks do not count as a surface.

Regarding elevation:

  • Note that h and h_obj return elevation information about the ground above sea level, not AGL Altitude. To get AGL Altitude, just subtract this value from the MSL altitude from ed_fm_set_atmosphere.
  • h also gives bridge elevation, but only if you are on or above it.
  • h and h_obj still give sea level if you sink below the surface.
  • h and h_obj do not give aircraft carrier deck height.

Surface Normal:

  • The surface normal vector is a unit vector, so it always has a magnitude of 1 pointing out of the ground.
  • Hence, assuming an infinite surface plane, the shortest distance to it is: (hmsl-h)*Ny

 

Now for a couple questions: Is there a way to translate it away from the center of the aircraft, and is there a way to get this info at more than one point? If the surface is planar (usually true over small distances), then it is just a math problem to find elevation at a different location, otherwise this is wrong.

 

(For those that read this thread before, I just had a generic typo causing my problem.)

ed_fm_set_surface.zip

Edited by VincentLaw

[sIGPIC][/sIGPIC]

Posted

I'm still trying to understand the usefuless of this function. I already had AGL from the radar altitude function from the cockpit systems. The different surfaces don't seem to be varied enough to be as useful as you originally thought. Perhaps it will change over time.

Posted (edited)

Yes, I was a bit optimistic about surfaces, but it turns out they are currently quite limited. Landing gear obviously gets more information about the surface from something else since it can tell the difference between grass and road. Maybe this feature will be expanded in future maps, possibly with EDGE, or as they add more ambient effects.

 

It could still be used to add buoyancy into the flight model (except in streams) like the deployable airbags on the Ka-27.

 

The thing that you get from this function that you don't get from the radar altimeter is the surface normal vector. This would be important for calculating ground effect while hovering or flying close to an incline, since it would cause asymmetric ground effect in level flight... but as I pointed out, if you are near a curve/angle in the surface, or the edge of a roof/bridge, you will get the wrong results... and when I tested it before, the surface normal vector seemed wrong. I will check that again later.

Edited by VincentLaw

[sIGPIC][/sIGPIC]

Posted

Are you using this function for ground handling modelling? Because then h and h_obj variables should be accessible for any position, e.g. they should provide height information from ground to any XYZ coordinate that you request.

 

Regards!



Posted (edited)

Yes, I am trying to use it for ground interaction. You said there is a way to request info at an XYZ coordinate? the flight model template doesn't include any explanation for how to make a request of the function like that. It just automatically gets called at the origin of the 3d model once every timestep.

Edited by VincentLaw

[sIGPIC][/sIGPIC]

Posted
You said there is a way to request info at an XYZ coordinate?

 

No I didn't! I really don't know. But , since FM SDK provides you with aircraft attitude in global coordinates, and knowing the XYZ position of the point of interest in local frame, you can infer the height of any aircraft point using rotation/translation matrices. It's a bit cumbersome but it should do the trick. Results can contain some error , since you are considering that the height is constant around the aircraft, and in some cases (sea...) this doesn't have to be true.

 

Regards!



Posted (edited)

I am already using transformation matrices to calculate the altitude of different parts of the aircraft, also I am assuming the ground is flat, but not constant elevation. The function provides a normal vector for the surface directly under the aircraft so it is possible to make proper calculations for change in elevation of a planar incline. The problem is basically: I want more definition than that. I want to be able to tell when some points of the aircraft cross an edge between surface polygons.

 

Sorry for the misinterpretation.

Edited by VincentLaw

[sIGPIC][/sIGPIC]

Posted

Ahhh no problem VicentLaw! When landing in bare terrain, normal surface + h should be enough inputs for a custom ground handling model, you will get some errors in the terrain triangles edges, but they should be small since surface normals don't vary greatly, it's a good aproximation. Another story is landing over objects though, h_obj must be accesible for any X,Y,Z coordinate for an accurate contact point detection.

 

Regards!



Posted

I just checked again, and the surface normal vector is pointing in the correct direction. I guess I was just reading it incorrectly before. And you are right, the approximation from one coordinate is "good enough" most of the time.

[sIGPIC][/sIGPIC]

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...