]> git.mxchange.org Git - flightgear.git/blob - src/Autopilot/autopilot.hxx
Norman's autopilot updates, now serving great circle routes direct to
[flightgear.git] / src / Autopilot / autopilot.hxx
1 // autopilot.hxx -- autopilot defines and prototypes (very alpha)
2 //
3 // Written by Jeff Goeke-Smith, started April 1998.
4 //
5 // Copyright (C) 1998 Jeff Goeke-Smith  - jgoeke@voyager.net
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22                        
23                        
24 #ifndef _AUTOPILOT_HXX
25 #define _AUTOPILOT_HXX
26
27 #include <Include/compiler.h>
28                        
29 #include STL_STRING
30
31 #include <string.h>
32
33 #include <Aircraft/aircraft.hxx>
34 #include <FDM/flight.hxx>
35 #include <Controls/controls.hxx>
36                        
37 FG_USING_STD(string);
38
39                   
40 // Structures
41 typedef struct {
42     bool waypoint_hold;       // the current state of the target hold
43     bool heading_hold;        // the current state of the heading hold
44     bool altitude_hold;       // the current state of the altitude hold
45     bool terrain_follow;      // the current state of the terrain follower
46     bool auto_throttle;       // the current state of the auto throttle
47
48     double TargetLatitude;    // the latitude the AP should steer to.
49     double TargetLongitude;   // the longitude the AP should steer to.
50     double TargetDistance;    // the distance to Target.
51     double TargetHeading;     // the heading the AP should steer to.
52     double TargetAltitude;    // altitude to hold
53     double TargetAGL;         // the terrain separation
54     double TargetClimbRate;   // climb rate to shoot for
55     double TargetSpeed;       // speed to shoot for
56     double alt_error_accum;   // altitude error accumulator
57     double speed_error_accum; // speed error accumulator
58
59     double TargetSlope; // the glide slope hold value
60     
61     double MaxRoll ; // the max the plane can roll for the turn
62     double RollOut;  // when the plane should roll out
63     // measured from Heading
64     double MaxAileron; // how far to move the aleroin from center
65     double RollOutSmooth; // deg to use for smoothing Aileron Control
66     double MaxElevator; // the maximum elevator allowed
67     double SlopeSmooth; // smoothing angle for elevator
68         
69         // following for testing disengagement of autopilot
70         // apon pilot interaction with controls
71     double old_aileron;
72     double old_elevator;
73     double old_elevator_trim;
74     double old_rudder;
75         
76         // manual controls override beyond this value
77         double disengage_threshold; 
78
79         // For future cross track error adjust
80         double old_lat;
81         double old_lon;
82
83         // keeping these locally to save work inside main loop
84         char TargetLatitudeStr[32];
85         char TargetLongitudeStr[32];
86     char TargetLatLonStr[32];
87         char TargetDistanceStr[32];
88     char TargetHeadingStr[32];
89     char TargetAltitudeStr[32];
90 //      char jnk[32];
91         // using current_options.airport_id for now
92 //      string tgt_airport_id;  // ID of initial starting airport    
93 } fgAPData, *fgAPDataPtr ;
94                 
95
96 // Defines
97 #define AP_CURRENT_HEADING -1
98
99
100 // prototypes
101 void fgAPInit( fgAIRCRAFT *current_aircraft );
102 int fgAPRun( void );
103
104 void fgAPToggleWayPoint( void );
105 void fgAPToggleHeading( void );
106 void fgAPToggleAltitude( void );
107 void fgAPToggleTerrainFollow( void );
108 void fgAPToggleAutoThrottle( void );
109
110 bool fgAPTerrainFollowEnabled( void );
111 bool fgAPAltitudeEnabled( void );
112 bool fgAPHeadingEnabled( void );
113 bool fgAPWayPointEnabled( void );
114 bool fgAPAutoThrottleEnabled( void );
115
116 void fgAPAltitudeAdjust( double inc );
117 void fgAPHeadingAdjust( double inc );
118 void fgAPAutoThrottleAdjust( double inc );
119
120 void fgAPHeadingSet( double value );
121
122 double fgAPget_TargetLatitude( void );
123 double fgAPget_TargetLongitude( void );
124 double fgAPget_TargetHeading( void );
125 double fgAPget_TargetDistance( void );
126 double fgAPget_TargetAltitude( void );
127
128 char *fgAPget_TargetLatitudeStr( void );
129 char *fgAPget_TargetLongitudeStr( void );
130 char *fgAPget_TargetDistanceStr( void );
131 char *fgAPget_TargetHeadingStr( void );
132 char *fgAPget_TargetAltitudeStr( void );
133 char *fgAPget_TargetLatLonStr( void );
134
135 //void fgAPset_tgt_airport_id( const string );
136 //string fgAPget_tgt_airport_id( void );
137
138 void fgAPReset(void);
139
140 int geo_inverse_wgs_84( double alt,
141                                                 double lat1, double lon1,
142                                                 double lat2, double lon2,
143                                                 double *az1, double *az2,
144                                                 double *s );
145
146 int geo_direct_wgs_84(  double alt,
147                                                 double lat1, double lon1,
148                                                 double az1, double s,
149                                                 double *lat2, double *lon2,
150                                                 double *az2 );
151
152 class puObject;
153 void fgAPAdjust( puObject * );
154
155 #endif // _AUTOPILOT_HXX