WSF
P6DofFlightControlSystem.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#ifndef P6DOFFLIGHTCONTROLSYSTEM_H
13#define P6DOFFLIGHTCONTROLSYSTEM_H
14
15#include "p6dof_export.h"
16
17#include <cinttypes>
18#include <string>
19#include <vector>
20
23#include "P6DofObject.hpp"
24#include "P6DofVehicleData.hpp"
25#include "UtCloneablePtr.hpp"
26#include "UtTable.hpp"
27
30class P6DofVehicle;
31class UtInput;
32
33// The P6DofFlightControlSystem class provides a means to transform control inputs into
34// control surface movement. P6DofFlightControlSystem connects to a P6DofPilotController
35// to get control inputs. It offers functions for P6DofObjects to get control surface
36// positions. Control surfaces include typical aerodynamic control surfaces but can
37// also include unconventional control surfaces as well as other components (such as
38// landing gear) that can produce forces and moments that are a function of extended
39// position of the component.
40
41class P6DOF_EXPORT P6DofFlightControlSystem : public P6DofObject
42{
43public:
44 explicit P6DofFlightControlSystem(P6DofScenario* aScenario);
46
48
50
52
53 // ProcessInput reads initialization data
54 bool ProcessInput(UtInput& aInput);
55 bool Initialize(int64_t aSimTime_nanosec);
56
57 void Update(int64_t aSimTime_nanosec, P6DofKinematicState& aState);
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(P6DofPilotManager* aP6DofPilotManager);
66
67 // This sets the pilot object, allowing the flight controls to get control inputs
68 void SetPilotObject(P6DofPilotObject* aP6DofPilotObject);
69
70 // ......................................................................................
71
72 // This returns a 'handle' to a control surface. If there is no control surface
73 // with the specified name, the function returns 0;
74 size_t GetControlSurfaceHandle(const std::string& aControlSurfaceName) const;
75
76 // This returns a 'handle' to the first control surface that contains the
77 // specified string. If there is no control surface that contains the name,
78 // the function returns 0;
79 size_t GetControlSurfaceHandleContainingString(const std::string& aString) const;
80
81 // This returns a 'handle' to the first control surface that contains the
82 // two specified strings. If there is no control surface that contains the names,
83 // the function returns 0;
84 size_t GetControlSurfaceHandleContainingTwoStrings(const std::string& aString1, const std::string& aString2) const;
85
86 // This returns the name of the control surface, given its handle
87 std::string GetControlSurfaceName(size_t aControlSurfaceHandle) const;
88
89 // This returns the angle of the control surface in degrees, given its handle
90 double GetControlSurfaceAngle_deg(size_t aControlSurfaceHandle) const;
91
92 // This returns the max angle of the control surface in degrees, given its handle
93 double GetControlSurfaceMinAngle_deg(size_t aControlSurfaceHandle) const;
94
95 // This returns the max angle of the control surface in degrees, given its handle
96 double GetControlSurfaceMaxAngle_deg(size_t aControlSurfaceHandle) const;
97
98 // This returns the normalized angle of the control surface, given its handle
99 double GetControlSurfaceValueNormalized(size_t aControlSurfaceHandle) const;
100
101 // This sets the angle of the control surface in degrees, given its handle.
102 // Note that this should only be used for initialization, to set the position
103 // to a desired angle. This will also set the actuator position.
104 void SetControlSurfaceAngle_deg(size_t aControlSurfaceHandle, double aAngle_deg);
105
106 // ......................................................................................
107
108 // This returns a 'handle' to a control output value. If there is no control value
109 // with the specified name, the function returns 0;
110 size_t GetControlValueHandle(const std::string& aControlValueName) const;
111
112 // This returns the name of the control value, given its handle
113 std::string GetControlValueName(size_t aControlValueHandle) const;
114
115 // This returns the value of the control value, given its handle
116 double GetControlValue(size_t aControlValueHandle) const;
117
118 // ......................................................................................
119
120 // This returns a 'handle' to a boolean control. If there is no boolean control
121 // with the specified name, the function returns 0;
122 size_t GetBooleanControlHandle(const std::string& aControlBooleanName) const;
123
124 // This returns the name of the boolean control, given its handle
125 std::string GetBooleanControlName(size_t aControlBooleanHandle) const;
126
127 // This returns the value of the boolean control, given its handle
128 bool GetControlBoolean(size_t aControlBooleanHandle) const;
129
130 // This returns the last value of the boolean control, given its handle
131 bool GetControlBooleanLastValue(size_t aControlBooleanHandle) const;
132
133 // ......................................................................................
134
135 // This clears all control data
136 void ClearAllControlData();
137
138 // This returns the number of flight control inputs
139 size_t NumFlightControlInputs() const;
140
141 // This loads data for the specified control input
142 void LoadFlightControlInputData(size_t aIndex, P6DOF::FlightControlInputValue* aData) const;
143
144 // This returns the number of flight control surfaces
145 size_t NumFlightControlSurfaces() const;
146
147 // This loads data for the specified control surface
148 void LoadFlightControlSurfaceData(size_t aIndex, P6DOF::ControlSurfaceValue* aData) const;
149
150 // .....................................................................................................
151
160
187
189 {
191 : type(Undefined)
192 , table(nullptr)
193 , curve(nullptr)
194 , scalarGain(1.0)
195 , minClamp(-1.0)
196 , maxClamp(1.0)
197 {
198 }
199 std::string name;
201 UtCloneablePtr<UtTable::Table> table;
202 UtCloneablePtr<UtTable::Curve> curve;
204 double minClamp;
205 double maxClamp;
206 };
207
209 {
210 std::string controlInputName;
211 ControlInputValue* controlInput; // This is owned externally
212 std::vector<std::string> modifierNameList;
213 std::vector<ControlSignalModifier*> modifierList; // This is owned externally
214 };
215
216 // This contains data for a single control surface, including a list
217 // of control inputs and modifiers as well as the angle mapping and actuator
219 {
221 std::vector<ControlInputGainStream*> controlInputList;
222 UtTable::Curve* angleMappingAuto;
223 UtTable::Curve* angleMappingManual;
229 {
230 std::vector<ControlInputGainStream*>::iterator it;
231 for (it = controlInputList.begin(); it != controlInputList.end(); ++it)
232 {
233 delete *it;
234 }
235 if (angleMappingAuto != nullptr)
236 {
237 delete angleMappingAuto;
238 }
239 if (angleMappingManual != nullptr)
240 {
241 delete angleMappingManual;
242 }
243 if (actuator != nullptr)
244 {
245 delete actuator;
246 }
247 }
248 };
249
250 // This contains data for a single control output, including a list
251 // of control inputs and modifiers
253 {
254 std::string controlValueName;
255 std::vector<ControlInputGainStream*> controlInputList;
257 double minValue;
258 double maxValue;
260 {
261 std::vector<ControlInputGainStream*>::iterator it;
262 for (it = controlInputList.begin(); it != controlInputList.end(); ++it)
263 {
264 delete *it;
265 }
266 }
267 };
268
269 // This contains data for a single boolean output, including a list
270 // of control inputs and modifiers
272 {
273 std::string controlValueName;
274 std::vector<ControlInputGainStream*> controlInputList;
279 {
280 std::vector<ControlInputGainStream*>::iterator it;
281 for (it = controlInputList.begin(); it != controlInputList.end(); ++it)
282 {
283 delete *it;
284 }
285 }
286 };
287
288 // .....................................................................................................
289
290 // This provides a list/vector of control surfaces that use the specified input handle
291 // If there are none, it returns false.
292 bool GetControlSurfacesUsingInput(std::vector<ControlSurfaceElement*>& list, unsigned int aInputHandle);
293
294 // This provides a list/vector of control surface names. If there are none, it returns an empty vector.
295 void GetControlSurfaceNames(std::vector<std::string>& list);
296
297 // This provides a vector of the current control surface angles and actuator angles. It is used with
298 // the SetAllControlSurfaceAndActuatorsAngles function to get/save angles and later reset the angles.
299 void GetAllControlSurfaceAndActuatorsAngles(std::vector<double>& aControlSurfaceAngles_deg,
300 std::vector<double>& aActuatorAngles_deg) const;
301
302 // This uses vectors of the current control surface angles and actuator angles obtained
303 // from the function GetAllControlSurfaceAndActuatorsAngles function to set the angles.
304 void SetAllControlSurfaceAndActuatorsAngles(const std::vector<double>& aControlSurfaceAngles_deg,
305 const std::vector<double>& aActuatorAngles_deg);
306
307 // This sets the control surface positions based on the control inputs
308 void SetControlSurfacesBasedOnControlInputs(int64_t aSimTime_nanosec);
309
310 // This sets the control values based on the control inputs
311 void SetControlValuesBasedOnControlInputs();
312
313 // This sets the control booleans based on the control inputs
314 void SetControlBooleansBasedOnControlInputs();
315
316 // .....................................................................................................
317
318protected:
320
321 // This processes file input for signal modifiers
322 bool ProcessSignalModifierTable(UtInput& aInput);
323
324 // This processes file input for control surfaces
325 bool ProcessControlSurfaceInput(UtInput& aInput);
326
327 // This processes file input for control values
328 bool ProcessControlValueInput(UtInput& aInput);
329
330 // This processes file input for control booleans
331 bool ProcessControlBooleanInput(UtInput& aInput);
332
333 bool ProcessInputSet(UtInput& aInput, ControlSurfaceElement* aActiveControlSurfaceElement);
334 bool ProcessInputSet(UtInput& aInput, ControlValueElement* aActiveControlValueElement);
335 bool ProcessInputSet(UtInput& aInput, ControlBooleanElement* aActiveControlBooleanElement);
336
337 bool ProcessControlInputs(UtInput& aInput, ControlSurfaceElement* aActiveControlSurfaceElement);
338 bool ProcessControlInputs(UtInput& aInput, ControlValueElement* aActiveControlValueElement);
339 bool ProcessControlInputs(UtInput& aInput, ControlBooleanElement* aActiveControlBooleanElement);
340
341 // This adds the control surface to the list if the name is unique.
342 // If it cannot add it to the list, it returns false, else it returns true
343 bool AddControlSurfaceToList(ControlSurfaceElement* aControlSurface);
344
345 // This adds the control value to the list if the name is unique.
346 // If it cannot add it to the list, it returns false, else it returns true
347 bool AddControlValueToList(ControlValueElement* aControlValue);
348
349 // This adds the control boolean to the list if the name is unique.
350 // If it cannot add it to the list, it returns false, else it returns true
351 bool AddControlBooleanToList(ControlBooleanElement* aControlBoolean);
352
353 ControlInputValue* GetControlInputByName(const std::string& aControlInputName) const;
354 ControlSignalModifier* GetControlSignalModifierByName(const std::string& aSignalModifierName) const;
355
358
359 std::vector<ControlInputValue*> mControlInputList;
360 std::vector<ControlSignalModifier*> mControlSignalModifiersList;
361 std::vector<ControlSurfaceElement*> mControlSurfaceList;
362 std::vector<ControlValueElement*> mControlValueList;
363 std::vector<ControlBooleanElement*> mControlBooleanList;
364
367};
368
369#endif
aObjectPtr Update(simTime)
Definition P6DofControlActuator.hpp:21
Definition P6DofFlightControlSystem.hpp:42
ControlSignalModifierType
Definition P6DofFlightControlSystem.hpp:162
@ BetaGainTable
Definition P6DofFlightControlSystem.hpp:170
@ SASChannel
Definition P6DofFlightControlSystem.hpp:166
@ GyLoadMappingTable
Definition P6DofFlightControlSystem.hpp:181
@ ScalarGain
Definition P6DofFlightControlSystem.hpp:164
@ ClampGain
Definition P6DofFlightControlSystem.hpp:165
@ MachMappingTable
Definition P6DofFlightControlSystem.hpp:176
@ GyLoadGainTable
Definition P6DofFlightControlSystem.hpp:172
@ GxLoadGainTable
Definition P6DofFlightControlSystem.hpp:171
@ QMappingTable
Definition P6DofFlightControlSystem.hpp:184
@ KTASMappingTable
Definition P6DofFlightControlSystem.hpp:177
@ AltGainTable
Definition P6DofFlightControlSystem.hpp:174
@ AltMappingTable
Definition P6DofFlightControlSystem.hpp:183
@ AlphaMappingTable
Definition P6DofFlightControlSystem.hpp:178
@ MachGainTable
Definition P6DofFlightControlSystem.hpp:167
@ SignalMappingTable
Definition P6DofFlightControlSystem.hpp:185
@ Undefined
Definition P6DofFlightControlSystem.hpp:163
@ KTASGainTable
Definition P6DofFlightControlSystem.hpp:168
@ QGainTable
Definition P6DofFlightControlSystem.hpp:175
@ AlphaGainTable
Definition P6DofFlightControlSystem.hpp:169
@ GzLoadMappingTable
Definition P6DofFlightControlSystem.hpp:182
@ GzLoadGainTable
Definition P6DofFlightControlSystem.hpp:173
@ GxLoadMappingTable
Definition P6DofFlightControlSystem.hpp:180
@ BetaMappingTable
Definition P6DofFlightControlSystem.hpp:179
P6DofKinematicState mState
Definition P6DofFlightControlSystem.hpp:366
P6DofFlightControlSystem & operator=(const P6DofFlightControlSystem &other)=delete
std::vector< ControlValueElement * > mControlValueList
Definition P6DofFlightControlSystem.hpp:362
P6DofFlightControlSystem(P6DofScenario *aScenario)
Definition P6DofFlightControlSystem.cpp:26
std::vector< ControlSurfaceElement * > mControlSurfaceList
Definition P6DofFlightControlSystem.hpp:361
bool ProcessInput(UtInput &aInput)
Definition P6DofFlightControlSystem.cpp:434
int64_t mLastUpdateSimTime_nanosec
Definition P6DofFlightControlSystem.hpp:365
bool Initialize(int64_t aSimTime_nanosec)
Definition P6DofFlightControlSystem.cpp:1336
void ConnectInputsWithOutputs()
Definition P6DofFlightControlSystem.cpp:210
std::vector< ControlSignalModifier * > mControlSignalModifiersList
Definition P6DofFlightControlSystem.hpp:360
std::vector< ControlBooleanElement * > mControlBooleanList
Definition P6DofFlightControlSystem.hpp:363
P6DofPilotManager * mP6DofPilotManager
Definition P6DofFlightControlSystem.hpp:357
std::vector< ControlInputValue * > mControlInputList
Definition P6DofFlightControlSystem.hpp:359
P6DofPilotObject * mP6DofPilotObjectPtr
Definition P6DofFlightControlSystem.hpp:356
void SetLastUpdateSimTime(int64_t aLastUpdateSimTime_nanosec)
Definition P6DofFlightControlSystem.hpp:59
Definition P6DofKinematicState.hpp:31
P6DofObject(P6DofScenario *aScenario)
Definition P6DofObject.cpp:17
P6DofObject * Clone() const
Definition P6DofObject.cpp:24
Definition P6DofPilotManager.hpp:38
Definition P6DofPilotObject.hpp:37
Definition P6DofScenario.hpp:25
Definition P6DofVehicle.hpp:53
Simple
Definition P6DofVehicleData.hpp:25
Definition P6DofVehicleData.hpp:66
Definition P6DofVehicleData.hpp:74
Definition P6DofFlightControlSystem.hpp:272
std::string controlValueName
Definition P6DofFlightControlSystem.hpp:273
~ControlBooleanElement()
Definition P6DofFlightControlSystem.hpp:278
double thresholdValue
Definition P6DofFlightControlSystem.hpp:275
std::vector< ControlInputGainStream * > controlInputList
Definition P6DofFlightControlSystem.hpp:274
bool currentValue
Definition P6DofFlightControlSystem.hpp:276
bool lastValue
Definition P6DofFlightControlSystem.hpp:277
Definition P6DofFlightControlSystem.hpp:209
std::vector< ControlSignalModifier * > modifierList
Definition P6DofFlightControlSystem.hpp:213
std::vector< std::string > modifierNameList
Definition P6DofFlightControlSystem.hpp:212
std::string controlInputName
Definition P6DofFlightControlSystem.hpp:210
ControlInputValue * controlInput
Definition P6DofFlightControlSystem.hpp:211
Definition P6DofFlightControlSystem.hpp:153
bool boolData
Definition P6DofFlightControlSystem.hpp:158
std::string name
Definition P6DofFlightControlSystem.hpp:154
size_t handle
Definition P6DofFlightControlSystem.hpp:155
P6DOF::DataType::Simple typeData
Definition P6DofFlightControlSystem.hpp:157
double normalizedValue
Definition P6DofFlightControlSystem.hpp:156
double scalarGain
Definition P6DofFlightControlSystem.hpp:203
ControlSignalModifier()
Definition P6DofFlightControlSystem.hpp:190
double maxClamp
Definition P6DofFlightControlSystem.hpp:205
UtCloneablePtr< UtTable::Curve > curve
Definition P6DofFlightControlSystem.hpp:202
UtCloneablePtr< UtTable::Table > table
Definition P6DofFlightControlSystem.hpp:201
std::string name
Definition P6DofFlightControlSystem.hpp:199
ControlSignalModifierType type
Definition P6DofFlightControlSystem.hpp:200
double minClamp
Definition P6DofFlightControlSystem.hpp:204
Definition P6DofFlightControlSystem.hpp:219
std::string controlSurfaceName
Definition P6DofFlightControlSystem.hpp:220
double minAngle_deg
Definition P6DofFlightControlSystem.hpp:226
UtTable::Curve * angleMappingAuto
Definition P6DofFlightControlSystem.hpp:222
~ControlSurfaceElement()
Definition P6DofFlightControlSystem.hpp:228
double currentAngle_deg
Definition P6DofFlightControlSystem.hpp:225
UtTable::Curve * angleMappingManual
Definition P6DofFlightControlSystem.hpp:223
std::vector< ControlInputGainStream * > controlInputList
Definition P6DofFlightControlSystem.hpp:221
double maxAngle_deg
Definition P6DofFlightControlSystem.hpp:227
P6DofControlActuator * actuator
Definition P6DofFlightControlSystem.hpp:224
Definition P6DofFlightControlSystem.hpp:253
std::string controlValueName
Definition P6DofFlightControlSystem.hpp:254
double maxValue
Definition P6DofFlightControlSystem.hpp:258
double currentValue
Definition P6DofFlightControlSystem.hpp:256
~ControlValueElement()
Definition P6DofFlightControlSystem.hpp:259
double minValue
Definition P6DofFlightControlSystem.hpp:257
std::vector< ControlInputGainStream * > controlInputList
Definition P6DofFlightControlSystem.hpp:255
Copyrights Multiple, All Rights Reserved