JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGTrimmer.h
1 /*
2  * FGTrimmer.h
3  * Copyright (C) James Goppert 2010 <james.goppert@gmail.com>
4  *
5  * FGTrimmer.h is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * FGTrimmer.h is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef JSBSim_FGTrimmer_H
20 #define JSBSim_FGTrimmer_H
21 
22 #include "math/FGNelderMead.h"
23 #include "FGFDMExec.h"
24 #include "models/FGInertial.h"
25 
26 namespace JSBSim
27 {
28 
30 {
31 public:
32  struct Constraints
33  {
34  Constraints() :
35  velocity(100), altitude(1000), gamma(0),
36  rollRate(0), pitchRate(0), yawRate(0),
37  coordinatedTurn(true), stabAxisRoll(true)
38  {
39  }
40  double velocity, altitude, gamma;
41  double rollRate, pitchRate, yawRate;
42  bool coordinatedTurn, stabAxisRoll;
43  };
44  FGTrimmer(FGFDMExec * fdm, Constraints * constraints);
45  ~FGTrimmer();
46  std::vector<double> constrain(const std::vector<double> & v);
47  void printSolution(std::ostream & stream, const std::vector<double> & v);
48  void printState(std::ostream & stream);
49  double compute_cost();
50  double eval(const std::vector<double> & v);
51  static void limit(double min, double max, double &val)
52  {
53  if (val<min) val=min;
54  else if (val>max) val=max;
55  }
56  void setFdm(FGFDMExec * fdm) {m_fdm = fdm; }
57 private:
58  FGFDMExec * m_fdm;
59  Constraints * m_constraints;
60 };
61 
62 } // JSBSim
63 
64 #endif
65 
66 // vim:ts=4:sw=4
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189