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