YASim calculate max CG range (on x-axis) from gear positions, to implement checks later (a better guesstimate will follow).
This commit is contained in:
parent
e78a763eef
commit
dbf21b1ca8
3 changed files with 34 additions and 1 deletions
|
@ -57,6 +57,8 @@ Airplane::Airplane()
|
|||
|
||||
_failureMsg = 0;
|
||||
_wingsN = 0;
|
||||
_cgMaxX = -1e6;
|
||||
_cgMinX = 1e6;
|
||||
}
|
||||
|
||||
Airplane::~Airplane()
|
||||
|
@ -238,6 +240,10 @@ void Airplane::addGear(Gear* gear)
|
|||
g->gear = gear;
|
||||
g->surf = 0;
|
||||
_gears.add(g);
|
||||
float pos[3];
|
||||
g->gear->getPosition(pos);
|
||||
if (pos[0] > _cgMaxX) _cgMaxX = pos[0];
|
||||
if (pos[0] < _cgMinX) _cgMinX = pos[0];
|
||||
}
|
||||
|
||||
void Airplane::addThruster(Thruster* thruster, float mass, float* cg)
|
||||
|
@ -320,6 +326,14 @@ void Airplane::setupState(const float aoa, const float speed, const float gla, S
|
|||
s->pos[2] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief add contact point for crash detection
|
||||
* used to add wingtips and fuselage nose and tail
|
||||
*
|
||||
* @param pos ...
|
||||
* @return void
|
||||
*/
|
||||
|
||||
void Airplane::addContactPoint(float* pos)
|
||||
{
|
||||
ContactRec* c = new ContactRec;
|
||||
|
@ -522,6 +536,13 @@ void Airplane::compileGear(GearRec* gr)
|
|||
_surfs.add(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief add "fake gear" per contact point
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
void Airplane::compileContactPoints()
|
||||
{
|
||||
// Figure it will compress by 20cm
|
||||
|
|
|
@ -103,6 +103,9 @@ public:
|
|||
void loadApproachControls();
|
||||
void loadCruiseControls();
|
||||
|
||||
float getCGMinX() { return _cgMinX; }
|
||||
float getCGMaxX() { return _cgMaxX; }
|
||||
|
||||
private:
|
||||
struct Tank { float pos[3]; float cap; float fill;
|
||||
float density; int handle; };
|
||||
|
@ -182,6 +185,10 @@ private:
|
|||
float _tailIncidence;
|
||||
Control _approachElevator;
|
||||
const char* _failureMsg;
|
||||
|
||||
// hard limits for cg from gear positions
|
||||
float _cgMaxX;
|
||||
float _cgMinX;
|
||||
};
|
||||
|
||||
}; // namespace yasim
|
||||
|
|
|
@ -130,7 +130,12 @@ void FGFDM::init()
|
|||
// alias to older name
|
||||
fgGetNode("/yasim/gross-weight-lbs", true)->alias(_gross_weight_lbs);
|
||||
|
||||
// write some compile time information to property tree
|
||||
_yasimN->getNode("config-version",true)->setIntValue(_airplane.getVersion());
|
||||
_yasimN->getNode("model/cg-x-min",true)->setFloatValue(_airplane.getCGMinX());
|
||||
_yasimN->getNode("model/cg-x-max",true)->setFloatValue(_airplane.getCGMaxX());
|
||||
|
||||
// prepare nodes for write at runtime
|
||||
_cg_x = _yasimN->getNode("cg-x-m", true);
|
||||
_cg_y = _yasimN->getNode("cg-y-m", true);
|
||||
_cg_z = _yasimN->getNode("cg-z-m", true);
|
||||
|
|
Loading…
Reference in a new issue