1 // autopilot.hxx -- autopilot defines and prototypes (very alpha)
3 // Written by Jeff Goeke-Smith, started April 1998.
5 // Copyright (C) 1998 Jeff Goeke-Smith - jgoeke@voyager.net
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.
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.
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.
24 #ifndef _AUTOPILOT_HXX
25 #define _AUTOPILOT_HXX
27 #include <Include/compiler.h>
33 #include <Aircraft/aircraft.hxx>
34 #include <FDM/flight.hxx>
35 #include <Controls/controls.hxx>
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
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
59 double TargetSlope; // the glide slope hold value
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
69 // following for testing disengagement of autopilot
70 // apon pilot interaction with controls
73 double old_elevator_trim;
76 // manual controls override beyond this value
77 double disengage_threshold;
79 // For future cross track error adjust
83 // keeping these locally to save work inside main loop
84 char TargetLatitudeStr[64];
85 char TargetLongitudeStr[64];
86 char TargetLatLonStr[64];
87 char TargetDistanceStr[64];
88 char TargetHeadingStr[64];
89 char TargetAltitudeStr[64];
91 // using current_options.airport_id for now
92 // string tgt_airport_id; // ID of initial starting airport
93 } fgAPData, *fgAPDataPtr ;
97 #define AP_CURRENT_HEADING -1
101 void fgAPInit( fgAIRCRAFT *current_aircraft );
104 void fgAPToggleWayPoint( void );
105 void fgAPToggleHeading( void );
106 void fgAPToggleAltitude( void );
107 void fgAPToggleTerrainFollow( void );
108 void fgAPToggleAutoThrottle( void );
110 bool fgAPTerrainFollowEnabled( void );
111 bool fgAPAltitudeEnabled( void );
112 bool fgAPHeadingEnabled( void );
113 bool fgAPWayPointEnabled( void );
114 bool fgAPAutoThrottleEnabled( void );
116 void fgAPAltitudeAdjust( double inc );
117 void fgAPHeadingAdjust( double inc );
118 void fgAPAutoThrottleAdjust( double inc );
120 void fgAPHeadingSet( double value );
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 );
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 );
135 //void fgAPset_tgt_airport_id( const string );
136 //string fgAPget_tgt_airport_id( void );
138 void fgAPReset(void);
140 int geo_inverse_wgs_84( double alt,
141 double lat1, double lon1,
142 double lat2, double lon2,
143 double *az1, double *az2,
146 int geo_direct_wgs_84( double alt,
147 double lat1, double lon1,
148 double az1, double s,
149 double *lat2, double *lon2,
153 void fgAPAdjust( puObject * );
155 #endif // _AUTOPILOT_HXX