1
0
Fork 0

Changes to support new simgear waypoint module.

This commit is contained in:
curt 2000-10-11 00:18:26 +00:00
parent 7c38f172d9
commit 1e5e2eb36e
6 changed files with 86 additions and 69 deletions

View 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() );

View 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() << " ) "
);
}

View 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; }

View 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 \

View 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

View 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