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