On Monday 12 June 2006 07:15, Mick - wrote:
> Through observation, I found that my calculated agl value (as discussed in
> my
> previous post) was close to that of "/position/ground-elev-ft" when using
> the
> current lat/lon values instead of those from
> Point3D calc_gc_lon_lat( const Point3D& orig, double course, double dist ).
> I did this in an attempt to compare against the /position/ground-elev-ft
> value.
> The resulting value was close but not the same. Having
> converted between feet and meters, and degrees and radians for the purpose
> of the calculations, would this have resulted in the slight difference in
> value?
Ok, what is 'slight' in that case?

> With my limited avionics knowledge, I assumed that:
> (altitude-ft - ground-elev-ft) = altitude-agl-ft. Again, this is something
> I want to verify
> instead of assuming. So is it (somewhat) correct to assume that subtracting
> the
> current altitude from my "calculated agl" would give me the the
> altitude-agl-ft?
That should be ok.

Anyway, I have attached the quick hack that I used to test that and the past 
material changes. That might serve as a starting point for you.
It takes the aircraft's position (not the view position!) does an additional 
ground query at that location and computes an additional location 10 meters 
away in the direction of your view. There is also an additional ground query.
Both are printed to stdout ...

Hope that helps

         Greetings

                 Mathias

-- 
Mathias Fröhlich, email: [EMAIL PROTECTED]
? src/FDM/OpenFDM
Index: configure.ac
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/configure.ac,v
retrieving revision 1.116
diff -u -r1.116 configure.ac
--- configure.ac	5 Apr 2006 19:52:52 -0000	1.116
+++ configure.ac	12 Jun 2006 06:13:18 -0000
@@ -439,6 +439,14 @@
 fi
 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
 
+dnl Check for installed OpenFDM
+AC_CHECK_HEADER(OpenFDM/OpenFDMConfig.h)
+AM_CONDITIONAL(ENABLE_OpenFDM_FDM, \
+               [ test "x$ac_cv_header_OpenFDM_OpenFDMConfig_h" = "xyes" ] )
+if test "x$ac_cv_header_OpenFDM_OpenFDMConfig_h" = "xyes" ; then
+    AC_DEFINE([FG_ENABLE_OPENFDM_FDM], 1, [Define for no logging output])
+fi
+
 AC_LANG_POP
 
 dnl Check for system installed zlib
@@ -519,6 +527,7 @@
 	src/FDM/JSBSim/models/atmosphere/Makefile \
 	src/FDM/JSBSim/models/propulsion/Makefile \
 	src/FDM/LaRCsim/Makefile \
+	src/FDM/OpenFDM/Makefile \
 	src/FDM/SP/Makefile \
 	src/FDM/UIUCModel/Makefile \
 	src/FDM/YASim/Makefile \
Index: src/FDM/Makefile.am
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/Makefile.am,v
retrieving revision 1.7
diff -u -r1.7 Makefile.am
--- src/FDM/Makefile.am	22 Nov 2004 10:10:33 -0000	1.7
+++ src/FDM/Makefile.am	12 Jun 2006 06:13:18 -0000
@@ -4,8 +4,14 @@
 SP_DIR =
 endif
 
+if ENABLE_OpenFDM_FDM
+OpenFDM_DIR = OpenFDM
+else
+OpenFDM_DIR =
+endif
+
 SUBDIRS	= Balloon JSBSim LaRCsim UIUCModel YASim \
-          $(SP_DIR) ExternalNet ExternalPipe
+          $(SP_DIR) $(OpenFDM_DIR) ExternalNet ExternalPipe
 
 noinst_LIBRARIES = libFlight.a
 
Index: src/FDM/flight.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/flight.hxx,v
retrieving revision 1.13
diff -u -r1.13 flight.hxx
--- src/FDM/flight.hxx	11 Jun 2006 13:34:19 -0000	1.13
+++ src/FDM/flight.hxx	12 Jun 2006 06:13:20 -0000
@@ -433,7 +433,10 @@
 	FG_PARACHUTE = 9,
 
 	// Driven externally via a serial port, net, file, etc.
-	FG_EXTERNAL = 10
+	FG_EXTERNAL = 10,
+
+	// OpenFDM. Reads JSBSim legacy and new files.
+	FG_OPENFDM = 11
     };
 
     // initialization
Index: src/Main/Makefile.am
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/Makefile.am,v
retrieving revision 1.68
diff -u -r1.68 Makefile.am
--- src/Main/Makefile.am	14 May 2006 12:22:53 -0000	1.68
+++ src/Main/Makefile.am	12 Jun 2006 06:13:20 -0000
@@ -9,6 +9,13 @@
 SP_FDM_LIBS = 
 endif
 
