1 // rnav_waypt_controller.hxx - Waypoint-specific behaviours for RNAV systems
2 // Written by James Turner, started 2009.
4 // Copyright (C) 2009 Curtis L. Olson
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef FG_WAYPT_CONTROLLER_HXX
21 #define FG_WAYPT_CONTROLLER_HXX
23 #include <Navaids/waypoint.hxx>
29 * Abstract RNAV interface, for devices which implement an RNAV
30 * system - INS / GPS / FMS
35 virtual SGGeod position() = 0;
38 * True track in degrees
40 virtual double trackDeg() = 0;
43 * Ground speed (along the track) in knots
45 virtual double groundSpeedKts() = 0;
48 * Vertical speed in ft/minute
50 virtual double vspeedFPM()= 0;
53 * Magnetic variation at current position
55 virtual double magvarDeg() = 0;
58 * device selected course (eg, from autopilot / MCP / OBS) in degrees
60 virtual double selectedMagCourse() = 0;
63 * minimum distance to switch next waypoint.
65 virtual double overflightDistanceM() = 0;
67 * minimum distance to a waypoint for overflight sequencing.
69 virtual double overflightArmDistanceM() = 0;
71 * angle for overflight sequencing.
73 virtual double overflightArmAngleDeg() = 0;
76 * device leg previous waypoint position(eg, from route manager)
78 virtual SGGeod previousLegWaypointPosition(bool& isValid)= 0;
85 virtual ~WayptController();
89 virtual void update() = 0;
92 * Compute time until the waypoint is done
94 virtual double timeToWaypt() const;
97 * Compute distance until the waypoint is done
99 virtual double distanceToWayptM() const = 0;
102 * Bearing to the waypoint, if this value is meaningful.
103 * Default implementation returns the target track
105 virtual double trueBearingDeg() const
106 { return _targetTrack; }
108 virtual double targetTrackDeg() const
109 { return _targetTrack; }
111 virtual double xtrackErrorNm() const
114 virtual double courseDeviationDeg() const
118 * Position associated with the waypt. For static waypoints, this is
119 * simply the waypoint position itself; for dynamic points, it's the
120 * estimated location at which the controller will be done.
122 virtual SGGeod position() const = 0;
125 * Is this controller finished?
131 * to/from flag - true = to, false = from. Defaults to 'true' because
132 * nearly all waypoint controllers become done as soon as this value would
135 virtual bool toFlag() const
139 * Static factory method, given a waypoint, return a controller bound
140 * to it, of the appropriate type
142 static WayptController* createForWaypt(RNAV* rnav, const WayptRef& aWpt);
144 WayptController(RNAV* aRNAV, const WayptRef& aWpt) :
161 * Controller supports 'directTo' (DTO) navigation to a waypoint. This
162 * creates a course from a starting point, to the waypoint, and reports
163 * deviation from that course.
165 * The controller is done when the waypoint is reached (to/from goes to 'from')
167 class DirectToController : public WayptController
170 DirectToController(RNAV* aRNAV, const WayptRef& aWpt, const SGGeod& aOrigin);
173 virtual void update();
174 virtual double distanceToWayptM() const;
175 virtual double xtrackErrorNm() const;
176 virtual double courseDeviationDeg() const;
177 virtual double trueBearingDeg() const;
178 virtual SGGeod position() const;
181 double _distanceAircraftTargetMeter;
183 double _courseAircraftToTarget;
189 class OBSController : public WayptController
192 OBSController(RNAV* aRNAV, const WayptRef& aWpt);
195 virtual void update();
196 virtual double distanceToWayptM() const;
197 virtual double xtrackErrorNm() const;
198 virtual double courseDeviationDeg() const;
199 virtual double trueBearingDeg() const;
200 virtual bool toFlag() const;
201 virtual SGGeod position() const;
203 double _distanceAircraftTargetMeter;
205 double _courseAircraftToTarget;
208 } // of namespace flightgear