Norman's autopilot updates, now serving great circle routes direct to
the center of airports.
This commit is contained in:
parent
d5a3c2e8a4
commit
057fa8d37e
5 changed files with 1451 additions and 490 deletions
File diff suppressed because it is too large
Load diff
|
@ -24,19 +24,30 @@
|
|||
#ifndef _AUTOPILOT_HXX
|
||||
#define _AUTOPILOT_HXX
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <FDM/flight.hxx>
|
||||
#include <Controls/controls.hxx>
|
||||
|
||||
FG_USING_STD(string);
|
||||
|
||||
|
||||
// Structures
|
||||
typedef struct {
|
||||
bool waypoint_hold; // the current state of the target hold
|
||||
bool heading_hold; // the current state of the heading hold
|
||||
bool altitude_hold; // the current state of the altitude hold
|
||||
bool terrain_follow; // the current state of the terrain follower
|
||||
bool auto_throttle; // the current state of the auto throttle
|
||||
|
||||
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
|
||||
double TargetAGL; // the terrain separation
|
||||
|
@ -55,6 +66,30 @@ typedef struct {
|
|||
double MaxElevator; // the maximum elevator allowed
|
||||
double SlopeSmooth; // smoothing angle for elevator
|
||||
|
||||
// following for testing disengagement of autopilot
|
||||
// apon pilot interaction with controls
|
||||
double old_aileron;
|
||||
double old_elevator;
|
||||
double old_elevator_trim;
|
||||
double old_rudder;
|
||||
|
||||
// manual controls override beyond this value
|
||||
double disengage_threshold;
|
||||
|
||||
// For future cross track error adjust
|
||||
double old_lat;
|
||||
double old_lon;
|
||||
|
||||
// keeping these locally to save work inside main loop
|
||||
char TargetLatitudeStr[32];
|
||||
char TargetLongitudeStr[32];
|
||||
char TargetLatLonStr[32];
|
||||
char TargetDistanceStr[32];
|
||||
char TargetHeadingStr[32];
|
||||
char TargetAltitudeStr[32];
|
||||
// char jnk[32];
|
||||
// using current_options.airport_id for now
|
||||
// string tgt_airport_id; // ID of initial starting airport
|
||||
} fgAPData, *fgAPDataPtr ;
|
||||
|
||||
|
||||
|
@ -66,6 +101,7 @@ typedef struct {
|
|||
void fgAPInit( fgAIRCRAFT *current_aircraft );
|
||||
int fgAPRun( void );
|
||||
|
||||
void fgAPToggleWayPoint( void );
|
||||
void fgAPToggleHeading( void );
|
||||
void fgAPToggleAltitude( void );
|
||||
void fgAPToggleTerrainFollow( void );
|
||||
|
@ -74,6 +110,7 @@ void fgAPToggleAutoThrottle( void );
|
|||
bool fgAPTerrainFollowEnabled( void );
|
||||
bool fgAPAltitudeEnabled( void );
|
||||
bool fgAPHeadingEnabled( void );
|
||||
bool fgAPWayPointEnabled( void );
|
||||
bool fgAPAutoThrottleEnabled( void );
|
||||
|
||||
void fgAPAltitudeAdjust( double inc );
|
||||
|
@ -82,11 +119,37 @@ void fgAPAutoThrottleAdjust( double inc );
|
|||
|
||||
void fgAPHeadingSet( double value );
|
||||
|
||||
double fgAPget_TargetLatitude( void );
|
||||
double fgAPget_TargetLongitude( void );
|
||||
double fgAPget_TargetHeading( void );
|
||||
double fgAPget_TargetDistance( void );
|
||||
double fgAPget_TargetAltitude( void );
|
||||
|
||||
char *fgAPget_TargetLatitudeStr( void );
|
||||
char *fgAPget_TargetLongitudeStr( void );
|
||||
char *fgAPget_TargetDistanceStr( void );
|
||||
char *fgAPget_TargetHeadingStr( void );
|
||||
char *fgAPget_TargetAltitudeStr( void );
|
||||
char *fgAPget_TargetLatLonStr( void );
|
||||
|
||||
//void fgAPset_tgt_airport_id( const string );
|
||||
//string fgAPget_tgt_airport_id( void );
|
||||
|
||||
void fgAPReset(void);
|
||||
|
||||
int geo_inverse_wgs_84( double alt,
|
||||
double lat1, double lon1,
|
||||
double lat2, double lon2,
|
||||
double *az1, double *az2,
|
||||
double *s );
|
||||
|
||||
int geo_direct_wgs_84( double alt,
|
||||
double lat1, double lon1,
|
||||
double az1, double s,
|
||||
double *lat2, double *lon2,
|
||||
double *az2 );
|
||||
|
||||
class puObject;
|
||||
void fgAPAdjust( puObject * );
|
||||
|
||||
#endif // _AUTOPILOT_HXX
|
||||
|
||||
|
||||
|
|
|
@ -993,6 +993,7 @@ int brightness = pHUDInstr->get_brightness();
|
|||
pHUDInstr->SetBrightness( brightness );
|
||||
}
|
||||
|
||||
#if 0
|
||||
// fgUpdateHUD
|
||||
//
|
||||
// Performs a once around the list of calls to instruments installed in
|
||||
|
@ -1132,3 +1133,168 @@ void fgUpdateHUD( void ) {
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// fgUpdateHUD
|
||||
//
|
||||
// Performs a once around the list of calls to instruments installed in
|
||||
// the HUD object with requests for redraw. Kinda. It will when this is
|
||||
// all C++.
|
||||
//
|
||||
void fgUpdateHUD( void ) {
|
||||
int brightness;
|
||||
// int day_night_sw = current_aircraft.controls->day_night_switch;
|
||||
int day_night_sw = global_day_night_switch;
|
||||
int hud_displays = HUD_deque.size();
|
||||
instr_item *pHUDInstr;
|
||||
float line_width;
|
||||
|
||||
if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
|
||||
return;
|
||||
}
|
||||
|
||||
HUD_TextList.erase();
|
||||
HUD_LineList.erase();
|
||||
// HUD_StippleLineList.erase();
|
||||
|
||||
pHUDInstr = HUD_deque[0];
|
||||
brightness = pHUDInstr->get_brightness();
|
||||
// brightness = HUD_deque.at(0)->get_brightness();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0, 640, 0, 480);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glIndexi(7);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// We can do translucency, so why not. :-)
|
||||
// glEnable ( GL_BLEND ) ;
|
||||
// glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
if( day_night_sw == DAY) {
|
||||
switch (brightness) {
|
||||
case BRT_LIGHT:
|
||||
// glColor4f (0.1, 0.9, 0.1, 0.75);
|
||||
glColor3f (0.1, 0.9, 0.1);
|
||||
break;
|
||||
|
||||
case BRT_MEDIUM:
|
||||
// glColor4f (0.1, 0.7, 0.0, 0.75);
|
||||
glColor3f (0.1, 0.7, 0.0);
|
||||
break;
|
||||
|
||||
case BRT_DARK:
|
||||
// glColor4f (0.0, 0.6, 0.0, 0.75);
|
||||
glColor3f(0.0, 0.6, 0.0);
|
||||
break;
|
||||
|
||||
case BRT_BLACK:
|
||||
// glColor4f( 0.0, 0.0, 0.0, 0.75);
|
||||
glColor3f( 0.0, 0.0, 0.0);
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( day_night_sw == NIGHT) {
|
||||
switch (brightness) {
|
||||
case BRT_LIGHT:
|
||||
// glColor4f (0.9, 0.1, 0.1, 0.75);
|
||||
glColor3f (0.9, 0.1, 0.1);
|
||||
break;
|
||||
|
||||
case BRT_MEDIUM:
|
||||
// glColor4f (0.7, 0.0, 0.1, 0.75);
|
||||
glColor3f (0.7, 0.0, 0.1);
|
||||
break;
|
||||
|
||||
case BRT_DARK:
|
||||
default:
|
||||
// glColor4f (0.6, 0.0, 0.0, 0.75);
|
||||
glColor3f (0.6, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
else { // Just in case default
|
||||
// glColor4f (0.1, 0.9, 0.1, 0.75);
|
||||
glColor3f (0.1, 0.9, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
deque < instr_item * > :: iterator current = HUD_deque.begin();
|
||||
deque < instr_item * > :: iterator last = HUD_deque.end();
|
||||
|
||||
for ( ; current != last; ++current ) {
|
||||
pHUDInstr = *current;
|
||||
|
||||
if( pHUDInstr->enabled()) {
|
||||
// fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
|
||||
// hud->code, hud->status );
|
||||
pHUDInstr->draw();
|
||||
// HUD_deque.at(i)->draw(); // Responsible for broken or fixed variants.
|
||||
// No broken displays honored just now.
|
||||
}
|
||||
}
|
||||
|
||||
char *gmt_str = get_formated_gmt_time();
|
||||
HUD_TextList.add( fgText(40, 10, gmt_str) );
|
||||
|
||||
// temporary
|
||||
extern bool fgAPAltitudeEnabled( void );
|
||||
extern bool fgAPHeadingEnabled( void );
|
||||
extern bool fgAPWayPointEnabled( void );
|
||||
extern char *fgAPget_TargetDistanceStr( void );
|
||||
extern char *fgAPget_TargetHeadingStr( void );
|
||||
extern char *fgAPget_TargetAltitudeStr( void );
|
||||
extern char *fgAPget_TargetLatLonStr( void );
|
||||
|
||||
int apY = 480 - 80;
|
||||
char scratch[128];
|
||||
// HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) );
|
||||
// apY -= 15;
|
||||
if( fgAPHeadingEnabled() ) {
|
||||
HUD_TextList.add( fgText( 40, apY, fgAPget_TargetHeadingStr()) );
|
||||
apY -= 15;
|
||||
}
|
||||
if( fgAPAltitudeEnabled() ) {
|
||||
HUD_TextList.add( fgText( 40, apY, fgAPget_TargetAltitudeStr()) );
|
||||
apY -= 15;
|
||||
}
|
||||
if( fgAPWayPointEnabled() ) {
|
||||
HUD_TextList.add( fgText( 40, apY, fgAPget_TargetLatLonStr()) );
|
||||
apY -= 15;
|
||||
HUD_TextList.add( fgText( 40, apY, fgAPget_TargetDistanceStr() ) );
|
||||
apY -= 15;
|
||||
}
|
||||
|
||||
HUD_TextList.draw();
|
||||
|
||||
line_width = (current_options.get_xsize() > 1000) ? 1.0 : 0.5;
|
||||
glLineWidth(line_width);
|
||||
HUD_LineList.draw();
|
||||
|
||||
// glEnable(GL_LINE_STIPPLE);
|
||||
// glLineStipple( 1, 0x00FF );
|
||||
// HUD_StippleLineList.draw();
|
||||
// glDisable(GL_LINE_STIPPLE);
|
||||
|
||||
// glDisable( GL_BLEND );
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ extern void NewAltitude( puObject *cb );
|
|||
extern void NewHeading( puObject *cb );
|
||||
extern void fgAPAdjust( puObject * );
|
||||
extern void fgLatLonFormatToggle( puObject *);
|
||||
extern void NewTgtAirport( puObject *cb );
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
Mouse stuff
|
||||
|
@ -714,10 +715,12 @@ puCallback viewSubmenuCb [] = {
|
|||
};
|
||||
|
||||
char *aircraftSubmenu [] = {
|
||||
"Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
|
||||
"Autopilot", "Heading", "Altitude", "Navigation", "Airport",
|
||||
"Communication", NULL
|
||||
};
|
||||
puCallback aircraftSubmenuCb [] = {
|
||||
fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
|
||||
fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, NewTgtAirport,
|
||||
notCb, NULL
|
||||
};
|
||||
|
||||
char *environmentSubmenu [] = {
|
||||
|
@ -736,7 +739,8 @@ puCallback optionsSubmenuCb [] = {
|
|||
|
||||
#ifdef FG_NETWORK_OLK
|
||||
char *networkSubmenu [] = {
|
||||
"Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", "Register to FGD",
|
||||
"Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots",
|
||||
"Register to FGD",
|
||||
"Scan for Deamons", "Enter Callsign", "Display Netinfos", "Toggle Display",
|
||||
"Hyper Blast", NULL
|
||||
};
|
||||
|
|
|
@ -400,6 +400,9 @@ void GLUTspecialkey(int k, int x, int y) {
|
|||
t->togglePauseMode();
|
||||
return;
|
||||
}
|
||||
case GLUT_KEY_F6: // F6 toggles Autopilot target location
|
||||
fgAPToggleWayPoint();
|
||||
return;
|
||||
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
|
||||
current_options.cycle_fog();
|
||||
|
||||
|
|
Loading…
Reference in a new issue