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 a waypoint for overflight sequencing.
65 virtual double overflightArmDistanceM() = 0;
71 virtual ~WayptController();
75 virtual void update() = 0;
78 * Compute time until the waypoint is done
80 virtual double timeToWaypt() const;
83 * Compute distance until the waypoint is done
85 virtual double distanceToWayptM() const = 0;
88 * Bearing to the waypoint, if this value is meaningful.
89 * Default implementation returns the target track
91 virtual double trueBearingDeg() const
92 { return _targetTrack; }
94 virtual double targetTrackDeg() const
95 { return _targetTrack; }
97 virtual double xtrackErrorNm() const
100 virtual double courseDeviationDeg() const
104 * Position associated with the waypt. For static waypoints, this is
105 * simply the waypoint position itself; for dynamic points, it's the
106 * estimated location at which the controller will be done.
108 virtual SGGeod position() const = 0;
111 * Is this controller finished?
117 * to/from flag - true = to, false = from. Defaults to 'true' because
118 * nearly all waypoint controllers become done as soon as this value would
121 virtual bool toFlag() const
125 * Static factory method, given a waypoint, return a controller bound
126 * to it, of the appropriate type
128 static WayptController* createForWaypt(RNAV* rnav, const WayptRef& aWpt);
130 WayptController(RNAV* aRNAV, const WayptRef& aWpt) :
146 * Controller supports 'directTo' (DTO) navigation to a waypoint. This
147 * creates a course from a starting point, to the waypoint, and reports
148 * deviation from that course.
150 * The controller is done when the waypoint is reached (to/from goes to 'from')
152 class DirectToController : public WayptController
155 DirectToController(RNAV* aRNAV, const WayptRef& aWpt, const SGGeod& aOrigin);
158 virtual void update();
159 virtual double distanceToWayptM() const;
160 virtual double xtrackErrorNm() const;
161 virtual double courseDeviationDeg() const;
162 virtual double trueBearingDeg() const;
163 virtual SGGeod position() const;
173 class OBSController : public WayptController
176 OBSController(RNAV* aRNAV, const WayptRef& aWpt);
179 virtual void update();
180 virtual double distanceToWayptM() const;
181 virtual double xtrackErrorNm() const;
182 virtual double courseDeviationDeg() const;
183 virtual double trueBearingDeg() const;
184 virtual bool toFlag() const;
185 virtual SGGeod position() const;
191 } // of namespace flightgear