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.
30 #include <simgear/route/waypoint.hxx>
38 enum fgAutoHeadingMode {
39 FG_DG_HEADING_LOCK = 0,
43 FG_HEADING_WAYPOINT = 4
46 enum fgAutoAltitudeMode {
48 FG_ALTITUDE_TERRAIN = 1,
55 bool heading_hold; // the current state of the heading hold
56 bool altitude_hold; // the current state of the altitude hold
57 bool auto_throttle; // the current state of the auto throttle
59 fgAutoHeadingMode heading_mode;
60 fgAutoAltitudeMode altitude_mode;
62 SGWayPoint waypoint; // the waypoint the AP should steer to.
64 // double TargetLatitude; // the latitude the AP should steer to.
65 // double TargetLongitude; // the longitude the AP should steer to.
66 double TargetDistance; // the distance to Target.
67 double DGTargetHeading; // the apparent DG heading to steer towards.
68 double TargetHeading; // the true heading the AP should steer to.
69 double TargetAltitude; // altitude to hold
70 double TargetAGL; // the terrain separation
71 double TargetClimbRate; // climb rate to shoot for
72 double TargetSpeed; // speed to shoot for
73 double alt_error_accum; // altitude error accumulator
74 double climb_error_accum; // climb error accumulator (for GS)
75 double speed_error_accum; // speed error accumulator
77 double TargetSlope; // the glide slope hold value
79 double MaxRoll ; // the max the plane can roll for the turn
80 double RollOut; // when the plane should roll out
81 // measured from Heading
82 double MaxAileron; // how far to move the aleroin from center
83 double RollOutSmooth; // deg to use for smoothing Aileron Control
84 double MaxElevator; // the maximum elevator allowed
85 double SlopeSmooth; // smoothing angle for elevator
87 // following for testing disengagement of autopilot upon pilot
88 // interaction with controls
91 double old_elevator_trim;
94 // manual controls override beyond this value
95 double disengage_threshold;
97 // For future cross track error adjust
101 // keeping these locally to save work inside main loop
102 char TargetLatitudeStr[64];
103 char TargetLongitudeStr[64];
104 char TargetLatLonStr[64];
105 char TargetWP1Str[64];
106 char TargetWP2Str[64];
107 char TargetWP3Str[64];
108 char TargetHeadingStr[64];
109 char TargetAltitudeStr[64];
113 // Initialize autopilot system
116 // Reset the autopilot system
119 // run an interation of the autopilot (updates control positions)
122 void AltitudeSet( double new_altitude );
123 void AltitudeAdjust( double inc );
124 void HeadingAdjust( double inc );
125 void AutoThrottleAdjust( double inc );
127 void HeadingSet( double value );
129 inline bool get_HeadingEnabled() const { return heading_hold; }
130 inline void set_HeadingEnabled( bool value ) { heading_hold = value; }
131 inline fgAutoHeadingMode get_HeadingMode() const { return heading_mode; }
132 void set_HeadingMode( fgAutoHeadingMode mode );
134 inline bool get_AltitudeEnabled() const { return altitude_hold; }
135 inline void set_AltitudeEnabled( bool value ) { altitude_hold = value; }
136 inline fgAutoAltitudeMode get_AltitudeMode() const { return altitude_mode;}
137 void set_AltitudeMode( fgAutoAltitudeMode mode );
139 inline bool get_AutoThrottleEnabled() const { return auto_throttle; }
140 void set_AutoThrottleEnabled( bool value );
142 /* inline void set_WayPoint( const double lon, const double lat,
143 const double alt, const string s ) {
144 waypoint = SGWayPoint( lon, lat, alt, SGWayPoint::WGS84, "Current WP" );
146 inline double get_TargetLatitude() const {
147 return waypoint.get_target_lat();
149 inline double get_TargetLongitude() const {
150 return waypoint.get_target_lon();
152 inline void set_old_lat( double val ) { old_lat = val; }
153 inline void set_old_lon( double val ) { old_lon = val; }
154 inline double get_TargetHeading() const { return TargetHeading; }
155 inline void set_TargetHeading( double val ) { TargetHeading = val; }
156 inline double get_DGTargetHeading() const { return DGTargetHeading; }
157 inline void set_DGTargetHeading( double val ) { DGTargetHeading = val; }
158 inline double get_TargetDistance() const { return TargetDistance; }
159 inline void set_TargetDistance( double val ) { TargetDistance = val; }
160 inline double get_TargetAltitude() const { return TargetAltitude; }
161 inline void set_TargetAltitude( double val ) { TargetAltitude = val; }
163 inline char *get_TargetLatitudeStr() { return TargetLatitudeStr; }
164 inline char *get_TargetLongitudeStr() { return TargetLongitudeStr; }
165 inline char *get_TargetWP1Str() { return TargetWP1Str; }
166 inline char *get_TargetWP2Str() { return TargetWP2Str; }
167 inline char *get_TargetWP3Str() { return TargetWP3Str; }
168 inline char *get_TargetHeadingStr() { return TargetHeadingStr; }
169 inline char *get_TargetAltitudeStr() { return TargetAltitudeStr; }
170 inline char *get_TargetLatLonStr() { return TargetLatLonStr; }
173 void MakeTargetLatLonStr( double lat, double lon );
174 void MakeTargetAltitudeStr( double altitude );
175 void MakeTargetHeadingStr( double bearing );
176 void MakeTargetWPStr( double distance );
177 void update_old_control_values();
180 inline double get_MaxRoll() const { return MaxRoll; }
181 inline void set_MaxRoll( double val ) { MaxRoll = val; }
182 inline double get_RollOut() const { return RollOut; }
183 inline void set_RollOut( double val ) { RollOut = val; }
185 inline double get_MaxAileron() const { return MaxAileron; }
186 inline void set_MaxAileron( double val ) { MaxAileron = val; }
187 inline double get_RollOutSmooth() const { return RollOutSmooth; }
188 inline void set_RollOutSmooth( double val ) { RollOutSmooth = val; }
193 extern FGAutopilot *current_autopilot;
196 #endif // _NEWAUTO_HXX