WSF
WsfPathGuidance.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFPATHGUIDANCE_HPP
16#define WSFPATHGUIDANCE_HPP
17
18#include "wsf_export.h"
19
20#include "UtInput.hpp"
21class WsfMover;
22#include "WsfPath.hpp"
23class WsfWaypoint;
24
39{
40public:
43 enum
44 {
45 cSPEED = 0x0001,
46 cAXIAL_ACCEL = 0x0002,
47 cCLIMB_RATE = 0x0004,
48 cALTITUDE = 0x0008,
49 cHEADING = 0x0010,
50 cTURN_RATE = 0x0020,
51 cRADIAL_ACCEL = 0x0040,
52 cLAT_LON = 0x0080,
53 cSEGMENT_TIME = 0x0100,
54 cSEGMENT_DIST = 0x0200,
56 };
57
59 virtual ~WsfPathGuidance();
60 virtual WsfPathGuidance* Clone() const;
61
64 void SetMover(WsfMover* aMoverPtr) { mMoverPtr = aMoverPtr; }
65
67 WsfMover* GetMover() const { return mMoverPtr; }
68
69 virtual bool Initialize(double aSimTime);
70 virtual bool ProcessInput(UtInput& aInput);
71 virtual void Update(double aSimTime);
72
73 void TriggerExtrapolation();
74
75 // const (or mutable) accessors:
76
79 bool IsChanged() const { return mIsChanged; }
80 bool IsOnGround() const { return mIsOnGround; }
81 bool IsOnRoad() const { return mIsOnRoad; }
82 bool IsExtrapolating() const { return mSwitch == WsfPath::cSWITCH_EXTERNAL; }
83 bool IsStopping() const { return mSpeed == 0.0; }
84 bool IsInitialized() const { return mInitialized; }
85 bool IsPaused() const { return mPauseTime > 0.0; }
86 double GetPauseTime() const { return mPauseTime; }
87
88 virtual double GetAltitude() const;
89 virtual double GetSpeed() const;
90
91 double GetRawHeading() const { return mHeading; }
92 double GetClimbRate() const { return mClimbRate; }
93 double GetLatitude() const { return mLatitude; }
94 double GetLongitude() const { return mLongitude; }
95 double GetSegmentEndTime() const { return mSegEndTime; }
96 double GetSegmentEndDist() const { return mSegEndDist; }
97 double GetAxialAccel() const { return mAxialAccel; }
98 double GetRadialAccel() const { return mRadialAccel; }
99 double GetTurnRate() const { return mTurnRate; }
100
101 WsfPath::AltRef GetAltRef() const { return mAltRef; }
102 WsfPath::HdgRef GetHdgRef() const { return mHdgRef; }
103 WsfPath::TurnDirection GetTurnDir() const { return mSetTurnDir; }
104 WsfPath::Switch GetSwitch() const { return mSwitch; }
105
106 // non-const
107 void DecrementPauseTime(double aValue) { mPauseTime -= aValue; }
108 void SetPauseTime(double aValue) { mPauseTime = aValue; }
109 void SetAltitude(double aAltitude, WsfPath::AltRef aAltRef);
110 void SetAltitude(double aAltitude, WsfPath::AltRef aMoverDefault, WsfPath::AltRef aAltRefWP_Override);
111 void SetLatLon(double aLatitude, double aLongitude);
112 void SetHeading(double aHeading, WsfPath::HdgRef aHdgRef);
113 void SetClimbRate(double aClimbRate);
114 void SetLLA(double aLatitude,
115 double aLongitude,
116 double aAltitude,
117 WsfPath::AltRef aMoverDefault,
118 WsfPath::AltRef aAltRefOverride = WsfPath::cALT_REF_MSL);
119 void SetSpeed(double aSpeed);
120 void SetAxialAccel(double aAxialAccel);
121 void SetRadialAccel(double aRadialAccel);
122 void SetTurnRate(double aTurnRate);
123 void SetSegmentEndTime(double aSegmentTime);
124 void SetSegmentEndDist(double aSegmentDist);
125 void SetHdgRef(WsfPath::HdgRef aHdgRef);
126 void SetTurnDir(WsfPath::TurnDirection aTurnDir);
127 void SetSwitch(WsfPath::Switch aMoverDefault, WsfPath::Switch aWP_SwitchOverride);
128 void ClearValid(int aClearMask);
129 bool IsSet(int aMask);
130
131 bool SpeedIsSet() const { return (mValidityMap & cSPEED) ? true : false; }
132 bool AltIsSet() const { return (mValidityMap & cALTITUDE) ? true : false; }
133 bool LatLonIsSet() const { return (mValidityMap & cLAT_LON) ? true : false; }
134 bool HeadingIsSet() const { return (mValidityMap & cHEADING) ? true : false; }
135 bool AxialAccelIsSet() const { return (mValidityMap & cAXIAL_ACCEL) ? true : false; }
136 bool ClimbRateIsSet() const { return (mValidityMap & cCLIMB_RATE) ? true : false; }
137 bool TurnRateIsSet() const { return (mValidityMap & cTURN_RATE) ? true : false; }
138 bool RadialAccelIsSet() const { return (mValidityMap & cRADIAL_ACCEL) ? true : false; }
139 bool SegmentTimeIsSet() const { return (mValidityMap & cSEGMENT_TIME) ? true : false; }
140 bool SegmentDistIsSet() const { return (mValidityMap & cSEGMENT_DIST) ? true : false; }
141
142 // Convenience methods...
143 bool LLA_IsSet() const { return LatLonIsSet() && AltIsSet(); }
144 bool HdgAndAltSet() const { return HeadingIsSet() && AltIsSet(); }
145 bool HdgAltAndSpeedSet() const { return HeadingIsSet() && AltIsSet() && SpeedIsSet(); }
146
147 // Three chosen turn outputs, first check the flag, then use the two accessors:
148 bool TurnIsDetermined() const { return (mValidityMap & cTURN_DETERMINED) ? true : false; }
149 double ChosenHeading() const;
150 WsfPath::TurnDirection ChosenDirection() const { return mChosenDir; }
151
152 void PrintValidityMap(double aSimTime) const;
153
154 void GetWPTargetInfo(double aVelNED[3],
155 double& aPlatformHeading,
156 double& aPlatformPitch,
157 double& aPlatformRoll,
158 double& aHeadingChangeMag,
159 double& aHdgChgDirection,
160 double& aGroundSpeed,
161 double& aTotalSpeed,
162 double& aGroundDistTo);
163
164 virtual double GetRadialAccelAtPoint(const WsfWaypoint& aPoint) const;
165
166protected:
167 virtual bool BeginExtrapolation(double aSimTime);
168 virtual bool SetNewGuidance(double aSimTime);
169 virtual bool ReviseGuidance(double aSimTime);
170 virtual bool DetermineTheTurn(double aSimTime);
171
173
174 void SetAltRef(WsfPath::AltRef aMoverDefault, WsfPath::AltRef aAltRefOverride = WsfPath::cALT_REF_MSL);
175
176 bool mDebug;
178 bool mIsChanged; // flag to indicate there is new information
182 double mPauseTime; // The mover is FROZEN if this value is non-zero.
183
184 const double* TgtWCS() const { return mTgtWCS; }
185
186 void PrivateSetTurnDir(WsfPath::TurnDirection aTurnDir);
187
188 std::string PrintBool(int aMask) const;
189 void SetValid(int aSetMask);
190
191private:
192 void PrivateSetAltitude(double aValue);
193 void PrivateSetAltRef(WsfPath::AltRef aValue);
194 void PrivateSetSwitch(WsfPath::Switch aValue);
195
196 bool mExtrapNoted;
197
198 int mValidityMap; // summed bit mapped values
199
200 double mSpeed; // m/s
201 double mAxialAccel; // m/s^2
202
203 double mDistance; // Distance to extrapolate the last waypoint.
204 double mTime; // Time to extrapolate the last waypoint.
205
206 double mClimbRate; // m/s
207
208 double mAltitude; // MSL or AGL altitude, meters.
209
210 double mTurnRate; // radial turn rate (radians/sec = 1/sec)
211 double mRadialAccel; // lateral turn acceleration m/s^2
212
213 double mHeading; // Desired heading, rad (reference is implementation defined).
214
215 double mLatitude; // Waypoint Location Latitude
216 double mLongitude; // Waypoint Location Longitude
217
218 double mSegEndTime; // Time to extrapolate a heading and speed before switching.
219 double mSegEndDist; // Distance to extrapolate a heading and speed before switching.
220
221 WsfPath::AltRef mAltRef; // Reference value for specified altitude
222 WsfPath::HdgRef mHdgRef; // Specified heading is relative (implementation defined)
223 WsfPath::TurnDirection mSetTurnDir; // Specified direction to turn when changing heading
224 WsfPath::Switch mSwitch; // Instruction on when to switch waypoints
225
226 WsfMover* mMoverPtr; // The mover for whom guidance is being provided
227 WsfPath::TurnDirection mChosenDir; // Selected direction to turn when changing heading
228 double mTgtWCS[3]; // Target WCS location, which will not change between Sets().
229};
230
231#endif
aObjectPtr Update(simTime)
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfMover.hpp:37
Definition WsfPathGuidance.hpp:39
bool SegmentDistIsSet() const
Definition WsfPathGuidance.hpp:140
bool HeadingIsSet() const
Definition WsfPathGuidance.hpp:134
double GetSegmentEndDist() const
Definition WsfPathGuidance.hpp:96
bool TurnRateIsSet() const
Definition WsfPathGuidance.hpp:137
@ cSPEED
Speed value is valid.
Definition WsfPathGuidance.hpp:45
@ cCLIMB_RATE
Climb Rate value is valid.
Definition WsfPathGuidance.hpp:47
@ cALTITUDE
Altitude value is valid.
Definition WsfPathGuidance.hpp:48
@ cHEADING
Heading value is valid.
Definition WsfPathGuidance.hpp:49
@ cLAT_LON
Latitude and Longitude values are valid.
Definition WsfPathGuidance.hpp:52
@ cRADIAL_ACCEL
Radial Acceleration value is valid.
Definition WsfPathGuidance.hpp:51
@ cTURN_RATE
Turn Rate value is valid.
Definition WsfPathGuidance.hpp:50
@ cAXIAL_ACCEL
Axial Acceleration value is valid.
Definition WsfPathGuidance.hpp:46
@ cSEGMENT_DIST
Segment Distance value is valid.
Definition WsfPathGuidance.hpp:54
@ cTURN_DETERMINED
Absolute Heading value (to an LLA point) has been calculated.
Definition WsfPathGuidance.hpp:55
@ cSEGMENT_TIME
Segment Time value is valid.
Definition WsfPathGuidance.hpp:53
bool IsPaused() const
Definition WsfPathGuidance.hpp:85
double GetAxialAccel() const
Definition WsfPathGuidance.hpp:97
double GetPauseTime() const
Definition WsfPathGuidance.hpp:86
virtual bool DetermineTheTurn(double aSimTime)
Definition WsfPathGuidance.cpp:558
bool AxialAccelIsSet() const
Definition WsfPathGuidance.hpp:135
WsfPath::Switch GetSwitch() const
Definition WsfPathGuidance.hpp:104
WsfPathGuidance()
Construct a path guidance object.
Definition WsfPathGuidance.cpp:29
bool mDebug
Definition WsfPathGuidance.hpp:176
WsfMover * GetMover() const
Get the mover to whom guidance is being provided.
Definition WsfPathGuidance.hpp:67
bool SpeedIsSet() const
Definition WsfPathGuidance.hpp:131
WsfPath::TurnDirection ChosenDirection() const
Definition WsfPathGuidance.hpp:150
double GetRawHeading() const
Definition WsfPathGuidance.hpp:91
void SetHdgRef(WsfPath::HdgRef aHdgRef)
Definition WsfPathGuidance.cpp:375
WsfPath::AltRef GetAltRef() const
Definition WsfPathGuidance.hpp:101
bool IsInitialized() const
Definition WsfPathGuidance.hpp:84
bool IsSet(int aMask)
Definition WsfPathGuidance.cpp:241
const double * TgtWCS() const
Definition WsfPathGuidance.hpp:184
double GetTurnRate() const
Definition WsfPathGuidance.hpp:99
bool mIsChanged
Definition WsfPathGuidance.hpp:178
double GetRadialAccel() const
Definition WsfPathGuidance.hpp:98
bool IsExtrapolating() const
Definition WsfPathGuidance.hpp:82
void SetTurnRate(double aTurnRate)
bool mKeepLevel
Definition WsfPathGuidance.hpp:181
bool mIsOnRoad
Definition WsfPathGuidance.hpp:180
void SetSegmentEndDist(double aSegmentDist)
Definition WsfPathGuidance.cpp:394
bool IsOnGround() const
Definition WsfPathGuidance.hpp:80
bool TurnIsDetermined() const
Definition WsfPathGuidance.hpp:148
void ClearChosenDir()
Definition WsfPathGuidance.hpp:172
void GetWPTargetInfo(double aVelNED[3], double &aPlatformHeading, double &aPlatformPitch, double &aPlatformRoll, double &aHeadingChangeMag, double &aHdgChgDirection, double &aGroundSpeed, double &aTotalSpeed, double &aGroundDistTo)
WsfPath::HdgRef GetHdgRef() const
Definition WsfPathGuidance.hpp:102
bool HdgAltAndSpeedSet() const
Definition WsfPathGuidance.hpp:145
void SetMover(WsfMover *aMoverPtr)
Definition WsfPathGuidance.hpp:64
bool mInitialized
Definition WsfPathGuidance.hpp:177
bool LLA_IsSet() const
Definition WsfPathGuidance.hpp:143
double mPauseTime
Definition WsfPathGuidance.hpp:182
bool IsChanged() const
Definition WsfPathGuidance.hpp:79
virtual bool SetNewGuidance(double aSimTime)
Definition WsfPathGuidance.cpp:213
virtual double GetRadialAccelAtPoint(const WsfWaypoint &aPoint) const
Definition WsfPathGuidance.cpp:94
double GetLongitude() const
Definition WsfPathGuidance.hpp:94
void DecrementPauseTime(double aValue)
Definition WsfPathGuidance.hpp:107
double GetClimbRate() const
Definition WsfPathGuidance.hpp:92
bool IsOnRoad() const
Definition WsfPathGuidance.hpp:81
virtual bool ReviseGuidance(double aSimTime)
Definition WsfPathGuidance.cpp:229
virtual bool BeginExtrapolation(double aSimTime)
Definition WsfPathGuidance.cpp:185
WsfPath::TurnDirection GetTurnDir() const
Definition WsfPathGuidance.hpp:103
bool AltIsSet() const
Definition WsfPathGuidance.hpp:132
void SetPauseTime(double aValue)
Definition WsfPathGuidance.hpp:108
bool SegmentTimeIsSet() const
Definition WsfPathGuidance.hpp:139
double GetSegmentEndTime() const
Definition WsfPathGuidance.hpp:95
void SetTurnDir(WsfPath::TurnDirection aTurnDir)
Definition WsfPathGuidance.cpp:495
void SetSwitch(WsfPath::Switch aMoverDefault, WsfPath::Switch aWP_SwitchOverride)
Definition WsfPathGuidance.cpp:502
void SetSegmentEndTime(double aSegmentTime)
Definition WsfPathGuidance.cpp:410
bool RadialAccelIsSet() const
Definition WsfPathGuidance.hpp:138
bool mIsOnGround
Definition WsfPathGuidance.hpp:179
bool HdgAndAltSet() const
Definition WsfPathGuidance.hpp:144
bool ClimbRateIsSet() const
Definition WsfPathGuidance.hpp:136
bool IsStopping() const
Definition WsfPathGuidance.hpp:83
void ClearValid(int aClearMask)
Definition WsfPathGuidance.cpp:235
double GetLatitude() const
Definition WsfPathGuidance.hpp:93
bool LatLonIsSet() const
Definition WsfPathGuidance.hpp:133
Definition WsfWaypoint.hpp:57
HdgRef
Heading reference option.
Definition WsfPath.hpp:60
AltRef
Altitude reference option.
Definition WsfPath.hpp:52
@ cALT_REF_MSL
Altitude is referenced to MSL.
Definition WsfPath.hpp:54
TurnDirection
Turn direction for TurnToHeading and TurnToRelativeHeading.
Definition WsfPath.hpp:88
@ cTURN_DIR_SHORTEST
Turn in the direction that results in the shortest turn (DEFAULT).
Definition WsfPath.hpp:90
Switch
Option setting when to react as a WsfWaypoint is approached.
Definition WsfPath.hpp:76
@ cSWITCH_EXTERNAL
via software commands, or in script, or the path is being extrapolated.
Definition WsfPath.hpp:82
Copyrights Multiple, All Rights Reserved