WSF
WsfPointMassSixDOF_Mover.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 2020 Infoscitex, a DCS 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#ifndef WSFPOINTMASSSIXDOFMOVER_HPP
13#define WSFPOINTMASSSIXDOFMOVER_HPP
14
22#include "WsfSixDOF_Mover.hpp"
23
24namespace wsf
25{
26namespace six_dof
27{
32class WSF_SIX_DOF_EXPORT PointMassMover : public Mover
33{
34public:
36 explicit PointMassMover(const WsfScenario& aScenario);
37
38 PointMassMover& operator=(const PointMassMover& other) = delete;
39
40 WsfMover* Clone() const override;
41
42 bool ProcessInput(UtInput& aInput) override;
43
44 static int GetTypeId() { return WsfStringId::UnsafeGetNumber("WSF_POINT_MASS_SIX_DOF_MOVER"); }
45
46 // ====================================================================================================
47
48 // CommonController/autopilot control commands
49
50 // Returns the position (deg) of the speed brakes (common position)
51 double GetSpeedBrakePosition() const override;
52
53 // Returns the position (deg) of the flaps (common position)
54 double GetFlapsPosition() const override;
55
56 // Returns the position (deg) of the spoilers (common position)
57 double GetSpoilersPosition() const override;
58
59 // These functions return the normalized control surface angle
60 double GetNormalizedFlapLeft() const override { return GetFlapsPosition(); }
61 double GetNormalizedFlapRight() const override { return GetFlapsPosition(); }
62 double GetNormalizedSpoilerLeft() const override { return GetSpoilersPosition(); }
63 double GetNormalizedSpoilerRight() const override { return GetSpoilersPosition(); }
64 double GetNormalizedSpeedBrake() const override { return GetSpeedBrakePosition(); }
65
66 // These functions return true if the data for that control surface is valid
67
68 // Flaps, spoilers, and speedbrakes are always available, but may not have any associated aero data
69 bool FlapLeftValid() const override { return true; };
70 bool FlapRightValid() const override { return true; };
71 bool SpoilerLeftValid() const override { return true; };
72 bool SpoilerRightValid() const override { return true; };
73 bool SpeedBrakeValid() const override { return true; };
74
75 // Throttle is always available on a PM pilot, but may not be used
76 bool ThrottleValid() const override { return GetActivePilotObject() != nullptr; }
77
78 // ====================================================================================================
79
80 // Functions to support scripting
81
82 const char* GetScriptClassName() const override { return "WsfPointMassSixDOF_Mover"; }
83
84 // Set the flaps position in normalized values ranging from 0 when flaps are retracted
85 // to 1 when flaps are full deployed.
86 void SetFlapsPosition(double aPosition) override;
87
88 // Set the spoilers position in normalized values ranging from 0 when spoilers are retracted
89 // to 1 when spoilers are full deployed.
90 void SetSpoilersPosition(double aPosition) override;
91
92 // This returns a pointer to the test object. It should only be used in testing.
95
96 // Initialization functions
97
98 void DeriveFrom(const PointMassMover& aSrc);
99
100 // Note: PointMassSixDOF_VehicleType uses ProcessInput(), but PointMassSixDOF_Vehicle does not
101
102 // ====================================================================================================
103 // Mass properties functions
104
105 // This calculates the current mass properties, including those
106 // from subobjects and other contributors such as fuel.
107 void CalculateCurrentMassProperties() override;
108
109 // This is used to modify the weight of a vehicle without adding fuel or subobjects
110 // for testing and should only be called in testing. Additional weight is added at
111 // the existing vehicle CG.
112 void SetCurrentWeight_lbs(double aWeight_lbs);
113
114 // ====================================================================================================
115
116 // Integrator functions
117
118 // This returns the integrator.
119 const Integrator* GetIntegrator() const override;
120
121 // ====================================================================================================
122
123 size_t GetInputHandle(const std::string&) const override { return 0; }
124 bool GetBooleanInput(size_t) const override { return false; }
125 bool GetLastBooleanInput(size_t) const override { return false; }
126
127 // ====================================================================================================
128
129 // "Last" functions
130
131 // This sets the mLastSimTime_nanosec to the specified sim time in seconds. If the
132 // aIncludeSubobjects flag is true, all subobjects will also have their last time
133 // values set.
134 void SetLastSimTime(double aSimTime_sec, bool aIncludeSubobjects = false) override;
135
136 // ====================================================================================================
137
138 // Aerodynamics functions
139
140 // This function is used to calculate the lift, drag, side force, and moments
141 // using the current state. The reference point is typically (0,0,0), but
142 // may be a non-origin reference due to subobjects. This function will include
143 // aero contributions by subobjects, if appropriate.
144 void CalculateAeroBodyForceAndMoments(UtVec3dX& aLiftBodyVector_lbs,
145 UtVec3dX& aDragBodyVector_lbs,
146 UtVec3dX& aSideForceBodyVector_lbs,
147 UtVec3dX& aRotationAccelerationLimits_rps2,
148 UtVec3dX& aStabilizingFrequency_rps) override;
149
150 // This function is used to calculate the lift, drag, and side force using the
151 // current state. Because moments are not included at this level of detail,
152 // zero moments will be reported to any RB6 parent vehicles. Conversely,
153 // RB6 vehicles cannot make use of omega-dot limits. This function will
154 // include aero contributions by subobjects, if appropriate.
155 void CalculateAeroBodyForceAndRotation(UtVec3dX& aLiftBodyVector_lbs,
156 UtVec3dX& aDragBodyVector_lbs,
157 UtVec3dX& aSideForceBodyVector_lbs,
158 UtVec3dX& aMoment_ftlbs,
159 UtVec3dX& aReferencePt_ft) override;
160
161 // This uses CalculatePitchGLoadAtSpecifiedAlpha internally to calculate the
162 // angle of attack (alpha) at the specified g-load using the current conditions.
163 // If it cannot attain the specified g-load, it will return the *best* alpha.
164 void CalculateAlphaAtSpecifiedGLoad_deg(double aGLoad, double& aAlpha_deg) const override;
165
166 // This calculates the angle of sideslip (beta) at the specified g-load using the
167 // current conditions. If it cannot attain the specified g-load, it will return
168 // the *best* beta.
169 void CalculateBetaAtSpecifiedGLoad_deg(double aGLoad, double& aBeta_deg) const override;
170
171 // This sets the active aero object using the pointer
172 void SetActiveAeroObject(PointMassAeroCoreObject* aObject);
173
174 // This sets the active aero object using the name
175 void SetActiveAeroObject(const std::string& aName) override;
176
177 // This returns a pointer to the active aero object
179
180 // This returns the name of the active aero object
181 std::string GetActiveAeroObjectName() const
182 {
183 return GetActiveAeroObject() ? GetActiveAeroObject()->GetModeName() : "";
184 }
185
186 // This returns the ref area (sq-ft) for the current aero mode
187 double GetRefArea_sqft() const;
188
189 // This returns the current center of gravity in feet from the reference point
190 UtVec3dX GetCenterOfGravity_ft() const override { return mMassProperties.GetCmPosRelToRef_ft(); }
191
192 // This uses the current state to calculate the maximum g-load maneuverability
193 // based on the current mass, altitude, speed/mach and CLmax
194 double MaxPotentialManeuverGLoad() const override;
195
196 // This returns the fixed-aero object or null if none exists
198
199 // ====================================================================================================
200
201 // Subobject functions
202
203 // PropulsionSystem functions
204
205 // This calculates F&M for the full propulsion system (all engines) plus
206 // the thrust from any subobjects
207 void CalculatePropulsionFM(int64_t aSimTime_nanosec,
208 double aDeltaT_sec,
209 const KinematicState& aState,
210 UtVec3dX& aInertialPropulsionVector_lbs,
211 UtVec3dX& aMaximumRotationAcceleration_rps2);
212
213 // This returns the propulsion system or null if no propulsion system exists
215
216 // This returns the propulsion system or null if no propulsion system exists
218
219 // This provides the maximum potential thrust available, if full throttle, including
220 // afterburner (if available), is applied
221 double GetMaximumPotentialThrust_lbs() const override;
222
223 // This provides the minimum potential thrust available
224 double GetMinimumPotentialThrust_lbs() const override;
225
226 // This provides the current thrust magnitude produced by engines on the vehicle.
227 // It includes thrust from any first-level/immediate subobjects
228 double GetCurrentThrust_lbs() override;
229
230 // This provides the current forward thrust produced by engines on the vehicle.
231 // It includes thrust from any first-level/immediate subobjects
232 double GetCurrentForwardThrust_lbs() override;
233
234 // This returns the total fuel flow (lbs/hr) for all engines on the vehicle
235 double GetTotalVehicleFuelFlow_pph() const override;
236
237 // This returns the total fuel flow (lbs/hr) for the main engines on the vehicle.
238 // It does not include any subobjects.
239 double GetTotalFuelFlow_pph() const override;
240
241 // ====================================================================================================
242
243 // PilotObject and FlightControls functions
244
245 // This returns the pilot manager object. Null is returned when
246 // no pilot manager is present.
247 PilotManager* GetPilotManager() const override { return mPilotManagerPtr; }
249
250 // This returns the flight controls object. Null is returned when
251 // no flight controls are present.
253
254 // This returns true if the object includes flaps control surfaces
255 bool HasFlaps() const;
256
257 // These functions return the normalized control input (lever) value
258 double GetStickRightInput() const override;
259 double GetStickBackInput() const override;
260 double GetRudderRightInput() const override;
261 double GetThrottleInput() const override;
262 double GetSpeedBrakeInput() const override;
263 double GetSpoilerInput() const override;
264 double GetLandingGearInput() const override;
265
266 // ====================================================================================================
267
268 // Testing functions
269
270 // This sets kinematic state parameters to a zero condition for testing
271 void ZeroKinematicsDuringTesting() override;
272
273protected:
274 explicit PointMassMover(const PointMassMover& aSrc);
275
276 // This is used by all Initialize functions to complete "details"
277 bool InitializeDetails(double aSimTime_sec) override;
278
279 // Update functions
280 void UpdateFlightControls(int64_t aSimTime_nanosec) override;
281
282 void CalculateThrustVectorAndMomentUpdatePropulsion(double aSimTime_sec,
283 double aDeltaTime_sec,
284 const KinematicState& aState,
285 ForceAndRotationObject& aForceAndMoment);
286
287 void UpdatePropulsionFuelBurn(double aSimTime_sec, double aDeltaTime_sec, const KinematicState& aState) override;
288
289 void CalculateObjectPropulsion(double aSimTime_sec,
290 double aDeltaT_sec,
291 double aAlt_ft,
292 double aDynPress_lbsqft,
293 double aStatPress_lbssqft,
294 double aSpeed_fps,
295 double aMach,
296 double aAlpha_rad,
297 double aBeta_rad,
298 ForceAndRotationObject& aForceAndMoment,
299 double& aFuelBurnRate_pps,
300 double& aFuelBurned_lbs) override;
301
302 void CalculateObjectPropulsion(double aSimTime_sec,
303 double aDeltaT_sec,
304 double aAlt_ft,
305 double aDynPress_lbsqft,
306 double aStatPress_lbssqft,
307 double aSpeed_fps,
308 double aMach,
309 double aAlpha_rad,
310 double aBeta_rad,
311 ForceAndMomentsObject& aForceAndMoment,
312 double& aFuelBurnRate_pps,
313 double& aFuelBurned_lbs) override;
314
315 void UpdateObjectPropulsion(double aSimTime_sec,
316 double aDeltaT_sec,
317 double aAlt_ft,
318 double aDynPress_lbsqft,
319 double aStatPress_lbssqft,
320 double aSpeed_fps,
321 double aMach,
322 double aAlpha_rad,
323 double aBeta_rad,
324 ForceAndRotationObject& aForceAndMoment,
325 double& aFuelBurnRate_pps,
326 double& aFuelBurned_lbs);
327
328 void ObjectPropulsionCalculations(double aSimTime_sec,
329 double aDeltaT_sec,
330 double aAlt_ft,
331 double aDynPress_lbsqft,
332 double aStatPress_lbssqft,
333 double aSpeed_fps,
334 double aMach,
335 double aAlpha_rad,
336 double aBeta_rad,
337 ForceAndRotationObject& aForceAndMoment,
338 double& aFuelBurnRate_pps,
339 double& aFuelBurned_lbs,
340 bool aUpdateData);
341
342 void CalcTotalFuelFlowAndQuantity(double& aCurrentTotalFuelFlow_pph,
343 double& aCurrentTotalFuel_lbs,
344 double& aMaxTotalFuel_lbs) override;
345
346 // ====================================================================================================
347
348 std::unique_ptr<PointMassMoverTestObject> mTestSupportObjectPtr{nullptr};
349
350 ut::CloneablePtr<PointMassAeroCoreObject> mAeroCoreObjPtr{nullptr};
352
353 ut::CloneablePtr<PointMassPropulsionSystem> mPropulsionObjPtr{nullptr};
354
355 ut::CloneablePtr<PointMassIntegrator> mIntegratorPtr{nullptr};
356
357 ut::CloneablePtr<PointMassFlightControlSystem> mFlightControlsPtr{nullptr};
358 ut::CloneablePtr<PointMassPilotManager> mPilotManagerPtr{nullptr};
359};
360} // namespace six_dof
361} // namespace wsf
362
363
364#endif
WsfMover()=delete
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfSixDOF_AeroCoreObject.hpp:35
Definition WsfSixDOF_ForceAndMomentsObject.hpp:28
Definition WsfSixDOF_ForceAndRotationObject.hpp:30
Definition WsfSixDOF_Integrator.hpp:31
Definition WsfSixDOF_KinematicState.hpp:34
Definition WsfSixDOF_MoverTestObject.hpp:33
Mover(const WsfScenario &aScenario)
Constructor.
Definition WsfSixDOF_Mover.cpp:63
MassProperties mMassProperties
Definition WsfSixDOF_Mover.hpp:1823
PilotObject * GetActivePilotObject() const
Definition WsfSixDOF_Mover.cpp:1221
Definition WsfSixDOF_PilotManager.hpp:34
Definition WsfPointMassSixDOF_AeroCoreObject.hpp:28
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:44
Definition WsfPointMassSixDOF_MoverTestObject.hpp:23
Definition WsfPointMassSixDOF_Mover.hpp:33
bool FlapRightValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:70
double GetNormalizedSpoilerRight() const override
Definition WsfPointMassSixDOF_Mover.hpp:63
bool FlapLeftValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:69
double GetNormalizedSpoilerLeft() const override
Definition WsfPointMassSixDOF_Mover.hpp:62
double GetNormalizedFlapRight() const override
Definition WsfPointMassSixDOF_Mover.hpp:61
bool GetLastBooleanInput(size_t) const override
Definition WsfPointMassSixDOF_Mover.hpp:125
PointMassFlightControlSystem * GetFlightControls() const
Definition WsfPointMassSixDOF_Mover.hpp:252
MoverTestObject * GetTestSupportObject() const override
Definition WsfPointMassSixDOF_Mover.hpp:94
PointMassPropulsionSystem * GetPointMassPropulsionSystem()
Definition WsfPointMassSixDOF_Mover.hpp:217
double GetNormalizedSpeedBrake() const override
Definition WsfPointMassSixDOF_Mover.hpp:64
const char * GetScriptClassName() const override
Definition WsfPointMassSixDOF_Mover.hpp:82
ut::CloneablePtr< PointMassIntegrator > mIntegratorPtr
Definition WsfPointMassSixDOF_Mover.hpp:355
std::string GetActiveAeroObjectName() const
Definition WsfPointMassSixDOF_Mover.hpp:181
bool SpeedBrakeValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:73
PointMassMoverTestObject * GetPointMassTestSupportObject() const
Definition WsfPointMassSixDOF_Mover.hpp:93
double GetSpoilersPosition() const override
Definition WsfPointMassSixDOF_Mover.cpp:1483
PointMassAeroCoreObject * mActiveAeroObjPtr
Definition WsfPointMassSixDOF_Mover.hpp:351
double GetFlapsPosition() const override
Definition WsfPointMassSixDOF_Mover.cpp:1478
AeroCoreObject * GetAeroCoreObject() const override
Definition WsfPointMassSixDOF_Mover.hpp:197
bool GetBooleanInput(size_t) const override
Definition WsfPointMassSixDOF_Mover.hpp:124
PilotManager * GetPilotManager() const override
Definition WsfPointMassSixDOF_Mover.hpp:247
double GetNormalizedFlapLeft() const override
Definition WsfPointMassSixDOF_Mover.hpp:60
double GetSpeedBrakePosition() const override
Definition WsfPointMassSixDOF_Mover.cpp:1473
std::unique_ptr< PointMassMoverTestObject > mTestSupportObjectPtr
Definition WsfPointMassSixDOF_Mover.hpp:348
bool ProcessInput(UtInput &aInput) override
Definition WsfPointMassSixDOF_Mover.cpp:113
static int GetTypeId()
Definition WsfPointMassSixDOF_Mover.hpp:44
PointMassMover & operator=(const PointMassMover &other)=delete
ut::CloneablePtr< PointMassPropulsionSystem > mPropulsionObjPtr
Definition WsfPointMassSixDOF_Mover.hpp:353
ut::CloneablePtr< PointMassAeroCoreObject > mAeroCoreObjPtr
Definition WsfPointMassSixDOF_Mover.hpp:350
size_t GetInputHandle(const std::string &) const override
Definition WsfPointMassSixDOF_Mover.hpp:123
bool SpoilerRightValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:72
bool SpoilerLeftValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:71
ut::CloneablePtr< PointMassPilotManager > mPilotManagerPtr
Definition WsfPointMassSixDOF_Mover.hpp:358
UtVec3dX GetCenterOfGravity_ft() const override
Definition WsfPointMassSixDOF_Mover.hpp:190
bool ThrottleValid() const override
Definition WsfPointMassSixDOF_Mover.hpp:76
PointMassMover(const WsfScenario &aScenario)
Constructor.
Definition WsfPointMassSixDOF_Mover.cpp:63
ut::CloneablePtr< PointMassFlightControlSystem > mFlightControlsPtr
Definition WsfPointMassSixDOF_Mover.hpp:357
PointMassAeroCoreObject * GetActiveAeroObject() const
Definition WsfPointMassSixDOF_Mover.hpp:178
WsfMover * Clone() const override
Definition WsfPointMassSixDOF_Mover.cpp:107
PropulsionSystem * GetPropulsionSystem() const override
Definition WsfPointMassSixDOF_Mover.hpp:214
PointMassPilotManager * GetPointMassPilotManager() const
Definition WsfPointMassSixDOF_Mover.hpp:248
Definition WsfPointMassSixDOF_PilotManager.hpp:31
Definition WsfPointMassSixDOF_PropulsionSystem.hpp:26
Definition WsfSixDOF_PropulsionSystem.hpp:35
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved