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 {
37 FG_HEADING_WAYPOINT = 1,
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 speed_error_accum; // speed error accumulator
69 double TargetSlope; // the glide slope hold value
71 double MaxRoll ; // the max the plane can roll for the turn
72 double RollOut; // when the plane should roll out
73 // measured from Heading
74 double MaxAileron; // how far to move the aleroin from center
75 double RollOutSmooth; // deg to use for smoothing Aileron Control
76 double MaxElevator; // the maximum elevator allowed
77 double SlopeSmooth; // smoothing angle for elevator
79 // following for testing disengagement of autopilot upon pilot
80 // interaction with controls
83 double old_elevator_trim;
86 // manual controls override beyond this value
87 double disengage_threshold;
89 // For future cross track error adjust
93 // keeping these locally to save work inside main loop
94 char TargetLatitudeStr[64];
95 char TargetLongitudeStr[64];
96 char TargetLatLonStr[64];
97 char TargetDistanceStr[64];
98 char TargetHeadingStr[64];
99 char TargetAltitudeStr[64];
103 // Initialize autopilot system
106 // Reset the autopilot system
109 // run an interation of the autopilot (updates control positions)
112 void AltitudeSet( double new_altitude );
113 void AltitudeAdjust( double inc );
114 void HeadingAdjust( double inc );
115 void AutoThrottleAdjust( double inc );
117 void HeadingSet( double value );
119 inline bool get_HeadingEnabled() const { return heading_hold; }
120 inline void set_HeadingEnabled( bool value ) { heading_hold = value; }
121 inline fgAutoHeadingMode get_HeadingMode() const { return heading_mode; }
122 void set_HeadingMode( fgAutoHeadingMode mode );
124 inline bool get_AltitudeEnabled() const { return altitude_hold; }
125 inline void set_AltitudeEnabled( bool value ) { altitude_hold = value; }
126 inline fgAutoAltitudeMode get_AltitudeMode() const { return altitude_mode;}
127 void set_AltitudeMode( fgAutoAltitudeMode mode );
129 inline bool get_AutoThrottleEnabled() const { return auto_throttle; }
130 void set_AutoThrottleEnabled( bool value );
132 inline double get_TargetLatitude() const { return TargetLatitude; }
133 inline void set_TargetLatitude( double val ) { TargetLatitude = val; }
134 inline void set_old_lat( double val ) { old_lat = val; }
135 inline double get_TargetLongitude() const { return TargetLongitude; }
136 inline void set_TargetLongitude( double val ) { TargetLongitude = val; }
137 inline void set_old_lon( double val ) { old_lon = val; }
138 inline double get_TargetHeading() const { return TargetHeading; }
139 inline void set_TargetHeading( double val ) { TargetHeading = val; }
140 inline double get_TargetDistance() const { return TargetDistance; }
141 inline void set_TargetDistance( double val ) { TargetDistance = val; }
142 inline double get_TargetAltitude() const { return TargetAltitude; }
143 inline void set_TargetAltitude( double val ) { TargetAltitude = val; }
145 inline char *get_TargetLatitudeStr() { return TargetLatitudeStr; }
146 inline char *get_TargetLongitudeStr() { return TargetLongitudeStr; }
147 inline char *get_TargetDistanceStr() { return TargetDistanceStr; }
148 inline char *get_TargetHeadingStr() { return TargetHeadingStr; }
149 inline char *get_TargetAltitudeStr() { return TargetAltitudeStr; }
150 inline char *get_TargetLatLonStr() { return TargetLatLonStr; }
153 void MakeTargetLatLonStr( double lat, double lon );
154 void MakeTargetAltitudeStr( double altitude );
155 void MakeTargetHeadingStr( double bearing );
156 void MakeTargetDistanceStr( double distance );
157 void update_old_control_values();
160 inline double get_MaxRoll() const { return MaxRoll; }
161 inline void set_MaxRoll( double val ) { MaxRoll = val; }
162 inline double get_RollOut() const { return RollOut; }
163 inline void set_RollOut( double val ) { RollOut = val; }
165 inline double get_MaxAileron() const { return MaxAileron; }
166 inline void set_MaxAileron( double val ) { MaxAileron = val; }
167 inline double get_RollOutSmooth() const { return RollOutSmooth; }
168 inline void set_RollOutSmooth( double val ) { RollOutSmooth = val; }
173 extern FGAutopilot *current_autopilot;
176 #endif // _NEWAUTO_HXX