+if ENABLE_OpenFDM_FDM
+OpenFDM_LIBS = $(top_builddir)/src/FDM/OpenFDM/libFGOpenFDM.a \
+               -lOpenFDMJSBReader -lOpenFDMeasyxmlXML -lOpenFDMXML -lOpenFDM
+else
+OpenFDM_LIBS = 
+endif
+
 if WITH_THREADS
 THREAD_LIBS = -lsgthreads $(thread_LIBS)
 else
@@ -74,6 +81,7 @@
 	$(top_builddir)/src/FDM/LaRCsim/libLaRCsim.a \
 	$(top_builddir)/src/FDM/UIUCModel/libUIUCModel.a \
 	$(SP_FDM_LIBS) \
+	$(OpenFDM_LIBS) \
 	$(top_builddir)/src/GUI/libGUI.a \
 	$(top_builddir)/src/Autopilot/libAutopilot.a \
 	$(top_builddir)/src/Input/libInput.a \
Index: src/Main/fg_init.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_init.cxx,v
retrieving revision 1.165
diff -u -r1.165 fg_init.cxx
--- src/Main/fg_init.cxx	10 Jun 2006 22:24:05 -0000	1.165
+++ src/Main/fg_init.cxx	12 Jun 2006 06:13:20 -0000
@@ -88,6 +88,9 @@
 #include <FDM/UFO.hxx>
 #include <FDM/NullFDM.hxx>
 #include <FDM/YASim/YASim.hxx>
+#ifdef FG_ENABLE_OPENFDM_FDM
+#include <FDM/OpenFDM/FGOpenFDM.h>
+#endif
 #include <GUI/new_gui.hxx>
 #include <Include/general.hxx>
 #include <Input/input.hxx>
@@ -1336,6 +1339,10 @@
             cur_fdm_state = new FGNullFDM( dt );
         } else if ( model == "yasim" ) {
             cur_fdm_state = new YASim( dt );
+#ifdef FG_ENABLE_OPENFDM_FDM
+        } else if ( model == "openfdm" ) {
+            cur_fdm_state = new OpenFDM::FGOpenFDM();
+#endif
         } else {
             SG_LOG(SG_GENERAL, SG_ALERT,
                    "Unrecognized flight model '" << model
Index: src/Main/main.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/main.cxx,v
retrieving revision 1.219
diff -u -r1.219 main.cxx
--- src/Main/main.cxx	11 Jun 2006 13:34:19 -0000	1.219
+++ src/Main/main.cxx	12 Jun 2006 06:13:21 -0000
@@ -20,7 +20,6 @@
 //
 // $Id: main.cxx,v 1.219 2006-06-11 13:34:19 frohlich Exp $
 
-
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -50,6 +49,7 @@
 // Class references
 #include <simgear/ephemeris/ephemeris.hxx>
 #include <simgear/scene/model/modellib.hxx>
+#include <simgear/scene/material/mat.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/model/animation.hxx>
 #include <simgear/scene/sky/sky.hxx>
@@ -568,6 +568,42 @@
       }
     }
 
+
+    {
+      double lon = view_location->getLongitude_deg();
+      double lat = view_location->getLatitude_deg();
+      double alt = view_location->getAltitudeASL_ft() * SG_FEET_TO_METER;
+      const SGMaterial* material;
+      double lev;
+      globals->get_scenery()->get_elevation_m(lat, lon, alt+2, lev, &material);
+
+      std::cout << std::setprecision(16);
+      std::cout << "Ground level = " << lev;
+      if (material && !material->get_names().empty())
+        std::cout << " " << material->get_names().front();
+      std::cout << std::endl;
+      
+      extern Point3D calc_gc_lon_lat( const Point3D& orig, double course,
+                                      double dist );
+      Point3D orig;
+      orig.setlat(lat*SGD_DEGREES_TO_RADIANS);
+      orig.setlon(lon*SGD_DEGREES_TO_RADIANS);
+      orig.setelev(alt);
+      double course = (current_view->getHeadingOffset_deg() + current_view->getHeading_deg())*SGD_DEGREES_TO_RADIANS;
+      std::cout << "course " << (current_view->getHeadingOffset_deg() + current_view->getHeading_deg()) << std::endl;
+      Point3D pt = calc_gc_lon_lat(orig, course, 10);
+      std::cout << "ahead " << pt.lat()*SGD_RADIANS_TO_DEGREES << " " << pt.lon()*SGD_RADIANS_TO_DEGREES << std::endl;
+      
+      globals->get_scenery()->get_elevation_m(pt.lat()*SGD_RADIANS_TO_DEGREES,
+                                              pt.lon()*SGD_RADIANS_TO_DEGREES,
+                                              alt+2, lev, &material);
+      
+      std::cout << "10m ahead view: Ground level = " << lev;
+      if (material && !material->get_names().empty())
+        std::cout << " " << material->get_names().front();
+      std::cout << std::endl;
+    }
+    
 #ifdef ENABLE_AUDIO_SUPPORT
     // Right now we make a simplifying assumption that the primary
     // aircraft is the source of all sounds and that all sounds are
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to