JSBSim Flight Dynamics Model  1.0 (02 March 2017)
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 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 #define ID_FCS "$Id: FGFCS.h,v 1.54 2017/02/25 14:23:18 bcoconni Exp $"
54 
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 
59 namespace JSBSim {
60 
61 class FGFCSChannel;
62 typedef enum { ofRad=0, ofDeg, ofNorm, ofMag , NForms} OutputForm;
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
189 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 CLASS DECLARATION
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
192 
193 class FGFCS : public FGModel
194 {
195 
196 public:
199  FGFCS(FGFDMExec*);
201  ~FGFCS();
202 
203  bool InitModel(void);
204 
212  bool Run(bool Holding);
213 
215 
216 
218  double GetDaCmd(void) const { return DaCmd; }
219 
222  double GetDeCmd(void) const { return DeCmd; }
223 
226  double GetDrCmd(void) const { return DrCmd; }
227 
230  double GetDsCmd(void) const { return fdmex->GetGroundReactions()->GetDsCmd(); }
231 
234  double GetDfCmd(void) const { return DfCmd; }
235 
238  double GetDsbCmd(void) const { return DsbCmd; }
239 
242  double GetDspCmd(void) const { return DspCmd; }
243 
247  double GetThrottleCmd(int engine) const;
248 
249  const std::vector<double>& GetThrottleCmd() const {return ThrottleCmd;}
250 
254  double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
255 
256  const std::vector<double>& GetMixtureCmd() const {return MixtureCmd;}
257 
261  double GetPropAdvanceCmd(int engine) const { return PropAdvanceCmd[engine]; }
262 
266  bool GetFeatherCmd(int engine) const { return PropFeatherCmd[engine]; }
267 
270  double GetPitchTrimCmd(void) const { return PTrimCmd; }
271 
274  double GetYawTrimCmd(void) const { return YTrimCmd; }
275 
278  double GetRollTrimCmd(void) const { return RTrimCmd; }
279 
283  double GetGearCmd(void) const { return GearCmd; }
285 
287 
288 
290  double GetDaLPos( int form = ofRad )
291  const { return DaLPos[form]; }
292 
295  double GetDaRPos( int form = ofRad )
296  const { return DaRPos[form]; }
297 
300  double GetDePos( int form = ofRad )
301  const { return DePos[form]; }
302 
305  double GetDrPos( int form = ofRad )
306  const { return DrPos[form]; }
307 
310  double GetDsbPos( int form = ofRad )
311  const { return DsbPos[form]; }
312 
315  double GetDspPos( int form = ofRad )
316  const { return DspPos[form]; }
317 
320  double GetDfPos( int form = ofRad )
321  const { return DfPos[form]; }
322 
326  double GetThrottlePos(int engine) const;
327 
328  const std::vector<double>& GetThrottlePos() const {return ThrottlePos;}
329 
333  double GetMixturePos(int engine) const { return MixturePos[engine]; }
334 
335  const std::vector<double>& GetMixturePos() const {return MixturePos;}
336 
339  double GetGearPos(void) const { return GearPos; }
340 
343  double GetTailhookPos(void) const { return TailhookPos; }
344 
347  double GetWingFoldPos(void) const { return WingFoldPos; }
348 
352  double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
353 
354  const std::vector<double>& GetPropAdvance() const { return PropAdvance; }
355 
359  bool GetPropFeather(int engine) const { return PropFeather[engine]; }
360 
361  const std::vector<bool>& GetPropFeather() const { return PropFeather; }
363 
367  std::string GetComponentStrings(const std::string& delimiter) const;
368 
373  std::string GetComponentValues(const std::string& delimiter) const;
374 
376 
377 
379  void SetDaCmd( double cmd ) { DaCmd = cmd; }
380 
383  void SetDeCmd(double cmd ) { DeCmd = cmd; }
384 
387  void SetDrCmd(double cmd) { DrCmd = cmd; }
388 
391  void SetDsCmd(double cmd) { fdmex->GetGroundReactions()->SetDsCmd( cmd ); }
392 
395  void SetDfCmd(double cmd) { DfCmd = cmd; }
396 
399  void SetDsbCmd(double cmd) { DsbCmd = cmd; }
400 
403  void SetDspCmd(double cmd) { DspCmd = cmd; }
404 
407  void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
408 
411  void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
412 
415  void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
416 
420  void SetThrottleCmd(int engine, double cmd);
421 
425  void SetMixtureCmd(int engine, double cmd);
426 
429  void SetGearCmd(double gearcmd) { GearCmd = gearcmd; }
430 
434  void SetPropAdvanceCmd(int engine, double cmd);
435 
439  void SetFeatherCmd(int engine, bool cmd);
441 
443 
444 
446  void SetDaLPos( int form , double pos );
447 
450  void SetDaRPos( int form , double pos );
451 
454  void SetDePos( int form , double pos );
455 
458  void SetDrPos( int form , double pos );
459 
462  void SetDfPos( int form , double pos );
463 
466  void SetDsbPos( int form , double pos );
467 
470  void SetDspPos( int form , double pos );
471 
475  void SetThrottlePos(int engine, double cmd);
476 
480  void SetMixturePos(int engine, double cmd);
481 
484  void SetGearPos(double gearpos) { GearPos = gearpos; }
485 
488  void SetTailhookPos(double hookpos) { TailhookPos = hookpos; }
489 
492  void SetWingFoldPos(double foldpos) { WingFoldPos = foldpos; }
493 
497  void SetPropAdvance(int engine, double cmd);
498 
502  void SetPropFeather(int engine, bool cmd);
504 
506 
507 
509  void SetLBrake(double cmd) {BrakePos[FGLGear::bgLeft] = cmd;}
510 
513  void SetRBrake(double cmd) {BrakePos[FGLGear::bgRight] = cmd;}
514 
517  void SetCBrake(double cmd) {BrakePos[FGLGear::bgCenter] = cmd;}
518 
522  double GetBrake(FGLGear::BrakeGroup bg);
523 
524  const std::vector<double>& GetBrakePos() const {return BrakePos;}
525 
528  double GetLBrake(void) const {return BrakePos[FGLGear::bgLeft];}
529 
532  double GetRBrake(void) const {return BrakePos[FGLGear::bgRight];}
533 
536  double GetCBrake(void) const {return BrakePos[FGLGear::bgCenter];}
538 
539  enum SystemType { stFCS, stSystem, stAutoPilot };
540 
545  bool Load(Element* el);
546 
547  SGPath FindFullPathName(const SGPath& path) const;
548 
549  void AddThrottle(void);
550  double GetDt(void) const;
551 
552  FGPropertyManager* GetPropertyManager(void) { return PropertyManager; }
553 
554  bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
555  double GetChannelDeltaT(void) const { return GetDt() * ChannelRate; }
556 
557 private:
558  double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
559  double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms];
560  double DfPos[NForms], DsbPos[NForms], DspPos[NForms];
561  double PTrimCmd, YTrimCmd, RTrimCmd;
562  std::vector <double> ThrottleCmd;
563  std::vector <double> ThrottlePos;
564  std::vector <double> MixtureCmd;
565  std::vector <double> MixturePos;
566  std::vector <double> PropAdvanceCmd;
567  std::vector <double> PropAdvance;
568  std::vector <bool> PropFeatherCmd;
569  std::vector <bool> PropFeather;
570  //double LeftBrake, RightBrake, CenterBrake; // Brake settings
571  std::vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum
572  double GearCmd,GearPos;
573  double TailhookPos, WingFoldPos;
574  SystemType systype;
575  int ChannelRate;
576  FGFDMExec* fdmex;
577 
578  typedef std::vector <FGFCSChannel*> Channels;
579  Channels SystemChannels;
580  void bind(void);
581  void bindThrottle(unsigned int);
582  void Debug(int from);
583 };
584 }
585 
586 #endif
587 
void SetDePos(int form, double pos)
Sets the elevator position.
Definition: FGFCS.cpp:228
double GetDsCmd(void) const
Gets the steering command.
Definition: FGFCS.h:230
void SetDsbCmd(double cmd)
Sets the speedbrake command.
Definition: FGFCS.h:399
double GetRBrake(void) const
Gets the right brake.
Definition: FGFCS.h:532
void SetRollTrimCmd(double cmd)
Sets the aileron trim command.
Definition: FGFCS.h:415
double GetDsbCmd(void) const
Gets the speedbrake command.
Definition: FGFCS.h:238
double GetDfPos(int form=ofRad) const
Gets the flaps position.
Definition: FGFCS.h:320
double GetDeCmd(void) const
Gets the elevator command.
Definition: FGFCS.h:222
void SetLBrake(double cmd)
Sets the left brake group.
Definition: FGFCS.h:509
double GetDePos(int form=ofRad) const
Gets the elevator position.
Definition: FGFCS.h:300
double GetDfCmd(void) const
Gets the flaps command.
Definition: FGFCS.h:234
void SetPropAdvanceCmd(int engine, double cmd)
Sets the propeller pitch command for the specified engine.
Definition: FGFCS.cpp:423
void SetDrPos(int form, double pos)
Sets the rudder position.
Definition: FGFCS.cpp:247
double GetDaLPos(int form=ofRad) const
Gets the left aileron position.
Definition: FGFCS.h:290
void SetDspPos(int form, double pos)
Sets the spoiler position.
Definition: FGFCS.cpp:304
BrakeGroup
Brake grouping enumerators.
Definition: FGLGear.h:219
void SetRBrake(double cmd)
Sets the right brake group.
Definition: FGFCS.h:513
double GetRollTrimCmd(void) const
Gets the aileron trim command.
Definition: FGFCS.h:278
void SetDsbPos(int form, double pos)
Sets the speedbrake position.
Definition: FGFCS.cpp:285
double GetThrottlePos(int engine) const
Gets the throttle position.
Definition: FGFCS.cpp:377
double GetMixtureCmd(int engine) const
Gets the mixture command.
Definition: FGFCS.h:254
void SetDsCmd(double cmd)
Sets the steering command.
void SetPropFeather(int engine, bool cmd)
Sets the actual prop feather setting for the specified engine.
Definition: FGFCS.cpp:465
void SetThrottleCmd(int engine, double cmd)
Sets the throttle command for the specified engine.
Definition: FGFCS.cpp:323
void SetDaCmd(double cmd)
Sets the aileron command.
Definition: FGFCS.h:379
bool Run(bool Holding)
Runs the Flight Controls model; called by the Executive Can pass in a value indicating if the executi...
Definition: FGFCS.cpp:161
void SetDaRPos(int form, double pos)
Sets the right aileron position.
Definition: FGFCS.cpp:209
void SetDfPos(int form, double pos)
Sets the flaps position.
Definition: FGFCS.cpp:266
void SetPitchTrimCmd(double cmd)
Sets the pitch trim command.
Definition: FGFCS.h:407
double GetCBrake(void) const
Gets the center brake.
Definition: FGFCS.h:536
FGFCS(FGFDMExec *)
Constructor.
Definition: FGFCS.cpp:80
double GetMixturePos(int engine) const
Gets the mixture position.
Definition: FGFCS.h:333
~FGFCS()
Destructor.
Definition: FGFCS.cpp:104
double GetPitchTrimCmd(void) const
Gets the pitch trim command.
Definition: FGFCS.h:270
double GetPropAdvance(int engine) const
Gets the prop pitch position.
Definition: FGFCS.h:352
void SetDaLPos(int form, double pos)
Sets the left aileron position.
Definition: FGFCS.cpp:190
double GetThrottleCmd(int engine) const
Gets the throttle command.
Definition: FGFCS.cpp:359
bool GetPropFeather(int engine) const
Gets the prop feather position.
Definition: FGFCS.h:359
void SetYawTrimCmd(double cmd)
Sets the rudder trim command.
Definition: FGFCS.h:411
bool GetFeatherCmd(int engine) const
Gets the prop feather command.
Definition: FGFCS.h:266
void SetCBrake(double cmd)
Sets the center brake group.
Definition: FGFCS.h:517
void SetDspCmd(double cmd)
Sets the spoilers command.
Definition: FGFCS.h:403
FGGroundReactions * GetGroundReactions(void)
Returns the FGGroundReactions pointer.
Definition: FGFDMExec.h:361
std::string GetComponentValues(const std::string &delimiter) const
Retrieves all component outputs for inclusion in output stream.
Definition: FGFCS.cpp:641
Base class for all scheduled JSBSim models.
Definition: FGModel.h:74
void SetDrCmd(double cmd)
Sets the rudder command.
Definition: FGFCS.h:387
double GetDsbPos(int form=ofRad) const
Gets the speedbrake position.
Definition: FGFCS.h:310
double GetYawTrimCmd(void) const
Gets the rudder trim command.
Definition: FGFCS.h:274
void SetDeCmd(double cmd)
Sets the elevator command.
Definition: FGFCS.h:383
std::string GetComponentStrings(const std::string &delimiter) const
Retrieves all component names for inclusion in output stream.
Definition: FGFCS.cpp:618
void SetGearPos(double gearpos)
Set the gear extend/retract position, defaults to down.
Definition: FGFCS.h:484
void SetMixturePos(int engine, double cmd)
Sets the actual mixture setting for the specified engine.
Definition: FGFCS.cpp:409
bool Load(Element *el)
Loads the Flight Control System.
Definition: FGFCS.cpp:479
void SetTailhookPos(double hookpos)
Set the tailhook position.
Definition: FGFCS.h:488
double GetDaCmd(void) const
Gets the aileron command.
Definition: FGFCS.h:218
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:193
double GetGearCmd(void) const
Get the gear extend/retract command.
Definition: FGFCS.h:283
void SetDfCmd(double cmd)
Sets the flaps command.
Definition: FGFCS.h:395
void SetWingFoldPos(double foldpos)
Set the wing fold position.
Definition: FGFCS.h:492
double GetPropAdvanceCmd(int engine) const
Gets the prop pitch command.
Definition: FGFCS.h:261
void SetThrottlePos(int engine, double cmd)
Sets the actual throttle setting for the specified engine.
Definition: FGFCS.cpp:341
void SetPropAdvance(int engine, double cmd)
Sets the actual prop pitch setting for the specified engine.
Definition: FGFCS.cpp:437
void SetMixtureCmd(int engine, double cmd)
Sets the mixture command for the specified engine.
Definition: FGFCS.cpp:395
double GetDspPos(int form=ofRad) const
Gets the spoiler position.
Definition: FGFCS.h:315
double GetGearPos(void) const
Gets the gear position (0 up, 1 down), defaults to down.
Definition: FGFCS.h:339
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
double GetDsCmd(void) const
Gets the steering command.
double GetBrake(FGLGear::BrakeGroup bg)
Gets the brake for a specified group.
Definition: FGFCS.cpp:598
double GetDspCmd(void) const
Gets the spoiler command.
Definition: FGFCS.h:242
double GetLBrake(void) const
Gets the left brake.
Definition: FGFCS.h:528
double GetDrCmd(void) const
Gets the rudder command.
Definition: FGFCS.h:226
void SetGearCmd(double gearcmd)
Set the gear extend/retract command, defaults to down.
Definition: FGFCS.h:429
void SetFeatherCmd(int engine, bool cmd)
Sets the propeller feather command for the specified engine.
Definition: FGFCS.cpp:451
void SetDsCmd(double cmd)
Sets the steering command.
Definition: FGFCS.h:391
double GetDaRPos(int form=ofRad) const
Gets the right aileron position.
Definition: FGFCS.h:295
double GetTailhookPos(void) const
Gets the tailhook position (0 up, 1 down)
Definition: FGFCS.h:343
double GetWingFoldPos(void) const
Gets the wing fold position (0 unfolded, 1 folded)
Definition: FGFCS.h:347
double GetDrPos(int form=ofRad) const
Gets the rudder position.
Definition: FGFCS.h:305