WSF
WsfRigidBodySixDOF_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 WSFRIGIDBODYSIXDOFFLIGHTCONTROLSYSTEM_HPP
13#define WSFRIGIDBODYSIXDOFFLIGHTCONTROLSYSTEM_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <cinttypes>
18#include <string>
19#include <vector>
20
21#include "UtCloneablePtr.hpp"
22class UtInput;
23#include "UtTable.hpp"
26#include "WsfSixDOF_Object.hpp"
27
28namespace wsf
29{
30namespace six_dof
31{
34
35// The RigidBodyFlightControlSystem class provides a means to transform control inputs into
36// control surface movement. RigidBodyFlightControlSystem connects to a RigidBodySixDOF_PilotController
37// to get control inputs. It offers functions for RigidBodySixDOF_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 RigidBodyFlightControlSystem : public Object
44{
45public:
48
50
52
54
55 // ProcessInput reads initialization data
56 bool ProcessInput(UtInput& aInput);
57 bool Initialize(int64_t aSimTime_nanosec);
58
59 void Update(int64_t aSimTime_nanosec);
60
61 void SetLastUpdateSimTime(int64_t aLastUpdateSimTime_nanosec)
62 {
63 mLastUpdateSimTime_nanosec = aLastUpdateSimTime_nanosec;
64 }
65
66 // This sets the pilot manager so the flight controls can get the active pilot object
67 void SetPilotManager(RigidBodyPilotManager* aRigidBodySixDOF_PilotManager);
68
69 // This sets the pilot object, allowing the flight controls to get control inputs
70 void SetPilotObject(RigidBodyPilotObject* aRigidBodySixDOF_PilotObject);
71
72 // ......................................................................................
73
74 // This returns a 'handle' to a control surface. If there is no control surface
75 // with the specified name, the function returns 0;
76 size_t GetControlSurfaceHandle(const std::string& aControlSurfaceName) const;
77
78 // This returns a 'handle' to the first control surface that contains the
79 // specified string. If there is no control surface that contains the name,
80 // the function returns 0;
81 size_t GetControlSurfaceHandleContainingString(const std::string& aString) const;
82
83 // This returns a 'handle' to the first control surface that contains the
84 // two specified strings. If there is no control surface that contains the names,
85 // the function returns 0;
86 size_t GetControlSurfaceHandleContainingTwoStrings(const std::string& aString1, const std::string& aString2) const;
87
88 // This returns the name of the control surface, given its handle
89 std::string GetControlSurfaceName(size_t aControlSurfaceHandle) const;
90
91 // This returns the angle of the control surface in degrees, given its handle
92 double GetControlSurfaceAngle_deg(size_t aControlSurfaceHandle) const;
93
94 // This returns the max angle of the control surface in degrees, given its handle
95 double GetControlSurfaceMinAngle_deg(size_t aControlSurfaceHandle) const;
96
97 // This returns the max angle of the control surface in degrees, given its handle
98 double GetControlSurfaceMaxAngle_deg(size_t aControlSurfaceHandle) const;
99
100 // This returns the normalized angle of the control surface, given its handle
101 double GetControlSurfaceValueNormalized(size_t aControlSurfaceHandle) const;
102
103 // This sets the angle of the control surface in degrees, given its handle.
104 // Note that this should only be used for initialization, to set the position
105 // to a desired angle. This will also set the actuator position.
106 void SetControlSurfaceAngle_deg(size_t aControlSurfaceHandle, double aAngle_deg);
107
108 // ......................................................................................
109
110 // This returns a 'handle' to a control output value. If there is no control value
111 // with the specified name, the function returns 0;
112 size_t GetControlValueHandle(const std::string& aControlValueName) const;
113
114 // This returns the name of the control value, given its handle
115 std::string GetControlValueName(size_t aControlValueHandle) const;
116
117 // This returns the value of the control value, given its handle
118 double GetControlValue(size_t aControlValueHandle) const;
119
120 // ......................................................................................
121
122 // This returns a 'handle' to a boolean control. If there is no boolean control
123 // with the specified name, the function returns 0;
124 size_t GetBooleanControlHandle(const std::string& aControlBooleanName) const;
125
126 // This returns the name of the boolean control, given its handle
127 std::string GetBooleanControlName(size_t aControlBooleanHandle) const;
128
129 // This returns the value of the boolean control, given its handle
130 bool GetControlBoolean(size_t aControlBooleanHandle) const;
131
132 // This returns the last value of the boolean control, given its handle
133 bool GetControlBooleanLastValue(size_t aControlBooleanHandle) const;
134
135 // ......................................................................................
136
137 // This clears all control data
138 void ClearAllControlData();
139
140 // This returns the number of flight control inputs
141 size_t NumFlightControlInputs() const;
142
143 // This loads data for the specified control input
144 void LoadFlightControlInputData(size_t aIndex, FlightControlInputValue* aData) const;
145
146 // This returns the number of flight control surfaces
147 size_t NumFlightControlSurfaces() const;
148
149 // This loads data for the specified control surface
150 void LoadFlightControlSurfaceData(size_t aIndex, ControlSurfaceValue* aData) const;
151
152 // .....................................................................................................
153
155 {
156 std::string name;
157 size_t handle = 0;
158 double normalizedValue = 0;
160 bool boolData = false;
161 };
162
189
191 {
192 std::string name;
194 UtCloneablePtr<UtTable::Table> table{nullptr};
195 UtCloneablePtr<UtTable::Curve> curve{nullptr};
196 double scalarGain = 1.0;
197 double minClamp = -1.0;
198 double maxClamp = 1.0;
199 };
200
202 {
203 std::string controlInputName;
204 ControlInputValue* controlInput = nullptr; // This is owned externally
205 std::vector<std::string> modifierNameList;
206 std::vector<ControlSignalModifier*> modifierList; // These are owned externally
207 };
208
209 // This contains data for a single control surface, including a list
210 // of control inputs and modifiers as well as the angle mapping and actuator
212 {
214 std::vector<std::unique_ptr<ControlInputGainStream>> controlInputList;
215 UtCloneablePtr<UtTable::Curve> angleMappingAuto{nullptr};
216 UtCloneablePtr<UtTable::Curve> angleMappingManual{nullptr};
217 UtCloneablePtr<RigidBodyControlActuator> actuator{nullptr};
218 double currentAngle_deg = 0.0;
219 double minAngle_deg = 0.0;
220 double maxAngle_deg = 0.0;
221 };
222
223 // This contains data for a single control output, including a list
224 // of control inputs and modifiers
226 {
227 std::string controlValueName;
228 std::vector<std::unique_ptr<ControlInputGainStream>> controlInputList;
229 double currentValue = 0.0;
230 double minValue = 0.0;
231 double maxValue = 0.0;
232 };
233
234 // This contains data for a single boolean output, including a list
235 // of control inputs and modifiers
237 {
238 std::string controlValueName;
239 std::vector<std::unique_ptr<ControlInputGainStream>> controlInputList;
240 double thresholdValue = 0.0;
241 bool currentValue = false;
242 bool lastValue = false;
243 };
244
245 // .....................................................................................................
246
247 // This provides a list/vector of control surfaces that use the specified input handle
248 // If there are none, it returns false.
249 bool GetControlSurfacesUsingInput(std::vector<ControlSurfaceElement*>& list, unsigned int aInputHandle);
250
251 // This provides a list/vector of control surface names. If there are none, it returns an empty vector.
252 void GetControlSurfaceNames(std::vector<std::string>& list);
253
254 // This provides a vector of the current control surface angles and actuator angles. It is used with
255 // the SetAllControlSurfaceAndActuatorsAngles function to get/save angles and later reset the angles.
256 void GetAllControlSurfaceAndActuatorsAngles(std::vector<double>& aControlSurfaceAngles_deg,
257 std::vector<double>& aActuatorAngles_deg) const;
258
259 // This uses vectors of the current control surface angles and actuator angles obtained
260 // from the function GetAllControlSurfaceAndActuatorsAngles function to set the angles.
261 void SetAllControlSurfaceAndActuatorsAngles(const std::vector<double>& aControlSurfaceAngles_deg,
262 const std::vector<double>& aActuatorAngles_deg);
263
264 // This sets the control surface positions based on the control inputs
265 void SetControlSurfacesBasedOnControlInputs(int64_t aSimTime_nanosec);
266
267 // This sets the control values based on the control inputs
269
270 // This sets the control booleans based on the control inputs
272
273 // .....................................................................................................
274
275protected:
277
278 // This processes file input for signal modifiers
279 bool ProcessSignalModifierTable(UtInput& aInput);
280
281 // This processes file input for control surfaces
282 bool ProcessControlSurfaceInput(UtInput& aInput);
283
284 // This processes file input for control values
285 bool ProcessControlValueInput(UtInput& aInput);
286
287 // This processes file input for control booleans
288 bool ProcessControlBooleanInput(UtInput& aInput);
289
290 bool ProcessInputSet(UtInput& aInput, ControlSurfaceElement* aActiveControlSurfaceElement);
291 bool ProcessInputSet(UtInput& aInput, ControlValueElement* aActiveControlValueElement);
292 bool ProcessInputSet(UtInput& aInput, ControlBooleanElement* aActiveControlBooleanElement);
293
294 bool ProcessControlInputs(UtInput& aInput, ControlSurfaceElement* aActiveControlSurfaceElement);
295 bool ProcessControlInputs(UtInput& aInput, ControlValueElement* aActiveControlValueElement);
296 bool ProcessControlInputs(UtInput& aInput, ControlBooleanElement* aActiveControlBooleanElement);
297
298 // This adds the control surface to the list if the name is unique.
299 // If it cannot add it to the list, it returns false, else it returns true
300 bool AddControlSurfaceToList(std::unique_ptr<ControlSurfaceElement> aControlSurface);
301
302 // This adds the control value to the list if the name is unique.
303 // If it cannot add it to the list, it returns false, else it returns true
304 bool AddControlValueToList(std::unique_ptr<ControlValueElement> aControlValue);
305
306 // This adds the control boolean to the list if the name is unique.
307 // If it cannot add it to the list, it returns false, else it returns true
308 bool AddControlBooleanToList(std::unique_ptr<ControlBooleanElement> aControlBoolean);
309
310 ControlInputValue* GetControlInputByName(const std::string& aControlInputName) const;
311 ControlSignalModifier* GetControlSignalModifierByName(const std::string& aSignalModifierName) const;
312
314
317
318 std::vector<std::unique_ptr<ControlInputValue>> mControlInputList;
319 std::vector<std::unique_ptr<ControlSignalModifier>> mControlSignalModifiersList;
320 std::vector<std::unique_ptr<ControlSurfaceElement>> mControlSurfaceList;
321 std::vector<std::unique_ptr<ControlValueElement>> mControlValueList;
322 std::vector<std::unique_ptr<ControlBooleanElement>> mControlBooleanList;
323};
324} // namespace six_dof
325} // namespace wsf
326
327#endif
aObjectPtr Update(simTime)
bool AddControlBooleanToList(std::unique_ptr< ControlBooleanElement > aControlBoolean)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:2014
std::vector< std::unique_ptr< ControlSurfaceElement > > mControlSurfaceList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:320
ControlInputValue * GetControlInputByName(const std::string &aControlInputName) const
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:331
std::vector< std::unique_ptr< ControlInputValue > > mControlInputList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:318
void SetControlValuesBasedOnControlInputs()
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1500
bool AddControlSurfaceToList(std::unique_ptr< ControlSurfaceElement > aControlSurface)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1980
bool ProcessInput(UtInput &aInput)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:357
bool GetControlSurfacesUsingInput(std::vector< ControlSurfaceElement * > &list, unsigned int aInputHandle)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1286
RigidBodyFlightControlSystem & operator=(const RigidBodyFlightControlSystem &other)=delete
void SetAllControlSurfaceAndActuatorsAngles(const std::vector< double > &aControlSurfaceAngles_deg, const std::vector< double > &aActuatorAngles_deg)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1337
ControlSignalModifierType
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:164
@ AltGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:176
@ QGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:177
@ SASChannel
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:168
@ SignalMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:187
@ ScalarGain
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:166
@ Undefined
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:165
@ MachGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:169
@ GyLoadMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:183
@ AlphaGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:171
@ GzLoadMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:184
@ GyLoadGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:174
@ QMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:186
@ BetaGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:172
@ MachMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:178
@ AlphaMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:180
@ ClampGain
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:167
@ GzLoadGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:175
@ KTASGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:170
@ GxLoadMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:182
@ BetaMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:181
@ AltMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:185
@ KTASMappingTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:179
@ GxLoadGainTable
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:173
void SetControlSurfacesBasedOnControlInputs(int64_t aSimTime_nanosec)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1378
void SetControlBooleansBasedOnControlInputs()
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1599
void ConnectInputsWithOutputs()
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:152
bool Initialize(int64_t aSimTime_nanosec)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1268
bool ProcessInputSet(UtInput &aInput, ControlSurfaceElement *aActiveControlSurfaceElement)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1034
bool ProcessControlValueInput(UtInput &aInput)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:883
RigidBodyPilotObject * mRigidBodySixDOF_PilotObjectPtr
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:315
void GetControlSurfaceNames(std::vector< std::string > &list)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1310
void SetLastUpdateSimTime(int64_t aLastUpdateSimTime_nanosec)
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:61
ControlSignalModifier * GetControlSignalModifierByName(const std::string &aSignalModifierName) const
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:345
bool ProcessControlInputs(UtInput &aInput, ControlSurfaceElement *aActiveControlSurfaceElement)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1118
int64_t mLastUpdateSimTime_nanosec
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:313
std::vector< std::unique_ptr< ControlValueElement > > mControlValueList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:321
std::vector< std::unique_ptr< ControlSignalModifier > > mControlSignalModifiersList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:319
bool ProcessSignalModifierTable(UtInput &aInput)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:415
std::vector< std::unique_ptr< ControlBooleanElement > > mControlBooleanList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:322
bool ProcessControlBooleanInput(UtInput &aInput)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:970
void GetAllControlSurfaceAndActuatorsAngles(std::vector< double > &aControlSurfaceAngles_deg, std::vector< double > &aActuatorAngles_deg) const
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1320
bool ProcessControlSurfaceInput(UtInput &aInput)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:732
bool AddControlValueToList(std::unique_ptr< ControlValueElement > aControlValue)
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:1997
RigidBodyPilotManager * mRigidBodySixDOF_PilotManager
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:316
RigidBodyFlightControlSystem * Clone() const
Definition WsfRigidBodySixDOF_FlightControlSystem.cpp:147
Definition WsfRigidBodySixDOF_PilotManager.hpp:31
Definition WsfRigidBodySixDOF_PilotObject.hpp:25
Simple
Definition WsfSixDOF_VehicleData.hpp:28
@ Float
Definition WsfSixDOF_VehicleData.hpp:29
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Definition WsfRigidBodySixDOF_VehicleData.hpp:23
Definition WsfRigidBodySixDOF_VehicleData.hpp:31
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:237
double thresholdValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:240
std::vector< std::unique_ptr< ControlInputGainStream > > controlInputList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:239
std::string controlValueName
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:238
bool currentValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:241
bool lastValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:242
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:202
std::vector< std::string > modifierNameList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:205
std::string controlInputName
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:203
ControlInputValue * controlInput
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:204
std::vector< ControlSignalModifier * > modifierList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:206
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:155
double normalizedValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:158
bool boolData
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:160
DataType::Simple typeData
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:159
size_t handle
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:157
std::string name
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:156
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:191
std::string name
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:192
double scalarGain
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:196
ControlSignalModifierType type
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:193
UtCloneablePtr< UtTable::Curve > curve
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:195
UtCloneablePtr< UtTable::Table > table
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:194
double maxClamp
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:198
double minClamp
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:197
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:212
UtCloneablePtr< UtTable::Curve > angleMappingAuto
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:215
UtCloneablePtr< RigidBodyControlActuator > actuator
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:217
double currentAngle_deg
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:218
double maxAngle_deg
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:220
UtCloneablePtr< UtTable::Curve > angleMappingManual
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:216
std::string controlSurfaceName
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:213
std::vector< std::unique_ptr< ControlInputGainStream > > controlInputList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:214
double minAngle_deg
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:219
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:226
std::string controlValueName
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:227
double currentValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:229
double minValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:230
std::vector< std::unique_ptr< ControlInputGainStream > > controlInputList
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:228
double maxValue
Definition WsfRigidBodySixDOF_FlightControlSystem.hpp:231
Copyrights Multiple, All Rights Reserved