]> git.mxchange.org Git - flightgear.git/commitdiff
Changes to support new simgear waypoint module.
authorcurt <curt>
Wed, 11 Oct 2000 00:18:26 +0000 (00:18 +0000)
committercurt <curt>
Wed, 11 Oct 2000 00:18:26 +0000 (00:18 +0000)
src/Autopilot/auto_gui.cxx
src/Autopilot/newauto.cxx
src/Autopilot/newauto.hxx
src/Main/Makefile.am
src/Main/bfi.cxx
src/Main/bfi.hxx

index 56943208a6439b671c9b449057cdf0ada3fa904c..862167b88b1eaa36ed71b9e73ecf9e05ca999b01 100644 (file)
@@ -609,8 +609,10 @@ void TgtAptDialog_OK (puObject *)
                current_options.set_airport_id( TgtAptId.c_str() );
                sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
                        
-               current_autopilot->set_TargetLatitude( a.latitude );
-               current_autopilot->set_TargetLongitude( a.longitude );
+               current_autopilot->set_WayPoint( a.longitude, a.latitude,
+                                                TgtAptId );
+               // current_autopilot->set_TargetLatitude( a.latitude );
+               // current_autopilot->set_TargetLongitude( a.longitude );
                current_autopilot->MakeTargetLatLonStr(
                                     current_autopilot->get_TargetLatitude(),
                                     current_autopilot->get_TargetLongitude() );
index 6a99e05707ac08a6c0cef6989b071f722ddbe494..9955b6b21af927f7e67c5578a15198516f83ffbb 100644 (file)
@@ -67,8 +67,8 @@ extern char *coord_format_lon(float);
                        
 
 void FGAutopilot::MakeTargetLatLonStr( double lat, double lon ) {
-    sprintf( TargetLatitudeStr , "%s", coord_format_lat(TargetLatitude) );
-    sprintf( TargetLongitudeStr, "%s", coord_format_lon(TargetLongitude) );
+    sprintf( TargetLatitudeStr , "%s", coord_format_lat(get_TargetLatitude()));
+    sprintf( TargetLongitudeStr, "%s", coord_format_lon(get_TargetLongitude()));
     sprintf( TargetLatLonStr, "%s  %s", TargetLatitudeStr, TargetLongitudeStr );
 }
 
@@ -144,10 +144,11 @@ void FGAutopilot::init() {
     auto_throttle = false ;    // turn the auto throttle off
 
     // Initialize target location to startup location
-    old_lat = TargetLatitude = FGBFI::getLatitude();
-    old_lon = TargetLongitude = FGBFI::getLongitude();
+    old_lat = FGBFI::getLatitude();
+    old_lon = FGBFI::getLongitude();
+    set_WayPoint( old_lon, old_lat, "default" );
 
-    MakeTargetLatLonStr( TargetLatitude, TargetLongitude);
+    MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
        
     TargetHeading = 0.0;       // default direction, due north
     TargetAltitude = 3000;     // default altitude in meters
@@ -212,9 +213,11 @@ void FGAutopilot::reset() {
 
     sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() );
        
-    TargetLatitude = FGBFI::getLatitude();
-    TargetLongitude = FGBFI::getLongitude();
-    MakeTargetLatLonStr( TargetLatitude, TargetLongitude );
+    // TargetLatitude = FGBFI::getLatitude();
+    // TargetLongitude = FGBFI::getLongitude();
+    set_WayPoint( FGBFI::getLongitude(), FGBFI::getLatitude(), "reset" );
+
+    MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
 }
 
 
