From: <sv...@ww...> - 2007-07-31 06:08:42
|
Author: mkrose Date: 2007-07-30 23:07:30 -0700 (Mon, 30 Jul 2007) New Revision: 2159 Modified: trunk/csp/cspsim/AnimationSequence.cpp trunk/csp/cspsim/AnimationSequence.h trunk/csp/cspsim/LandingGear.cpp trunk/csp/data/xml/vehicles/aircraft/f16/gear.xml Log: Minor fixes to the landing gear simulation related to wheel hop and retraction animation. The main gear animation should work correctly, without discontinuities, when the gear is raised immediately after takeoff. Also increase the damping coeff. of the F16 main gear. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2159 Modified: trunk/csp/cspsim/AnimationSequence.cpp =================================================================== --- trunk/csp/cspsim/AnimationSequence.cpp 2007-07-30 06:43:48 UTC (rev 2158) +++ trunk/csp/cspsim/AnimationSequence.cpp 2007-07-31 06:07:30 UTC (rev 2159) @@ -91,12 +91,9 @@ update(); } -void SharedSequence::update(bool force) { - const double value = b_SequenceKey->value(); - if (force || (value >= m_InitialKey && value <= m_FinalKey)) { - if (b_NormalizedKey.valid()) b_NormalizedKey->value() = m_NormalizedKey; - b_SequenceKey->value() = m_SequenceKey; - } +void SharedSequence::update() { + if (b_NormalizedKey.valid()) b_NormalizedKey->value() = m_NormalizedKey; + b_SequenceKey->value() = m_SequenceKey; } CSP_NAMESPACE_END Modified: trunk/csp/cspsim/AnimationSequence.h =================================================================== --- trunk/csp/cspsim/AnimationSequence.h 2007-07-30 06:43:48 UTC (rev 2158) +++ trunk/csp/cspsim/AnimationSequence.h 2007-07-31 06:07:30 UTC (rev 2159) @@ -97,7 +97,7 @@ /** Activate this sequence. All other sequences sharing the output * channel will be disabled. */ - virtual void enable() { update(true); } + virtual void enable() { update(); } protected: typedef DataChannel<double>::RefT KeyChannel; @@ -109,7 +109,7 @@ void setSequenceKey(double key); private: - void update(bool force=false); + void update(); std::string m_SequenceChannel; std::string m_NormalizedChannel; Modified: trunk/csp/cspsim/LandingGear.cpp =================================================================== --- trunk/csp/cspsim/LandingGear.cpp 2007-07-30 06:43:48 UTC (rev 2158) +++ trunk/csp/cspsim/LandingGear.cpp 2007-07-31 06:07:30 UTC (rev 2159) @@ -284,16 +284,13 @@ Vector3 max_position = getMaxPosition(); if (motionNormal > 0.0) { compression = - (dot(max_position, normalGroundBody) + height) / motionNormal; + compression = std::max(compression, 0.0); } - // at (or past) max extension? - if (compression <= 0.0) { - // limit travel and clear weight-on-wheels (WOW) - double v_extend = (m_K * m_Compression) / m_Beta; - m_Compression = std::max(0.0, m_Compression - v_extend * dt); - m_Position = max_position; + // at max extension and not in contact? + if (compression == 0.0 && m_Compression == 0.0) { b_WOW->value() = false; - // no ground reaction force + m_Position = max_position; } else { // FIXME in computing vCompression, only the normal force is taken into // account, but other components can matter if m_Motion isn't vertical. @@ -322,22 +319,18 @@ m_Compression = compression; } - // update wheel position - m_Position = max_position + m_Motion * m_Compression; - - // determine reaction force - // ground support (in response to strut compression + damping) double normalForce = (m_K * compression + m_Beta * vCompression) * motionNormal; - if (normalForce < 0.0) { - normalForce = 0.0; // wheel hop - double v_extend = (m_K * old_compression) / m_Beta; + if (normalForce > 0.0) { + m_NormalForce += normalForce * normalGroundBody; + } else { + double v_extend = std::max(0.5, (m_K * m_Compression) / m_Beta); m_Compression = std::max(old_compression - v_extend * dt, 0.0); } - m_NormalForce += normalForce * normalGroundBody; - assert(!isNaN(normalForce)); - assert(normalGroundBody.valid()); + + // update wheel position + m_Position = max_position + m_Motion * m_Compression; } } @@ -396,7 +389,7 @@ void LandingGear::updateAnimation(double dt) { if (m_GearAnimation.valid()) { m_GearAnimation->update(dt); - m_GearAnimation->setCompression(m_Compression / m_CompressionLimit); + if (m_Compression > 0.0) m_GearAnimation->setCompression(m_Compression / m_CompressionLimit); m_GearAnimation->setTireRotation(fmod(m_TireRotation, 2.0*PI) - PI); if (m_SteeringLimit > 0.0) { m_GearAnimation->setSteeringAngle(toRadians(m_SteeringAngle)); Modified: trunk/csp/data/xml/vehicles/aircraft/f16/gear.xml =================================================================== --- trunk/csp/data/xml/vehicles/aircraft/f16/gear.xml 2007-07-30 06:43:48 UTC (rev 2158) +++ trunk/csp/data/xml/vehicles/aircraft/f16/gear.xml 2007-07-31 06:07:30 UTC (rev 2159) @@ -50,7 +50,7 @@ <!-- 0.191 --> <Float name="compression_limit">0.223</Float> <Float name="K">350000.0</Float> - <Float name="beta">240000.0</Float> + <Float name="beta">320000.0</Float> <Float name="brake_limit">50000.0</Float> <Float name="brake_slip">0.8</Float> <Float name="tire_radius">0.4</Float> @@ -81,7 +81,7 @@ <Real name="damage_limit">80000.0:10000.0</Real> <Float name="compression_limit">0.223</Float> <Float name="K">350000.0</Float> - <Float name="beta">240000.0</Float> + <Float name="beta">320000.0</Float> <Float name="brake_limit">50000.0</Float> <Float name="brake_slip">0.8</Float> <Float name="tire_radius">0.4</Float> |