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