WSF
WsfPointMassSixDOF_FlightControlSystem.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 WSFPOINTMASSSIXDOFFLIGHTCONTROLSYSTEM_HPP
13#define WSFPOINTMASSSIXDOFFLIGHTCONTROLSYSTEM_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <cinttypes>
18#include <string>
19#include <vector>
20
21#include "UtCloneablePtr.hpp"
22#include "UtTable.hpp"
26#include "WsfSixDOF_Object.hpp"
27
28namespace wsf
29{
30namespace six_dof
31{
34
35// The PointMassFlightControlSystem class provides a means to transform control inputs into
36// control surface movement. PointMassFlightControlSystem connects to a PointMassSixDOF_PilotController
37// to get control inputs. It offers functions for PointMassSixDOF_Objects to get control surface
38// positions. Control surfaces include typical aerodynamic control surfaces but can
39// also include unconventional control surfaces as well as other components (such as
40// landing gear) that can produce forces and moments that are a function of extended
41// position of the component.
42
43class WSF_SIX_DOF_EXPORT PointMassFlightControlSystem : public Object
44{
45public:
47
49
51
52 // ProcessInput reads initialization data
53 bool ProcessInput(UtInput& aInput);
54
55 bool Initialize(int64_t aSimTime_nanosec);
56
57 void Update(int64_t aSimTime_nanosec);
58
59 void SetLastUpdateSimTime(int64_t aLastUpdateSimTime_nanosec)
60 {
61 mLastUpdateSimTime_nanosec = aLastUpdateSimTime_nanosec;
62 }
63
64 // This sets the pilot manager so the flight controls can get the active pilot object
65 void SetPilotManager(PointMassPilotManager* aPointMassSixDOF_PilotManager);
66
67 // This sets the pilot object, allowing the flight controls to get control inputs
68 void SetPilotObject(PointMassPilotObject* aPointMassSixDOF_PilotObject);
69
70 // .....................................................................................................
71
72 const double* GetThrottleMilPtr() const { return &mThrottleMil; }
73 const double* GetThrottleAbPtr() const { return &mThrottleAb; }
74
76 {
77 if (mStickRightCurvePtr != nullptr)
78 {
79 return mStickRightCurvePtr->Lookup(mStickRight);
80 }
81
82 return 0.0;
83 }
84
86 {
87 if (mStickBackCurvePtr != nullptr)
88 {
89 return mStickBackCurvePtr->Lookup(mStickBack);
90 }
91
92 return 0.0;
93 }
94
96 {
97 if (mRudderRightCurvePtr != nullptr)
98 {
99 return mRudderRightCurvePtr->Lookup(mRudderRight);
100 }
101
102 return 0.0;
103 }
104
109
110 double GetFlapsPosition() { return mFlaps.GetCurrentSetting(); }
111
112 double GetSpoilersPosition() { return mSpoilers.GetCurrentSetting(); }
113
114 double GetSpeedbrakesPosition() { return mSpeedbrakes.GetCurrentSetting(); }
115
116 // .....................................................................................................
117
118 double FindStickBackForPitchCommand(double aPitchRate_rps)
119 {
120 return FindControlPositionForRotationCommand(aPitchRate_rps, *mStickBackCurvePtr);
121 }
122
123 double FindStickRightForRollCommand(double aRollRate_rps)
124 {
125 return FindControlPositionForRotationCommand(aRollRate_rps, *mStickRightCurvePtr);
126 }
127
128 double FindRudderRightForYawCommand(double aYawRate_rps)
129 {
130 return FindControlPositionForRotationCommand(aYawRate_rps, *mRudderRightCurvePtr);
131 }
132
133protected:
135
136private:
137 double LinearInterpolation(double aX, double aX0, double aX1, double aY0, double aY1)
138 {
139 return aY0 + (aX - aX0) * (aY1 - aY0) / (aX1 - aX0);
140 }
141
142 double FindControlPositionForRotationCommand(double aOmegaCommand, UtTable::Curve aControlCurve);
143
144 PointMassPilotObject* mPointMassSixDOF_PilotObjectPtr = nullptr;
145 PointMassPilotManager* mPointMassSixDOF_PilotManager = nullptr;
146
147 int64_t mLastUpdateSimTime_nanosec = 0;
148
149 UtCloneablePtr<UtTable::Curve> mStickBackCurvePtr{
150 nullptr}; // Mapping between stick-back position and pitch rate command (deg/s)
151 UtCloneablePtr<UtTable::Curve> mStickRightCurvePtr{
152 nullptr}; // Mapping between stick-right position and roll rate command (deg/s)
153 UtCloneablePtr<UtTable::Curve> mRudderRightCurvePtr{
154 nullptr}; // Mapping between rudder-right position and yaw rate command (deg/s)
155
156 double mStickBack = 0.0;
157 double mStickRight = 0.0;
158 double mRudderRight = 0.0;
159 double mThrottleMil = 0.0;
160 double mThrottleAb = 0.0;
161
162 PointMassControlActuator mFlaps = PointMassControlActuator(this);
163 PointMassControlActuator mSpeedbrakes = PointMassControlActuator(this);
164 PointMassControlActuator mSpoilers = PointMassControlActuator(this);
165};
166} // namespace six_dof
167} // namespace wsf
168
169#endif
aObjectPtr Update(simTime)
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:44
double FindRudderRightForYawCommand(double aYawRate_rps)
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:128
bool Initialize(int64_t aSimTime_nanosec)
Definition WsfPointMassSixDOF_FlightControlSystem.cpp:179
double GetSpoilersPosition()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:112
double GetPitchRateCommand_dps()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:85
const double * GetThrottleAbPtr() const
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:73
double FindStickBackForPitchCommand(double aPitchRate_rps)
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:118
double GetRollRateCommand_dps()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:75
double FindStickRightForRollCommand(double aRollRate_rps)
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:123
PointMassFlightControlSystem * Clone() const
Definition WsfPointMassSixDOF_FlightControlSystem.cpp:101
double GetSpeedbrakesPosition()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:114
bool ProcessInput(UtInput &aInput)
Definition WsfPointMassSixDOF_FlightControlSystem.cpp:106
double GetFlapsPosition()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:110
UtVec3dX GetBodyRateCommands_dps()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:105
double GetYawRateCommand_dps()
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:95
PointMassFlightControlSystem & operator=(const PointMassFlightControlSystem &other)=delete
void SetLastUpdateSimTime(int64_t aLastUpdateSimTime_nanosec)
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:59
const double * GetThrottleMilPtr() const
Definition WsfPointMassSixDOF_FlightControlSystem.hpp:72
Definition WsfPointMassSixDOF_PilotManager.hpp:31
Definition WsfPointMassSixDOF_PilotObject.hpp:25
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