JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGFCS.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGGFCS.h
4  Author: Jon S. Berndt
5  Date started: 12/12/98
6 
7  ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/12/98 JSB Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGFCS_H
35 #define FGFCS_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <iosfwd>
42 #include <vector>
43 #include <string>
44 
45 #include "models/FGModel.h"
46 #include "models/FGLGear.h"
47 #include "models/FGGroundReactions.h"
48 
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 class FGFCSChannel;
56 typedef enum { ofRad=0, ofDeg, ofNorm, ofMag , NForms} OutputForm;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
183 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 CLASS DECLARATION
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
186 
187 class FGFCS : public FGModel
188 {
189 
190 public:
193  FGFCS(FGFDMExec*);
195  ~FGFCS() override;
196 
197  bool InitModel(void) override;
198 
206  bool Run(bool Holding) override;
207 
209 
210 
212  double GetDaCmd(void) const { return DaCmd; }
213 
216  double GetDeCmd(void) const { return DeCmd; }
217 
220  double GetDrCmd(void) const { return DrCmd; }
221 
224  double GetDsCmd(void) const { return fdmex->GetGroundReactions()->GetDsCmd(); }
225 
228  double GetDfCmd(void) const { return DfCmd; }
229 
232  double GetDsbCmd(void) const { return DsbCmd; }
233 
236  double GetDspCmd(void) const { return DspCmd; }
237 
241  double GetThrottleCmd(int engine) const;
242 
243  const std::vector<double>& GetThrottleCmd() const {return ThrottleCmd;}
244 
248  double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
249 
250  const std::vector<double>& GetMixtureCmd() const {return MixtureCmd;}
251 
255  double GetPropAdvanceCmd(int engine) const { return PropAdvanceCmd[engine]; }
256 
260  bool GetFeatherCmd(int engine) const { return PropFeatherCmd[engine]; }
261 
264  double GetPitchTrimCmd(void) const { return PTrimCmd; }
265 
268  double GetYawTrimCmd(void) const { return YTrimCmd; }
269 
272  double GetRollTrimCmd(void) const { return RTrimCmd; }
273 
277  double GetGearCmd(void) const { return GearCmd; }
279 
281 
282 
284  double GetDaLPos( int form = ofRad )
285  const { return DaLPos[form]; }
286 
289  double GetDaRPos( int form = ofRad )
290  const { return DaRPos[form]; }
291 
294  double GetDePos( int form = ofRad )
295  const { return DePos[form]; }
296 
299  double GetDrPos( int form = ofRad )
300  const { return DrPos[form]; }
301 
304  double GetDsbPos( int form = ofRad )
305  const { return DsbPos[form]; }
306 
309  double GetDspPos( int form = ofRad )
310  const { return DspPos[form]; }
311 
314  double GetDfPos( int form = ofRad )
315  const { return DfPos[form]; }
316 
320  double GetThrottlePos(int engine) const;
321 
322  const std::vector<double>& GetThrottlePos() const {return ThrottlePos;}
323 
327  double GetMixturePos(int engine) const { return MixturePos[engine]; }
328 
329  const std::vector<double>& GetMixturePos() const {return MixturePos;}
330 
333  double GetGearPos(void) const { return GearPos; }
334 
337  double GetTailhookPos(void) const { return TailhookPos; }
338 
341  double GetWingFoldPos(void) const { return WingFoldPos; }
342 
346  double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
347 
348  const std::vector<double>& GetPropAdvance() const { return PropAdvance; }
349 
353  bool GetPropFeather(int engine) const { return PropFeather[engine]; }
354 
355  const std::vector<bool>& GetPropFeather() const { return PropFeather; }
357 
361  std::string GetComponentStrings(const std::string& delimiter) const;
362 
367  std::string GetComponentValues(const std::string& delimiter) const;
368 
370 
371 
373  void SetDaCmd( double cmd ) { DaCmd = cmd; }
374 
377  void SetDeCmd(double cmd ) { DeCmd = cmd; }
378 
381  void SetDrCmd(double cmd) { DrCmd = cmd; }
382 
385  void SetDsCmd(double cmd) { fdmex->GetGroundReactions()->SetDsCmd( cmd ); }
386 
389  void SetDfCmd(double cmd) { DfCmd = cmd; }
390 
393  void SetDsbCmd(double cmd) { DsbCmd = cmd; }
394 
397  void SetDspCmd(double cmd) { DspCmd = cmd; }
398 
401  void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
402 
405  void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
406 
409  void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
410 
414  void SetThrottleCmd(int engine, double cmd);
415 
419  void SetMixtureCmd(int engine, double cmd);
420 
423  void SetGearCmd(double gearcmd) { GearCmd = gearcmd; }
424 
428  void SetPropAdvanceCmd(int engine, double cmd);
429 
433  void SetFeatherCmd(int engine, bool cmd);
435 
437 
438 
440  void SetDaLPos( int form , double pos );
441 
444  void SetDaRPos( int form , double pos );
445 
448  void SetDePos( int form , double pos );
449 
452  void SetDrPos( int form , double pos );
453 
456  void SetDfPos( int form , double pos );
457 
460  void SetDsbPos( int form , double pos );
461 
464  void SetDspPos( int form , double pos );
465 
469  void SetThrottlePos(int engine, double cmd);
470 
474  void SetMixturePos(int engine, double cmd);
475 
478  void SetGearPos(double gearpos) { GearPos = gearpos; }
479 
482  void SetTailhookPos(double hookpos) { TailhookPos = hookpos; }
483 
486  void SetWingFoldPos(double foldpos) { WingFoldPos = foldpos; }
487 
491  void SetPropAdvance(int engine, double cmd);
492 
496  void SetPropFeather(int engine, bool cmd);
498 
500 
501 
503  void SetLBrake(double cmd) {BrakePos[FGLGear::bgLeft] = cmd;}
504 
507  void SetRBrake(double cmd) {BrakePos[FGLGear::bgRight] = cmd;}
508 
511  void SetCBrake(double cmd) {BrakePos[FGLGear::bgCenter] = cmd;}
512 
516  double GetBrake(FGLGear::BrakeGroup bg);
517 
518  const std::vector<double>& GetBrakePos() const {return BrakePos;}
519 
522  double GetLBrake(void) const {return BrakePos[FGLGear::bgLeft];}
523 
526  double GetRBrake(void) const {return BrakePos[FGLGear::bgRight];}
527 
530  double GetCBrake(void) const {return BrakePos[FGLGear::bgCenter];}
532 
533  enum SystemType { stFCS, stSystem, stAutoPilot };
534 
539  bool Load(Element* el) override;
540 
541  SGPath FindFullPathName(const SGPath& path) const override;
542 
543  void AddThrottle(void);
544  double GetDt(void) const;
545 
546  FGPropertyManager* GetPropertyManager(void) { return PropertyManager; }
547 
548  bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
549  double GetChannelDeltaT(void) const { return GetDt() * ChannelRate; }
550 
551 private:
552  double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
553  double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms];
554  double DfPos[NForms], DsbPos[NForms], DspPos[NForms];
555  double PTrimCmd, YTrimCmd, RTrimCmd;
556  std::vector <double> ThrottleCmd;
557  std::vector <double> ThrottlePos;
558  std::vector <double> MixtureCmd;
559  std::vector <double> MixturePos;
560  std::vector <double> PropAdvanceCmd;
561  std::vector <double> PropAdvance;
562  std::vector <bool> PropFeatherCmd;
563  std::vector <bool> PropFeather;
564  //double LeftBrake, RightBrake, CenterBrake; // Brake settings
565  std::vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum
566  double GearCmd,GearPos;
567  double TailhookPos, WingFoldPos;
568  SystemType systype;
569  int ChannelRate;
570  FGFDMExec* fdmex;
571 
572  typedef std::vector <FGFCSChannel*> Channels;
573  Channels SystemChannels;
574  void bind(void);
575  void bindThrottle(unsigned int);
576  void Debug(int from) override;
577 };
578 }
579 
580 #endif
JSBSim::FGFCS::SetDaRPos
void SetDaRPos(int form, double pos)
Sets the right aileron position.
Definition: FGFCS.cpp:201
JSBSim::FGFCS::SetDspPos
void SetDspPos(int form, double pos)
Sets the spoiler position.
Definition: FGFCS.cpp:296
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGFCS::GetCBrake
double GetCBrake(void) const
Gets the center brake.
Definition: FGFCS.h:530
JSBSim::FGFCS::GetGearPos
double GetGearPos(void) const
Gets the gear position (0 up, 1 down), defaults to down.
Definition: FGFCS.h:333
JSBSim::FGFCS::SetPropAdvance
void SetPropAdvance(int engine, double cmd)
Sets the actual prop pitch setting for the specified engine.
Definition: FGFCS.cpp:429
JSBSim::FGFCS::GetDsbCmd
double GetDsbCmd(void) const
Gets the speedbrake command.
Definition: FGFCS.h:232
JSBSim::FGFCS::SetFeatherCmd
void SetFeatherCmd(int engine, bool cmd)
Sets the propeller feather command for the specified engine.
Definition: FGFCS.cpp:443
JSBSim::FGFCS::SetThrottlePos
void SetThrottlePos(int engine, double cmd)
Sets the actual throttle setting for the specified engine.
Definition: FGFCS.cpp:333
JSBSim::FGFCS::SetDfPos
void SetDfPos(int form, double pos)
Sets the flaps position.
Definition: FGFCS.cpp:258
JSBSim::FGModel
Base class for all scheduled JSBSim models.
Definition: FGModel.h:68
JSBSim::FGFCS::GetPitchTrimCmd
double GetPitchTrimCmd(void) const
Gets the pitch trim command.
Definition: FGFCS.h:264
JSBSim::FGFCS::GetDeCmd
double GetDeCmd(void) const
Gets the elevator command.
Definition: FGFCS.h:216
JSBSim::FGFCS::~FGFCS
~FGFCS() override
Destructor.
Definition: FGFCS.cpp:96
JSBSim::FGGroundReactions::GetDsCmd
double GetDsCmd(void) const
Gets the steering command.
Definition: FGGroundReactions.h:114
JSBSim::FGFCS::SetDeCmd
void SetDeCmd(double cmd)
Sets the elevator command.
Definition: FGFCS.h:377
JSBSim::FGFCS::GetDsCmd
double GetDsCmd(void) const
Gets the steering command.
Definition: FGFCS.h:224
JSBSim::FGFCS::SetRBrake
void SetRBrake(double cmd)
Sets the right brake group.
Definition: FGFCS.h:507
JSBSim::FGFCS::GetYawTrimCmd
double GetYawTrimCmd(void) const
Gets the rudder trim command.
Definition: FGFCS.h:268
JSBSim::FGFCS::GetFeatherCmd
bool GetFeatherCmd(int engine) const
Gets the prop feather command.
Definition: FGFCS.h:260
JSBSim::FGFCS::GetDfPos
double GetDfPos(int form=ofRad) const
Gets the flaps position.
Definition: FGFCS.h:314
JSBSim::FGFCS::SetMixturePos
void SetMixturePos(int engine, double cmd)
Sets the actual mixture setting for the specified engine.
Definition: FGFCS.cpp:401
JSBSim::FGFCS::GetDfCmd
double GetDfCmd(void) const
Gets the flaps command.
Definition: FGFCS.h:228
JSBSim::FGFCS::SetThrottleCmd
void SetThrottleCmd(int engine, double cmd)
Sets the throttle command for the specified engine.
Definition: FGFCS.cpp:315
JSBSim::FGFDMExec::GetGroundReactions
FGGroundReactions * GetGroundReactions(void)
Returns the FGGroundReactions pointer.
Definition: FGFDMExec.h:369
JSBSim::FGFCS::GetTailhookPos
double GetTailhookPos(void) const
Gets the tailhook position (0 up, 1 down)
Definition: FGFCS.h:337
JSBSim::FGFCS::SetDrPos
void SetDrPos(int form, double pos)
Sets the rudder position.
Definition: FGFCS.cpp:239
JSBSim::FGFCS::GetDaCmd
double GetDaCmd(void) const
Gets the aileron command.
Definition: FGFCS.h:212
JSBSim::FGFCS::SetPropFeather
void SetPropFeather(int engine, bool cmd)
Sets the actual prop feather setting for the specified engine.
Definition: FGFCS.cpp:457
JSBSim::FGFCS::GetPropAdvanceCmd
double GetPropAdvanceCmd(int engine) const
Gets the prop pitch command.
Definition: FGFCS.h:255
JSBSim::FGFCS::GetComponentStrings
std::string GetComponentStrings(const std::string &delimiter) const
Retrieves all component names for inclusion in output stream.
Definition: FGFCS.cpp:624
JSBSim::FGFCS::SetDspCmd
void SetDspCmd(double cmd)
Sets the spoilers command.
Definition: FGFCS.h:397
JSBSim::FGFCS::SetDfCmd
void SetDfCmd(double cmd)
Sets the flaps command.
Definition: FGFCS.h:389
JSBSim::FGFCS::GetWingFoldPos
double GetWingFoldPos(void) const
Gets the wing fold position (0 unfolded, 1 folded)
Definition: FGFCS.h:341
JSBSim::FGFCS::Run
bool Run(bool Holding) override
Runs the Flight Controls model; called by the Executive Can pass in a value indicating if the executi...
Definition: FGFCS.cpp:153
JSBSim::FGGroundReactions::SetDsCmd
void SetDsCmd(double cmd)
Sets the steering command.
Definition: FGGroundReactions.cpp:137
JSBSim::FGFCS::SetDaCmd
void SetDaCmd(double cmd)
Sets the aileron command.
Definition: FGFCS.h:373
JSBSim::FGFCS::GetDePos
double GetDePos(int form=ofRad) const
Gets the elevator position.
Definition: FGFCS.h:294
JSBSim::FGFCS::GetLBrake
double GetLBrake(void) const
Gets the left brake.
Definition: FGFCS.h:522
JSBSim::FGFCS::SetGearCmd
void SetGearCmd(double gearcmd)
Set the gear extend/retract command, defaults to down.
Definition: FGFCS.h:423
JSBSim::FGFCS::SetDaLPos
void SetDaLPos(int form, double pos)
Sets the left aileron position.
Definition: FGFCS.cpp:182
JSBSim::FGFCS::SetDsbCmd
void SetDsbCmd(double cmd)
Sets the speedbrake command.
Definition: FGFCS.h:393
JSBSim::FGFCS::GetDspPos
double GetDspPos(int form=ofRad) const
Gets the spoiler position.
Definition: FGFCS.h:309
JSBSim::FGFCS::SetWingFoldPos
void SetWingFoldPos(double foldpos)
Set the wing fold position.
Definition: FGFCS.h:486
JSBSim::FGFCS::GetMixtureCmd
double GetMixtureCmd(int engine) const
Gets the mixture command.
Definition: FGFCS.h:248
JSBSim::FGFCS::GetDspCmd
double GetDspCmd(void) const
Gets the spoiler command.
Definition: FGFCS.h:236
JSBSim::FGFCS::SetPitchTrimCmd
void SetPitchTrimCmd(double cmd)
Sets the pitch trim command.
Definition: FGFCS.h:401
JSBSim::FGFCS::GetComponentValues
std::string GetComponentValues(const std::string &delimiter) const
Retrieves all component outputs for inclusion in output stream.
Definition: FGFCS.cpp:647
JSBSim::FGFCS::GetDsbPos
double GetDsbPos(int form=ofRad) const
Gets the speedbrake position.
Definition: FGFCS.h:304
JSBSim::FGFCS::SetYawTrimCmd
void SetYawTrimCmd(double cmd)
Sets the rudder trim command.
Definition: FGFCS.h:405
JSBSim::FGFCS::GetDrCmd
double GetDrCmd(void) const
Gets the rudder command.
Definition: FGFCS.h:220
JSBSim::FGFCS::GetPropFeather
bool GetPropFeather(int engine) const
Gets the prop feather position.
Definition: FGFCS.h:353
JSBSim::FGFCS::GetRBrake
double GetRBrake(void) const
Gets the right brake.
Definition: FGFCS.h:526
JSBSim::FGFCS
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:187
JSBSim::FGFCS::FGFCS
FGFCS(FGFDMExec *)
Constructor.
Definition: FGFCS.cpp:72
JSBSim::FGFCS::GetRollTrimCmd
double GetRollTrimCmd(void) const
Gets the aileron trim command.
Definition: FGFCS.h:272
JSBSim::FGLGear::BrakeGroup
BrakeGroup
Brake grouping enumerators.
Definition: FGLGear.h:215
JSBSim::FGFCS::SetLBrake
void SetLBrake(double cmd)
Sets the left brake group.
Definition: FGFCS.h:503
JSBSim::FGFCS::GetDaRPos
double GetDaRPos(int form=ofRad) const
Gets the right aileron position.
Definition: FGFCS.h:289
JSBSim::FGFCS::GetMixturePos
double GetMixturePos(int engine) const
Gets the mixture position.
Definition: FGFCS.h:327
JSBSim::FGFCS::SetMixtureCmd
void SetMixtureCmd(int engine, double cmd)
Sets the mixture command for the specified engine.
Definition: FGFCS.cpp:387
JSBSim::FGFCS::SetPropAdvanceCmd
void SetPropAdvanceCmd(int engine, double cmd)
Sets the propeller pitch command for the specified engine.
Definition: FGFCS.cpp:415
JSBSim::FGFCS::SetDsbPos
void SetDsbPos(int form, double pos)
Sets the speedbrake position.
Definition: FGFCS.cpp:277
JSBSim::FGFCS::SetDsCmd
void SetDsCmd(double cmd)
Sets the steering command.
Definition: FGFCS.h:385
JSBSim::FGFCS::SetTailhookPos
void SetTailhookPos(double hookpos)
Set the tailhook position.
Definition: FGFCS.h:482
JSBSim::FGFCS::Load
bool Load(Element *el) override
Loads the Flight Control System.
Definition: FGFCS.cpp:471
JSBSim::FGFCS::SetDrCmd
void SetDrCmd(double cmd)
Sets the rudder command.
Definition: FGFCS.h:381
JSBSim::FGFCS::SetCBrake
void SetCBrake(double cmd)
Sets the center brake group.
Definition: FGFCS.h:511
JSBSim::FGFCS::GetPropAdvance
double GetPropAdvance(int engine) const
Gets the prop pitch position.
Definition: FGFCS.h:346
JSBSim::FGFCS::GetGearCmd
double GetGearCmd(void) const
Get the gear extend/retract command.
Definition: FGFCS.h:277
JSBSim::FGFCS::GetBrake
double GetBrake(FGLGear::BrakeGroup bg)
Gets the brake for a specified group.
Definition: FGFCS.cpp:604
JSBSim::FGFCS::GetDaLPos
double GetDaLPos(int form=ofRad) const
Gets the left aileron position.
Definition: FGFCS.h:284
JSBSim::FGFCS::SetRollTrimCmd
void SetRollTrimCmd(double cmd)
Sets the aileron trim command.
Definition: FGFCS.h:409
JSBSim::FGFCS::GetDrPos
double GetDrPos(int form=ofRad) const
Gets the rudder position.
Definition: FGFCS.h:299
JSBSim::FGFCS::SetDePos
void SetDePos(int form, double pos)
Sets the elevator position.
Definition: FGFCS.cpp:220
JSBSim::FGFCS::SetGearPos
void SetGearPos(double gearpos)
Set the gear extend/retract position, defaults to down.
Definition: FGFCS.h:478