Debian Codegraph @

test_suite/FGTestApi/TestPilot.hxx

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 James Turner
3 *
4 * This file is part of the program FlightGear.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _FGTEST_API_TEST_PILOT_HXX
21 #define _FGTEST_API_TEST_PILOT_HXX
22
23 #include <simgear/props/propsfwd.hxx>
24 #include <simgear/math/SGMathFwd.hxx>
25 #include <simgear/structure/subsystem_mgr.hxx>
26 #include <simgear/math/SGGeod.hxx>
27
28 class GPS;
29
30 namespace FGTestApi {
31
32 /**
33 * @brief simulation of the user (pilot) fying in a particular way
34 * around the world. Standard property tree values are updated
35 * (position / orientation / velocity)
36 */
37 class TestPilot : public SGSubsystem
38 {
39 public:
40 TestPilot(SGPropertyNode_ptr props = {});
41 ~TestPilot();
42
43 void resetAtPosition(const SGGeod& pos);
44
45 void setSpeedKts(double knots);
46
47 void setCourseTrue(double deg);
48 void turnToCourse(double deg);
49
50 void setVerticalFPM(double fpm);
51 void setTargetAltitudeFtMSL(double altFt);
52
53 // void setTurnRateDegSec();
54
55 void init() override;
56 void update(double dT) override;
57
58 void flyHeading(double hdg);
59 void flyDirectTo(const SGGeod& target);
60 void flyGPSCourse(GPS *gps);
61
62 void flyGPSCourseOffset(GPS *gps, double offsetNm);
63
64 bool isOnHeading(double heading) const;
65
66 double trueCourseDeg() const;
67 private:
68 enum class LateralMode
69 {
70 Heading,
71 Direct,
72 GPSCourse,
73 GPSOffset
74 };
75
76 void updateValues(double dt);
77 void setPosition(const SGGeod& pos);
78
79 SGPropertyNode_ptr _propRoot;
80
81 double _trueCourseDeg = 0.0;
82 double _speedKnots = 0.0; // IAS
83 double _vspeedFPM = 0.0;
84
85 bool _turnActive = false;
86 bool _altActive = false;
87 double _targetCourseDeg = 0.0;
88 double _targetAltitudeFt = 0.0;
89
90 LateralMode _lateralMode = LateralMode::Heading;
91 SGGeod _targetPos;
92 GPS* _gps = nullptr;
93 double _courseOffsetNm =0.0;
94
95 SGPropertyNode_ptr _latProp;
96 SGPropertyNode_ptr _lonProp;
97 SGPropertyNode_ptr _altitudeProp;
98 SGPropertyNode_ptr _headingProp;
99 SGPropertyNode_ptr _speedKnotsProp;
100 SGPropertyNode_ptr _verticalFPMProp;
101 SGPropertyNode_ptr _groundspeedKnotsProp;
102 SGPropertyNode_ptr _speedMachProp;
103
104 SGPropertyNode_ptr _gpsNode;
105 SGPropertyNode_ptr _gpsLegCourse;
106 SGPropertyNode_ptr _courseErrorNm;
107 };
108
109 } // of namespace FGTestApi
110
111 #endif // of _FGTEST_API_TEST_PILOT_HXX
112