1 // newauto.hxx -- autopilot defines and prototypes (very alpha)
3 // Started April 1998 Copyright (C) 1998
5 // Contributions by Jeff Goeke-Smith <jgoeke@voyager.net>
6 // Norman Vine <nhv@cape.com>
7 // Curtis Olson <curt@flightgear.org>
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 enum fgAutoHeadingMode {
39 FG_HEADING_WAYPOINT = 3
42 enum fgAutoAltitudeMode {
44 FG_ALTITUDE_TERRAIN = 1,
51 bool heading_hold; // the current state of the heading hold
52 bool altitude_hold; // the current state of the altitude hold
53 bool auto_throttle; // the current state of the auto throttle
55 fgAutoHeadingMode heading_mode;
56 fgAutoAltitudeMode altitude_mode;
58 double TargetLatitude; // the latitude the AP should steer to.
59 double TargetLongitude; // the longitude the AP should steer to.
60 double TargetDistance; // the distance to Target.
61 double TargetHeading; // the heading the AP should steer to.
62 double TargetAltitude; // altitude to hold
63 double TargetAGL; // the terrain separation
64 double TargetClimbRate; // climb rate to shoot for
65 double TargetSpeed; // speed to shoot for
66 double alt_error_accum; // altitude error accumulator
67 double climb_error_accum; // climb error accumulator (for GS)
68 double speed_error_accum; // speed error accumulator
70 double TargetSlope; // the glide slope hold value
72 double MaxRoll ; // the max the plane can roll for the turn
73 double RollOut; // when the plane should roll out
74 // measured from Heading
75 double MaxAileron; // how far to move the aleroin from center
76 double RollOutSmooth; // deg to use for smoothing Aileron Control
77 double MaxElevator; // the maximum elevator allowed
78 double SlopeSmooth; // smoothing angle for elevator
80 // following for testing disengagement of autopilot upon pilot
81 // interaction with controls
84 double old_elevator_trim;
87 // manual controls override beyond this value
88 double disengage_threshold;
90 // For future cross track error adjust
94 // keeping these locally to save work inside main loop
95 char TargetLatitudeStr[64];
96 char TargetLongitudeStr[64];
97 char TargetLatLonStr[64];
98 char TargetDistanceStr[64];
99 char TargetHeadingStr[64];
100 char TargetAltitudeStr[64];
104 // Initialize autopilot system
107 // Reset the autopilot system
110 // run an interation of the autopilot (updates control positions)
113 void AltitudeSet( double new_altitude );
114 void AltitudeAdjust( double inc );
115 void HeadingAdjust( double inc );
116 void AutoThrottleAdjust( double inc );
118 void HeadingSet( double value );
120 inline bool get_HeadingEnabled() const { return heading_hold; }
121 inline void set_HeadingEnabled( bool value ) { heading_hold = value; }
122 inline fgAutoHeadingMode get_HeadingMode() const { return heading_mode; }
123 void set_HeadingMode( fgAutoHeadingMode mode );
125 inline bool get_AltitudeEnabled() const { return altitude_hold; }
126 inline void set_AltitudeEnabled( bool value ) { altitude_hold = value; }
127 inline fgAutoAltitudeMode get_AltitudeMode() const { return altitude_mode;}
128 void set_AltitudeMode( fgAutoAltitudeMode mode );
130 inline bool get_AutoThrottleEnabled() const { return auto_throttle; }
131 void set_AutoThrottleEnabled( bool value );
133 inline double get_TargetLatitude() const { return TargetLatitude; }
134 inline void set_TargetLatitude( double val ) { TargetLatitude = val; }
135 inline void set_old_lat( double val ) { old_lat = val; }
136 inline double get_TargetLongitude() const { return TargetLongitude; }
137 inline void set_TargetLongitude( double val ) { TargetLongitude = val; }
138 inline void set_old_lon( double val ) { old_lon = val; }
139 inline double get_TargetHeading() const { return TargetHeading; }
140 inline void set_TargetHeading( double val ) { TargetHeading = val; }
141 inline double get_TargetDistance() const { return TargetDistance; }
142 inline void set_TargetDistance( double val ) { TargetDistance = val; }
143 inline double get_TargetAltitude() const { return TargetAltitude; }
144 inline void set_TargetAltitude( double val ) { TargetAltitude = val; }
146 inline char *get_TargetLatitudeStr() { return TargetLatitudeStr; }
147 inline char *get_TargetLongitudeStr() { return TargetLongitudeStr; }
148 inline char *get_TargetDistanceStr() { return TargetDistanceStr; }
149 inline char *get_TargetHeadingStr() { return TargetHeadingStr; }
150 inline char *get_TargetAltitudeStr() { return TargetAltitudeStr; }
151 inline char *get_TargetLatLonStr() { return TargetLatLonStr; }
154 void MakeTargetLatLonStr( double lat, double lon );
155 void MakeTargetAltitudeStr( double altitude );
156 void MakeTargetHeadingStr( double bearing );
157 void MakeTargetDistanceStr( double distance );
158 void update_old_control_values();
161 inline double get_MaxRoll() const { return MaxRoll; }
162 inline void set_MaxRoll( double val ) { MaxRoll = val; }
163 inline double get_RollOut() const { return RollOut; }
164 inline void set_RollOut( double val ) { RollOut = val; }
166 inline double get_MaxAileron() const { return MaxAileron; }
167 inline void set_MaxAileron( double val ) { MaxAileron = val; }
168 inline double get_RollOutSmooth() const { return RollOutSmooth; }
169 inline void set_RollOutSmooth( double val ) { RollOutSmooth = val; }
174 extern FGAutopilot *current_autopilot;
177 #endif // _NEWAUTO_HXX