| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGKinemat.h |
| 4 | Author: Tony Peden, for flight control system authored by Jon S. Berndt |
| 5 | Date started: 12/02/01 |
| 6 | |
| 7 | ------------- Copyright (C) Anthony K. Peden ------------- |
| 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 |
| 11 | Software Foundation; either version 2 of the License, or (at your option) any |
| 12 | later 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 |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., 59 |
| 21 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | |
| 23 | Further information about the GNU Lesser General Public License can also be |
| 24 | found on the world wide web at http://www.gnu.org. |
| 25 | |
| 26 | HISTORY |
| 27 | -------------------------------------------------------------------------------- |
| 28 | |
| 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 30 | SENTRY |
| 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 32 | |
| 33 | #ifndef FGKinemat_H |
| 34 | #define FGKinemat_H |
| 35 | |
| 36 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 | INCLUDES |
| 38 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 39 | |
| 40 | #include "FGFCSComponent.h" |
| 41 | |
| 42 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 43 | FORWARD DECLARATIONS |
| 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 45 | |
| 46 | namespace JSBSim { |
| 47 | |
| 48 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 49 | CLASS DOCUMENTATION |
| 50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 51 | |
| 52 | /** Encapsulates a kinematic (mechanical) component for the flight control |
| 53 | system. This component models the action of a moving effector, such as an |
| 54 | aerosurface or other mechanized entity such as a landing gear strut for the |
| 55 | purpose of effecting vehicle control or configuration. The form of the component |
| 56 | specification is: |
| 57 | |
| 58 | @code |
| 59 | <kinematic name="Gear Control"> |
| 60 | <input> [-]property </input> |
| 61 | [<noscale/>] |
| 62 | <traverse> |
| 63 | <setting> |
| 64 | <position> number </position> |
| 65 | <time> number </time> |
| 66 | </setting> |
| 67 | ... |
| 68 | </traverse> |
| 69 | [<clipto> |
| 70 | <min> {[-]property name | value} </min> |
| 71 | <max> {[-]property name | value} </max> |
| 72 | </clipto>] |
| 73 | [<gain> {property name | value} </gain>] |
| 74 | [<output> {property} </output>] |
| 75 | </kinematic> |
| 76 | @endcode |
| 77 | |
| 78 | The detent is the position that the component takes, and the lag is the time it |
| 79 | takes to get to that position from an adjacent setting. For example: |
| 80 | |
| 81 | @code |
| 82 | <kinematic name="Gear Control"> |
| 83 | <input>gear/gear-cmd-norm</input> |
| 84 | <traverse> |
| 85 | <setting> |
| 86 | <position>0</position> |
| 87 | <time>0</time> |
| 88 | </setting> |
| 89 | <setting> |
| 90 | <position>1</position> |
| 91 | <time>5</time> |
| 92 | </setting> |
| 93 | </traverse> |
| 94 | <output>gear/gear-pos-norm</output> |
| 95 | </kinematic> |
| 96 | @endcode |
| 97 | |
| 98 | In this case, it takes 5 seconds to get to a 1 setting. As this is a software |
| 99 | mechanization of a servo-actuator, there should be an output specified. |
| 100 | |
| 101 | Positions must be given in ascending order. |
| 102 | |
| 103 | By default, the input is assumed to be in the range [-1;1] and is scaled to the |
| 104 | value specified in the last <position> tag. This behavior can be modified by |
| 105 | adding a <noscale/> tag to the component definition: in that case, the input |
| 106 | value is directly used to determine the current position of the component. |
| 107 | */ |
| 108 | |
| 109 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 110 | CLASS DECLARATION |
| 111 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 112 | |
| 113 | class FGKinemat : public FGFCSComponent { |
| 114 | public: |
| 115 | /** Constructor. |
| 116 | @param fcs A reference to the current flight control system. |
| 117 | @param element reference to the current configuration file node. |
| 118 | */ |
| 119 | FGKinemat(FGFCS* fcs, Element* element); |
| 120 | |
| 121 | /// Destructor. |
| 122 | ~FGKinemat(); |
| 123 | |
| 124 | /** Kinematic component output value. |
| 125 | @return the current output of the kinematic object on the range of [0,1]. */ |
| 126 | double GetOutputPct() const override |
| 127 | { return (Output-Detents[0])/(Detents.back()-Detents[0]); } |
| 128 | |
| 129 | /** Run method, overrides FGModel::Run(). |
| 130 | @return false on success, true on failure. |
| 131 | The routine doing the work. */ |
| 132 | bool Run (void) override; |
| 133 | |
| 134 | private: |
| 135 | std::vector<double> Detents; |
| 136 | std::vector<double> TransitionTimes; |
| 137 | bool DoScale; |
| 138 | |
| 139 | void Debug(int from) override; |
| 140 | }; |
| 141 | } |
| 142 | #endif |