43#include "FGTransmission.h"
56 FreeWheelTransmission(1.0),
57 ThrusterMoment(1.0), EngineMoment(1.0), EngineFriction(0.0),
58 ClutchCtrlNorm(1.0), BrakeCtrlNorm(0.0), MaxBrakePower(0.0),
59 EngineRPM(0.0), ThrusterRPM(0.0)
62 FreeWheelLag =
Filter(200.0,dt);
63 BindModel(num, PropertyManager.get());
75void FGTransmission::Calculate(
double EnginePower,
double ThrusterTorque,
double dt) {
77 double coupling = 1.0, coupling_sq = 1.0;
80 double d_omega = 0.0, engine_d_omega = 0.0, thruster_d_omega = 0.0;
82 double engine_omega = rpm_to_omega(EngineRPM);
83 double safe_engine_omega = engine_omega < 1e-1 ? 1e-1 : engine_omega;
84 double engine_torque = EnginePower / safe_engine_omega;
86 double thruster_omega = rpm_to_omega(ThrusterRPM);
87 double safe_thruster_omega = thruster_omega < 1e-1 ? 1e-1 : thruster_omega;
89 engine_torque -= EngineFriction / safe_engine_omega;
90 ThrusterTorque +=
Constrain(0.0, BrakeCtrlNorm, 1.0) * MaxBrakePower / safe_thruster_omega;
93 engine_d_omega = engine_torque/EngineMoment * dt;
94 thruster_d_omega = - ThrusterTorque/ThrusterMoment * dt;
96 if ( thruster_omega+thruster_d_omega > engine_omega+engine_d_omega ) {
98 FreeWheelTransmission = 0.0;
100 FreeWheelTransmission = 1.0;
103 fw_mult = FreeWheelLag.execute(FreeWheelTransmission);
104 coupling = fw_mult *
Constrain(0.0, ClutchCtrlNorm, 1.0);
106 if (coupling < 0.999999) {
109 (engine_torque - ThrusterTorque*coupling)/(ThrusterMoment*coupling + EngineMoment) * dt;
111 (engine_torque*coupling - ThrusterTorque)/(ThrusterMoment + EngineMoment*coupling) * dt;
113 EngineRPM += omega_to_rpm(engine_d_omega);
114 ThrusterRPM += omega_to_rpm(thruster_d_omega);
117 coupling_sq = coupling*coupling;
118 EngineRPM = (1.0-coupling_sq) * EngineRPM + coupling_sq * 0.02 * (49.0*EngineRPM + ThrusterRPM);
119 ThrusterRPM = (1.0-coupling_sq) * ThrusterRPM + coupling_sq * 0.02 * (EngineRPM + 49.0*ThrusterRPM);
122 if ( fabs(EngineRPM-ThrusterRPM) < 1e-3 ) {
123 EngineRPM = ThrusterRPM = 0.5 * (EngineRPM+ThrusterRPM);
126 d_omega = (engine_torque - ThrusterTorque)/(ThrusterMoment + EngineMoment) * dt;
127 EngineRPM = ThrusterRPM += omega_to_rpm(d_omega);
131 if (EngineRPM < 0.0 ) EngineRPM = 0.0;
132 if (ThrusterRPM < 0.0 ) ThrusterRPM = 0.0;
138bool FGTransmission::BindModel(
int num, FGPropertyManager* PropertyManager)
140 string property_name, base_property_name;
141 base_property_name = CreateIndexedPropertyName(
"propulsion/engine", num);
143 property_name = base_property_name +
"/brake-ctrl-norm";
144 PropertyManager->Tie( property_name.c_str(),
this,
145 &FGTransmission::GetBrakeCtrlNorm, &FGTransmission::SetBrakeCtrlNorm);
147 property_name = base_property_name +
"/clutch-ctrl-norm";
148 PropertyManager->Tie( property_name.c_str(),
this,
149 &FGTransmission::GetClutchCtrlNorm, &FGTransmission::SetClutchCtrlNorm);
151 property_name = base_property_name +
"/free-wheel-transmission";
152 PropertyManager->Tie( property_name.c_str(),
this,
153 &FGTransmission::GetFreeWheelTransmission);
177void FGTransmission::Debug(
int from)
179 if (debug_lvl <= 0)
return;
185 if (debug_lvl & 2 ) {
186 if (from == 0) cout <<
"Instantiated: FGTransmission" << endl;
187 if (from == 1) cout <<
"Destroyed: FGTransmission" << endl;
189 if (debug_lvl & 4 ) {
191 if (debug_lvl & 8 ) {
193 if (debug_lvl & 16) {
195 if (debug_lvl & 64) {
Encapsulates the JSBSim simulation executive.
std::shared_ptr< FGPropertyManager > GetPropertyManager(void) const
Returns a pointer to the property manager object.
First order, (low pass / lag) filter.
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
FGTransmission(FGFDMExec *exec, int num, double dt)
Constructor for FGTransmission.
~FGTransmission()
Destructor for FGTransmission.