]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Rotor.hpp
Maik: add ROTORELTARGET and ROTORENGINEMAXRELTORQUE input axes
[flightgear.git] / src / FDM / YASim / Rotor.hpp
1 #ifndef _ROTOR_HPP
2 #define _ROTOR_HPP
3
4 #include "Vector.hpp"
5 #include "Rotorpart.hpp"
6 #include "Integrator.hpp"
7 #include "RigidBody.hpp"
8 #include "BodyEnvironment.hpp"
9
10 namespace yasim {
11
12 class Surface;
13 class Rotorpart;
14 class Ground;
15 const float rho_null=1.184f; //25DegC, 101325Pa
16
17 class Rotor {
18     friend std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
19 private:
20     float _torque;
21     float _omega,_omegan,_omegarel,_ddt_omega,_omegarelneu;
22     float _phi_null;
23     float _chord;
24     float _taper;
25     float _airfoil_incidence_no_lift;
26     float _collective;
27     float _airfoil_lift_coefficient;
28     float _airfoil_drag_coefficient0;
29     float _airfoil_drag_coefficient1;
30     int _ccw;
31     int _number_of_blades;
32     int _number_of_segments;
33     int _number_of_parts;
34     float _balance1;
35     float _balance2;
36
37 public:
38     Rotor();
39     ~Rotor();
40
41     // Rotor geometry:
42     void setNormal(float* normal);
43     //the normal vector (direction of rotormast, pointing up)
44
45     void setForward(float* forward);
46     //the normal vector pointing forward (for ele and ail)
47     void setForceAtPitchA(float force);
48     void setPowerAtPitch0(float value);
49     void setPowerAtPitchB(float value);
50     void setNotorque(int value);
51     void setPitchA(float value);
52     void setPitchB(float value);
53     void setMinCyclicail(float value);
54     void setMinCyclicele(float value);
55     void setMaxCyclicail(float value);
56     void setMaxCyclicele(float value);
57     void setMaxCollective(float value);
58     void setMinCollective(float value);
59     void setDiameter(float value);
60     void setWeightPerBlade(float value);
61     void setNumberOfBlades(float value);
62     void setRelBladeCenter(float value);
63     void setDelta3(float value);
64     void setDelta(float value);
65     void setDynamic(float value);
66     void setTranslift(float value);
67     void setC2(float value);
68     void setStepspersecond(float steps);
69     void setRPM(float value);
70     void setPhiNull(float value);
71     void setRelLenHinge(float value);
72     void setBase(float* base);        // in local coordinates
73     void getPosition(float* out);
74     void setCyclicail(float lval,float rval);
75     void setCyclicele(float lval,float rval);
76     void setCollective(float lval);
77     void setAlphaoutput(int i, const char *text);
78     void setCcw(int ccw);
79     int getCcw() {return _ccw;};
80     void setParameter(char *parametername, float value);
81     void setGlobalGround(double* global_ground, float* global_vel);
82     float getTorqueOfInertia();
83     int getValueforFGSet(int j,char *b,float *f);
84     void setName(const char *text);
85     void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot);
86     void compile();
87     void getTip(float* tip);
88     void calcLiftFactor(float* v, float rho, State *s);
89     void getDownWash(float *pos, float * v_heli, float *downwash);
90     int getNumberOfBlades(){return _number_of_blades;}
91
92     // Query the list of Rotorpart objects
93     int numRotorparts();
94     Rotorpart* getRotorpart(int n);
95     void setAlpha0(float f);
96     void setAlphamin(float f);
97     void setAlphamax(float f);
98     void setTeeterdamp(float f);
99     void setMaxteeterdamp(float f);
100     void setRelLenTeeterHinge(float value);
101     void setAlpha0factor(float f);
102     void setTorque(float f);
103     void addTorque(float f);
104     float getTorque() {return _torque;}
105     float getLiftFactor();
106     float getLiftCoef(float incidence,float speed);
107     float getDragCoef(float incidence,float speed);
108     float getOmegaRel() {return _omegarel;}
109     float getOmegaRelNeu() {return _omegarelneu;}
110     void setOmegaRelNeu(float orn) {_omegarelneu=orn;}
111     float getOmegan() {return _omegan;}
112     float getTaper() { return _taper;}
113     float getChord() { return _chord;}
114     int getNumberOfParts() { return _number_of_parts;}
115     float getOverallStall() 
116         {if (_stall_v2sum !=0 ) return _stall_sum/_stall_v2sum; else return 0;}
117     float getAirfoilIncidenceNoLift() {return _airfoil_incidence_no_lift;}
118     Vector _rotorparts;
119     void findGroundEffectAltitude(Ground * ground_cb,State *s);
120     float *getGravDirection() {return _grav_direction;}
121     void writeInfo();
122     void setSharedFlapHinge(bool s);
123     void setBalance(float b);
124     float getBalance(){ return (_balance1>0)?_balance1*_balance2:_balance1;}
125
126 private:
127     void testForRotorGroundContact (Ground * ground_cb,State *s);
128     void strncpy(char *dest,const char *src,int maxlen);
129     void interp(float* v1, float* v2, float frac, float* out);
130     float calcStall(float incidence,float speed);
131     float findGroundEffectAltitude(Ground * ground_cb,State *s,
132         float *pos0,float *pos1,float *pos2,float *pos3,
133         int iteration=0,float a0=-1,float a1=-1,float a2=-1,float a3=-1);
134     Rotorpart* newRotorpart(float* pos, float *posforceattac, float *normal,
135         float* speed,float *dirzentforce, float zentforce,float maxpitchforce,
136         float delta3,float mass,float translift,float rellenhinge,float len);
137     float _base[3];
138     float _groundeffectpos[4][3];
139     float _ground_contact_pos[16][3];
140     int _num_ground_contact_pos;
141     float _ground_effect_altitude;
142     //some postions, where to calcualte the ground effect
143     float _normal[3];//the normal vector (direction of rotormast, pointing up)
144     float _normal_with_yaw_roll[3];//the normal vector (perpendicular to rotordisc)
145     float _forward[3];
146     float _diameter;
147     float _weight_per_blade;
148     float _rel_blade_center;
149     float _min_pitch;
150     float _max_pitch;
151     float _force_at_pitch_a;
152     float _pitch_a;
153     float _power_at_pitch_0;
154     float _power_at_pitch_b;
155     int _no_torque;
156     int _sim_blades;
157     float _pitch_b;
158     float _rotor_rpm;
159     float _rel_len_hinge;
160     float _maxcyclicail;
161     float _maxcyclicele;
162     float _mincyclicail;
163     float _mincyclicele;
164     float _delta3;
165     float _delta;
166     float _dynamic;
167     float _translift;
168     float _c2;
169     float _stepspersecond;
170     char _alphaoutput[8][256];
171     char _name[256];
172     int _engineon;
173     float _alphamin,_alphamax,_alpha0,_alpha0factor;
174     float _teeterdamp,_maxteeterdamp;
175     float _rellenteeterhinge;
176     float _translift_ve;
177     float _translift_maxfactor;
178     float _ground_effect_constant;
179     float _vortex_state_lift_factor;
180     float _vortex_state_c1;
181     float _vortex_state_c2;
182     float _vortex_state_c3;
183     float _vortex_state_e1;
184     float _vortex_state_e2;
185     float _vortex_state_e3;
186     float _lift_factor,_f_ge,_f_vs,_f_tl;
187     float _vortex_state;
188     double _global_ground[4];
189     float _liftcoef;
190     float _dragcoef0;
191     float _dragcoef1;
192     float _twist; //outer incidence = inner inner incidence + _twist
193     float _rel_len_where_incidence_is_measured;
194     float _torque_of_inertia;
195     float _rel_len_blade_start;
196     float _incidence_stall_zero_speed;
197     float _incidence_stall_half_sonic_speed;
198     float _lift_factor_stall;
199     float _stall_change_over;
200     float _drag_factor_stall;
201     float _stall_sum;
202     float _stall_v2sum;
203     float _yaw;
204     float _roll;
205     float _cyclicail;
206     float _cyclicele;
207     float _cyclic_factor;
208     float _rotor_correction_factor;
209     float _phi;
210     bool _shared_flap_hinge;
211     float _grav_direction[3];
212     int _properties_tied;
213 };
214 std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
215
216 class Rotorgear {
217 private:
218     int _in_use;
219     int _engineon;
220     float _max_power_engine;
221     float _engine_prop_factor;
222     float _yasimdragfactor;
223     float _yasimliftfactor;
224     float _rotorbrake;
225     float _max_power_rotor_brake;
226     float _rotorgear_friction;
227     float _ddt_omegarel;
228     float _engine_accel_limit;
229     float _total_torque_on_engine;
230     Vector _rotors;
231
232 public:
233     Rotorgear();
234     ~Rotorgear();
235     int isInUse() {return _in_use;}
236     void setInUse() {_in_use = 1;}
237     void compile();
238     void addRotor(Rotor* rotor);
239     int getNumRotors() {return _rotors.size();}
240     Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
241     void calcForces(float* torqueOut);
242     void setParameter(char *parametername, float value);
243     void setEngineOn(int value);
244     int getEngineon();
245     void setRotorBrake(float lval);
246     void setRotorEngineMaxRelTorque(float lval);
247     void setRotorRelTarget(float lval);
248     float getYasimDragFactor() { return _yasimdragfactor;}
249     float getYasimLiftFactor() { return _yasimliftfactor;}
250     float getMaxPowerEngine() { return _max_power_engine;}
251     float getMaxPowerRotorBrake() { return _max_power_rotor_brake;}
252     float getRotorBrake() { return _rotorbrake;}
253     float getEnginePropFactor() {return _engine_prop_factor;}
254     Vector* getRotors() { return &_rotors;}
255     void initRotorIteration(float *lrot,float dt);
256     void getDownWash(float *pos, float * v_heli, float *downwash);
257     int getValueforFGSet(int j,char *b,float *f);
258 };
259
260 }; // namespace yasim
261 #endif // _ROTOR_HPP