]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Gear.hpp
Use SG_LOG for debugging messages from the YASim helicopter model.
[flightgear.git] / src / FDM / YASim / Gear.hpp
1 #ifndef _GEAR_HPP
2 #define _GEAR_HPP
3
4 namespace yasim {
5
6 class RigidBody;
7
8 // A landing gear has the following parameters:
9 //
10 // position: a point in the aircraft's local coordinate system where the
11 //     fully-extended wheel will be found.
12 // compression: a vector from position where a fully-compressed wheel
13 //     will be, also in aircraft-local coordinates.
14 // spring coefficient: force coefficient along the compression axis, in
15 //     Newtons per meter.
16 // damping coefficient: force per compression speed, in Ns/m
17 // static coefficient of friction: force along the ground plane exerted
18 //     by a motionless wheel.  A unitless scalar.
19 // dynamic coefficient of friction: force along the ground plane exerted
20 //     by a sliding/skidding wheel.
21 // braking fraction: fraction of the dynamic friction that will be
22 //     actually exerted by a rolling wheel
23 // rotation: the angle from "forward" by which the wheel is rotated
24 //     around its compression axis.  In radians.
25 //
26 class Gear {
27 public:
28     Gear();
29
30     // Externally set values
31     void setPosition(float* position);
32     void setCompression(float* compression);
33     void setSpring(float spring);
34     void setDamping(float damping);
35     void setStaticFriction(float sfric);
36     void setDynamicFriction(float dfric);
37     void setBrake(float brake);
38     void setRotation(float rotation);
39     void setExtension(float extension);
40     void setCastering(bool castering);
41
42     void getPosition(float* out);
43     void getCompression(float* out);
44     float getSpring();
45     float getDamping();
46     float getStaticFriction();
47     float getDynamicFriction();
48     float getBrake();
49     float getRotation();
50     float getExtension();
51     bool getCastering();
52
53     // Takes a velocity of the aircraft relative to ground, a rotation
54     // vector, and a ground plane (all specified in local coordinates)
55     // and make a force and point of application (i.e. ground contact)
56     // available via getForce().
57     void calcForce(RigidBody* body, float* v, float* rot, float* ground);
58
59     // Computed values: total force, weight-on-wheels (force normal to
60     // ground) and compression fraction.
61     void getForce(float* force, float* contact);
62     float getWoW();
63     float getCompressFraction();
64
65 private:
66     float calcFriction(float wgt, float v);
67
68     bool _castering;
69     float _pos[3];
70     float _cmpr[3];
71     float _spring;
72     float _damp;
73     float _sfric;
74     float _dfric;
75     float _brake;
76     float _rot;
77     float _extension;
78     float _force[3];
79     float _contact[3];
80     float _wow;
81     float _frac;
82 };
83
84 }; // namespace yasim
85 #endif // _GEAR_HPP