@@ -330,7 +333,7 @@ int FGAutopilot::run() {
        } else if ( heading_mode == FG_HEADING_WAYPOINT ) {
            // update target heading to waypoint
 
-           double wp_course, wp_reverse, wp_distance;
+           double wp_course, /*wp_reverse,*/ wp_distance;
 
 #ifdef DO_fgAP_CORRECTED_COURSE
            // compute course made good
@@ -349,39 +352,31 @@ int FGAutopilot::run() {
 
            // compute course to way_point
            // need to test for iter
-           if( ! geo_inverse_wgs_84( 0, //fgAPget_altitude(),
-                                     lat,
-                                     lon,
-                                     TargetLatitude,
-                                     TargetLongitude,
-                                     &wp_course,
-                                     &wp_reverse,
-                                     &wp_distance ) ) {
-               
+           waypoint.CourseAndDistance( lon, lat, &wp_course, &wp_distance );
+
 #ifdef DO_fgAP_CORRECTED_COURSE
-               corrected_course = course - wp_course;
-               if( fabs(corrected_course) > 0.1 )
-                   printf("fgAP: course %f  wp_course %f  %f  %f\n",
-                          course, wp_course, fabs(corrected_course),
-                          distance );
+           corrected_course = course - wp_course;
+           if( fabs(corrected_course) > 0.1 )
+               printf("fgAP: course %f  wp_course %f  %f  %f\n",
+                      course, wp_course, fabs(corrected_course),
+                      distance );
 #endif // DO_fgAP_CORRECTED_COURSE
                
-               if ( wp_distance > 100 ) {
-                   // corrected_course = course - wp_course;
-                   TargetHeading = NormalizeDegrees(wp_course);
-               } else {
-                   printf("distance(%f) to close\n", wp_distance);
-                   // Real Close -- set heading hold to current heading
-                   // and Ring the arival bell !!
-                   heading_mode = FG_HEADING_LOCK;
-                   // use current heading
-                   TargetHeading = FGBFI::getHeading();
-               }
-               MakeTargetHeadingStr( TargetHeading );
-               // Force this just in case
-               TargetDistance = wp_distance;
-               MakeTargetDistanceStr( wp_distance );
+           if ( wp_distance > 100 ) {
+               // corrected_course = course - wp_course;
+               TargetHeading = NormalizeDegrees(wp_course);
+           } else {
+               printf("distance(%f) to close\n", wp_distance);
+               // Real Close -- set heading hold to current heading
+               // and Ring the arival bell !!
+               heading_mode = FG_HEADING_LOCK;
+               // use current heading
+               TargetHeading = FGBFI::getHeading();
            }
+           MakeTargetHeadingStr( TargetHeading );
+           // Force this just in case
+           TargetDistance = wp_distance;
+           MakeTargetDistanceStr( wp_distance );
        }
 
        double RelHeading;
@@ -628,29 +623,21 @@ void FGAutopilot::set_HeadingMode( fgAutoHeadingMode mode ) {
        // set heading hold to current heading
        TargetHeading = FGBFI::getHeading();
     } else if ( heading_mode == FG_HEADING_WAYPOINT ) {
-       double course, reverse, distance;
+       double course, /*reverse,*/ distance;
        // turn on location hold
        // turn on heading hold
        old_lat = FGBFI::getLatitude();
        old_lon = FGBFI::getLongitude();
                        
-       // need to test for iter
-       if( !geo_inverse_wgs_84( FGBFI::getAltitude() * FEET_TO_METER,
-                                FGBFI::getLatitude(),
-                                FGBFI::getLongitude(),
-                                TargetLatitude,
-                                TargetLongitude,
-                                &course,
-                                &reverse,
-                                &distance ) ) {
-           TargetHeading = course;
-           TargetDistance = distance;
-           MakeTargetDistanceStr( distance );
-       }
+       waypoint.CourseAndDistance( FGBFI::getLongitude(), FGBFI::getLatitude(),
+                                   &course, &distance );
+       TargetHeading = course;
+       TargetDistance = distance;
+       MakeTargetDistanceStr( distance );
 
        FG_LOG( FG_COCKPIT, FG_INFO, " fgAPSetLocation: ( "
-               << TargetLatitude  << " "
-               << TargetLongitude << " ) "
+               << get_TargetLatitude()  << " "
+               << get_TargetLongitude() << " ) "
                );
     }
        
index 334e2b26cd31388d28dab88e103fffeb324438c3..5ec7c924ad3b01632652577ba55269e7be57804b 100644 (file)
@@ -27,6 +27,9 @@
 #define _NEWAUTO_HXX
 
 
+#include <simgear/route/waypoint.hxx>
+
+
 // Structures
 class FGAutopilot {
 
@@ -55,8 +58,10 @@ private:
     fgAutoHeadingMode heading_mode;
     fgAutoAltitudeMode altitude_mode;
 
-    double TargetLatitude;     // the latitude the AP should steer to.
-    double TargetLongitude;    // the longitude the AP should steer to.
+    SGWayPoint waypoint;       // the waypoint the AP should steer to.
+
+    // double TargetLatitude;  // the latitude the AP should steer to.
+    // double TargetLongitude; // the longitude the AP should steer to.
     double TargetDistance;     // the distance to Target.
     double TargetHeading;      // the heading the AP should steer to.
     double TargetAltitude;     // altitude to hold
@@ -130,11 +135,19 @@ public:
     inline bool get_AutoThrottleEnabled() const { return auto_throttle; }
     void set_AutoThrottleEnabled( bool value );
 
-    inline double get_TargetLatitude() const { return TargetLatitude; }
-    inline void set_TargetLatitude( double val ) { TargetLatitude = val; }
+    inline void set_WayPoint( const double lon, const double lat,
+                             const string s ) {
+       waypoint = SGWayPoint( lon, lat, SGWayPoint::WGS84, "Current WP" );
+    }
+    inline double get_TargetLatitude() const {
+       return waypoint.get_target_lat();
+    }
+    inline double get_TargetLongitude() const {
+       return waypoint.get_target_lon();
+    }
+    // inline void set_TargetLatitude( double val ) { TargetLatitude = val; }
+    // inline void set_TargetLongitude( double val ) { TargetLongitude = val; }
     inline void set_old_lat( double val ) { old_lat = val; }
-    inline double get_TargetLongitude() const { return TargetLongitude; }
-    inline void set_TargetLongitude( double val ) { TargetLongitude = val; }
     inline void set_old_lon( double val ) { old_lon = val; }
     inline double get_TargetHeading() const { return TargetHeading; }
     inline void set_TargetHeading( double val ) { TargetHeading = val; }
index 37bce676aa5300f004b4b7c1e7ebc29dd9711ec4..61525a3f4db05913d4869c53484278290d3b9e32 100644 (file)
@@ -65,8 +65,8 @@ fgfs_LDADD = \
        $(top_builddir)/src/Time/libTime.a \
        $(WEATHER_LIBS) \
        $(top_builddir)/src/Joystick/libJoystick.a \
-       -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket \
-       -lsgdebug -lsgmagvar -lsgmisc -lsgxml \
+       -lsgroute -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen -lsgmath \
+       -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \
        $(SERIAL_LIBS) \
        -lplibpu -lplibfnt -lplibssg -lplibsg \
        -lmk4 -lz \
index ac50f56e344c0963a6bf6e9ffea27079a54f85c0..351792f90d64ea4aad20f867a07cb414016942dd 100644 (file)
@@ -314,8 +314,9 @@ FGBFI::reinit ()
   setAPAltitude(apAltitude);
   setTargetAirport(targetAirport);
   setGPSLock(gpsLock);
-  setGPSTargetLatitude(gpsLatitude);
-  setGPSTargetLongitude(gpsLongitude);
+  // setGPSTargetLatitude(gpsLatitude);
+  // setGPSTargetLongitude(gpsLongitude);
+  setGPSTargetWayPoint(gpsLatitude, gpsLongitude);
 
   _needReinit = false;
 
@@ -1556,6 +1557,17 @@ FGBFI::getGPSTargetLatitude ()
 }
 
 
+/**
+ * Set the GPS target waypoint
+ */
+void
+FGBFI::setGPSTargetWayPoint (double latitude, double longitude)
+{
+  current_autopilot->set_WayPoint( longitude, latitude, "reload" );
+}
+
+
+#if 0
 /**
  * Set the GPS target latitude in degrees (negative for south).
  */
@@ -1564,6 +1576,7 @@ FGBFI::setGPSTargetLatitude (double latitude)
 {
   current_autopilot->set_TargetLatitude( latitude );
 }
+#endif
 
 
 /**
@@ -1575,7 +1588,7 @@ FGBFI::getGPSTargetLongitude ()
   return current_autopilot->get_TargetLongitude();
 }
 
-
+#if 0
 /**
  * Set the GPS target longitude in degrees (negative for west).
  */
@@ -1584,6 +1597,7 @@ FGBFI::setGPSTargetLongitude (double longitude)
 {
   current_autopilot->set_TargetLongitude( longitude );
 }
+#endif
 
 
 \f
index 851dd0d4ff87c9d1e8282a3678b4ee1efc7fb3b9..8f26d88556cb3589ada3646d62a1c63c9056c666 100644 (file)
@@ -197,8 +197,9 @@ public:
 
   static void setTargetAirport (const string &targetAirport);
   static void setGPSLock (bool lock);
-  static void setGPSTargetLatitude (double latitude);
-  static void setGPSTargetLongitude (double longitude);
+  // static void setGPSTargetLatitude (double latitude);
+  // static void setGPSTargetLongitude (double longitude);
+  static void setGPSTargetWayPoint (double latitude, double longitude);
 
 
                                // Weather