JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
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 "FGFDMExec.h"
46 #include "models/FGModel.h"
47 #include "models/FGLGear.h"
48 #include "models/FGGroundReactions.h"
49 
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 
54 namespace JSBSim {
55 
56 class FGFCSChannel;
57 typedef enum { ofRad=0, ofDeg, ofNorm, ofMag , NForms} OutputForm;
58 
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 
184 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 CLASS DECLARATION
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
187 
188 class JSBSIM_API FGFCS : public FGModel
189 {
190 
191 public:
194  FGFCS(FGFDMExec*);
196  ~FGFCS() override;
197 
198  bool InitModel(void) override;
199 
207  bool Run(bool Holding) override;
208 
210 
211 
213  double GetDaCmd(void) const { return DaCmd; }
214 
217  double GetDeCmd(void) const { return DeCmd; }
218 
221  double GetDrCmd(void) const { return DrCmd; }
222 
225  double GetDsCmd(void) const { return fdmex->GetGroundReactions()->GetDsCmd(); }
226 
229  double GetDfCmd(void) const { return DfCmd; }
230 
233  double GetDsbCmd(void) const { return DsbCmd; }
234 
237  double GetDspCmd(void) const { return DspCmd; }
238 
242  double GetThrottleCmd(int engine) const;
243 
244  const std::vector<double>& GetThrottleCmd() const {return ThrottleCmd;}
245 
249  double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
250 
251  const std::vector<double>& GetMixtureCmd() const {return MixtureCmd;}
252 
256  double GetPropAdvanceCmd(int engine) const { return PropAdvanceCmd[engine]; }
257 
261  bool GetFeatherCmd(int engine) const { return PropFeatherCmd[engine]; }
262 
265  double GetPitchTrimCmd(void) const { return PTrimCmd; }
266 
269  double GetYawTrimCmd(void) const { return YTrimCmd; }
270 
273  double GetRollTrimCmd(void) const { return RTrimCmd; }
274 
278  double GetGearCmd(void) const { return GearCmd; }
280 
282 
283 
285  double GetDaLPos( int form = ofRad )
286  const { return DaLPos[form]; }
287 
290  double GetDaRPos( int form = ofRad )
291  const { return DaRPos[form]; }
292 
295  double GetDePos( int form = ofRad )
296  const { return DePos[form]; }
297 
300  double GetDrPos( int form = ofRad )
301  const { return DrPos[form]; }
302 
305  double GetDsbPos( int form = ofRad )
306  const { return DsbPos[form]; }
307 
310  double GetDspPos( int form = ofRad )
311  const { return DspPos[form]; }
312 
315  double GetDfPos( int form = ofRad )
316  const { return DfPos[form]; }
317 
321  double GetThrottlePos(int engine) const;
322 
323  const std::vector<double>& GetThrottlePos() const {return ThrottlePos;}
324 
328  double GetMixturePos(int engine) const { return MixturePos[engine]; }
329 
330  const std::vector<double>& GetMixturePos() const {return MixturePos;}
331 
334  double GetGearPos(void) const { return GearPos; }
335 
338  double GetTailhookPos(void) const { return TailhookPos; }
339 
342  double GetWingFoldPos(void) const { return WingFoldPos; }
343 
347  double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
348 
349  const std::vector<double>& GetPropAdvance() const { return PropAdvance; }
350 
354  bool GetPropFeather(int engine) const { return PropFeather[engine]; }
355 
356  const std::vector<bool>& GetPropFeather() const { return PropFeather; }
358 
362  std::string GetComponentStrings(const std::string& delimiter) const;
363 
368  std::string GetComponentValues(const std::string& delimiter) const;
369 
371 
372 
374  void SetDaCmd( double cmd ) { DaCmd = cmd; }
375 
378  void SetDeCmd(double cmd ) { DeCmd = cmd; }
379 
382  void SetDrCmd(double cmd) { DrCmd = cmd; }
383 
386  void SetDsCmd(double cmd) { fdmex->GetGroundReactions()->SetDsCmd( cmd ); }
387 
390  void SetDfCmd(double cmd) { DfCmd = cmd; }
391 
394  void SetDsbCmd(double cmd) { DsbCmd = cmd; }
395 
398  void SetDspCmd(double cmd) { DspCmd = cmd; }
399 
402  void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
403 
406  void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
407 
410  void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
411 
415  void SetThrottleCmd(int engine, double cmd);
416 
420  void SetMixtureCmd(int engine, double cmd);
421 
424  void SetGearCmd(double gearcmd) { GearCmd = gearcmd; }
425 
429  void SetPropAdvanceCmd(int engine, double cmd);
430 
434  void SetFeatherCmd(int engine, bool cmd);
436 
438 
439 
441  void SetDaLPos( int form , double pos );
442 
445  void SetDaRPos( int form , double pos );
446 
449  void SetDePos( int form , double pos );
450 
453  void SetDrPos( int form , double pos );
454 
457  void SetDfPos( int form , double pos );
458 
461  void SetDsbPos( int form , double pos );
462 
465  void SetDspPos( int form , double pos );
466 
470  void SetThrottlePos(int engine, double cmd);
471 
475  void SetMixturePos(int engine, double cmd);
476 
479  void SetGearPos(double gearpos) { GearPos = gearpos; }
480 
483  void SetTailhookPos(double hookpos) { TailhookPos = hookpos; }
484 
487  void SetWingFoldPos(double foldpos) { WingFoldPos = foldpos; }
488 
492  void SetPropAdvance(int engine, double cmd);
493 
497  void SetPropFeather(int engine, bool cmd);
499 
501 
502 
504  void SetLBrake(double cmd) {BrakePos[FGLGear::bgLeft] = cmd;}
505 
508  void SetRBrake(double cmd) {BrakePos[FGLGear::bgRight] = cmd;}
509 
512  void SetCBrake(double cmd) {BrakePos[FGLGear::bgCenter] = cmd;}
513 
517  double GetBrake(FGLGear::BrakeGroup bg);
518 
519  const std::vector<double>& GetBrakePos() const {return BrakePos;}
520 
523  double GetLBrake(void) const {return BrakePos[FGLGear::bgLeft];}
524 
527  double GetRBrake(void) const {return BrakePos[FGLGear::bgRight];}
528 
531  double GetCBrake(void) const {return BrakePos[FGLGear::bgCenter];}
533 
534  enum SystemType { stFCS, stSystem, stAutoPilot };
535 
540  bool Load(Element* el) override;
541 
542  SGPath FindFullPathName(const SGPath& path) const override;
543 
544  void AddThrottle(void);
545  double GetDt(void) const;
546 
547  std::shared_ptr<FGPropertyManager> GetPropertyManager(void) { return PropertyManager; }
548 
549  bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
550  double GetChannelDeltaT(void) const { return GetDt() * ChannelRate; }
551 
552 private:
553  double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
554  double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms];
555  double DfPos[NForms], DsbPos[NForms], DspPos[NForms];
556  double PTrimCmd, YTrimCmd, RTrimCmd;
557  std::vector <double> ThrottleCmd;
558  std::vector <double> ThrottlePos;
559  std::vector <double> MixtureCmd;
560  std::vector <double> MixturePos;
561  std::vector <double> PropAdvanceCmd;
562  std::vector <double> PropAdvance;
563  std::vector <bool> PropFeatherCmd;
564  std::vector <bool> PropFeather;
565  //double LeftBrake, RightBrake, CenterBrake; // Brake settings
566  std::vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum
567  double GearCmd,GearPos;
568  double TailhookPos, WingFoldPos;
569  SystemType systype;
570  int ChannelRate;
571  FGFDMExec* fdmex;
572 
573  typedef std::vector <FGFCSChannel*> Channels;
574  Channels SystemChannels;
575  void bind(void);
576  void bindThrottle(unsigned int);
577  void Debug(int from) override;
578 };
579 }
580 
581 #endif
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:189
void SetPitchTrimCmd(double cmd)
Sets the pitch trim command.
Definition: FGFCS.h:402
void SetGearPos(double gearpos)
Set the gear extend/retract position, defaults to down.
Definition: FGFCS.h:479
double GetCBrake(void) const
Gets the center brake.
Definition: FGFCS.h:531
double GetLBrake(void) const
Gets the left brake.
Definition: FGFCS.h:523
double GetDfPos(int form=ofRad) const
Gets the flaps position.
Definition: FGFCS.h:315
void SetDsbCmd(double cmd)
Sets the speedbrake command.
Definition: FGFCS.h:394
bool GetFeatherCmd(int engine) const
Gets the prop feather command.
Definition: FGFCS.h:261
double GetDfCmd(void) const
Gets the flaps command.
Definition: FGFCS.h:229
double GetDeCmd(void) const
Gets the elevator command.
Definition: FGFCS.h:217
double GetDsCmd(void) const
Gets the steering command.
Definition: FGFCS.h:225
double GetTailhookPos(void) const
Gets the tailhook position (0 up, 1 down)
Definition: FGFCS.h:338
double GetPropAdvanceCmd(int engine) const
Gets the prop pitch command.
Definition: FGFCS.h:256
void SetDeCmd(double cmd)
Sets the elevator command.
Definition: FGFCS.h:378
double GetDePos(int form=ofRad) const
Gets the elevator position.
Definition: FGFCS.h:295
void SetDaCmd(double cmd)
Sets the aileron command.
Definition: FGFCS.h:374
double GetDsbPos(int form=ofRad) const
Gets the speedbrake position.
Definition: FGFCS.h:305
double GetRBrake(void) const
Gets the right brake.
Definition: FGFCS.h:527
void SetRBrake(double cmd)
Sets the right brake group.
Definition: FGFCS.h:508
void SetDrCmd(double cmd)
Sets the rudder command.
Definition: FGFCS.h:382
double GetDrCmd(void) const
Gets the rudder command.
Definition: FGFCS.h:221
double GetDaCmd(void) const
Gets the aileron command.
Definition: FGFCS.h:213
double GetDaLPos(int form=ofRad) const
Gets the left aileron position.
Definition: FGFCS.h:285
double GetMixtureCmd(int engine) const
Gets the mixture command.
Definition: FGFCS.h:249
double GetRollTrimCmd(void) const
Gets the aileron trim command.
Definition: FGFCS.h:273
double GetDaRPos(int form=ofRad) const
Gets the right aileron position.
Definition: FGFCS.h:290
void SetTailhookPos(double hookpos)
Set the tailhook position.
Definition: FGFCS.h:483
void SetDfCmd(double cmd)
Sets the flaps command.
Definition: FGFCS.h:390
void SetDsCmd(double cmd)
Sets the steering command.
Definition: FGFCS.h:386
double GetWingFoldPos(void) const
Gets the wing fold position (0 unfolded, 1 folded)
Definition: FGFCS.h:342
double GetDspCmd(void) const
Gets the spoiler command.
Definition: FGFCS.h:237
double GetPitchTrimCmd(void) const
Gets the pitch trim command.
Definition: FGFCS.h:265
double GetGearPos(void) const
Gets the gear position (0 up, 1 down), defaults to down.
Definition: FGFCS.h:334
bool GetPropFeather(int engine) const
Gets the prop feather position.
Definition: FGFCS.h:354
double GetDsbCmd(void) const
Gets the speedbrake command.
Definition: FGFCS.h:233
void SetDspCmd(double cmd)
Sets the spoilers command.
Definition: FGFCS.h:398
void SetLBrake(double cmd)
Sets the left brake group.
Definition: FGFCS.h:504
double GetPropAdvance(int engine) const
Gets the prop pitch position.
Definition: FGFCS.h:347
double GetDspPos(int form=ofRad) const
Gets the spoiler position.
Definition: FGFCS.h:310
void SetCBrake(double cmd)
Sets the center brake group.
Definition: FGFCS.h:512
double GetYawTrimCmd(void) const
Gets the rudder trim command.
Definition: FGFCS.h:269
void SetRollTrimCmd(double cmd)
Sets the aileron trim command.
Definition: FGFCS.h:410
void SetYawTrimCmd(double cmd)
Sets the rudder trim command.
Definition: FGFCS.h:406
double GetGearCmd(void) const
Get the gear extend/retract command.
Definition: FGFCS.h:278
double GetMixturePos(int engine) const
Gets the mixture position.
Definition: FGFCS.h:328
void SetWingFoldPos(double foldpos)
Set the wing fold position.
Definition: FGFCS.h:487
double GetDrPos(int form=ofRad) const
Gets the rudder position.
Definition: FGFCS.h:300
void SetGearCmd(double gearcmd)
Set the gear extend/retract command, defaults to down.
Definition: FGFCS.h:424
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:184
BrakeGroup
Brake grouping enumerators.
Definition: FGLGear.h:216
Base class for all scheduled JSBSim models.
Definition: FGModel.h:70