1
0
Fork 0

src/Aircraft/flightrecorder.cxx: Improved logging of raw speed values.

This commit is contained in:
Julian Smith 2021-04-14 10:17:44 +01:00
parent cb00971dcb
commit 745273ab26

View file

@ -788,7 +788,7 @@ FGFlightRecorder::replay(double SimTime, const FGReplayData* _pNextBuffer,
m_CaptureDouble[i].Signal->setDoubleValue(v); m_CaptureDouble[i].Signal->setDoubleValue(v);
} }
if (m_LogRawSpeed->getBoolValue()) { if (m_LogRawSpeed->getBoolValue() && _pNextBuffer && pLastBuffer) {
// Log raw speed values to // Log raw speed values to
// /sim/replay/log-raw-speed-values/value[]. This is used by // /sim/replay/log-raw-speed-values/value[]. This is used by
// scripts/python/recordreplay.py --test-motion. // scripts/python/recordreplay.py --test-motion.
@ -800,14 +800,17 @@ FGFlightRecorder::replay(double SimTime, const FGReplayData* _pNextBuffer,
); );
SGVec3d pos = SGVec3d::fromGeod(pos_geod); SGVec3d pos = SGVec3d::fromGeod(pos_geod);
static SGVec3d pos_prev; static SGVec3d pos_prev;
static double simtime_prev = -1; static double t_prev = -1;
double dt = SimTime - simtime_prev; double t = SimTime;
if (simtime_prev != -1 && dt > 0) { double dt = t - t_prev;
if (t_prev != -1 && dt > 0) {
double distance = length(pos - pos_prev); double distance = length(pos - pos_prev);
double speed = dt ? distance / dt : -1; double speed = dt ? distance / dt : -1;
SG_LOG(SG_GENERAL, SG_DEBUG, "User aircraft:" SG_LOG(SG_GENERAL, SG_DEBUG, ""
<< " User aircraft:"
<< " pLastBuffer=" << ((void*) pLastBuffer) << " pLastBuffer=" << ((void*) pLastBuffer)
<< " SimTime=" << SimTime << " t_prev=" << std::setprecision(10) << t_prev
<< " t=" << std::setprecision(10) << t
<< " dt=" << dt << " dt=" << dt
<< " distance=" << distance << " distance=" << distance
<< " speed=" << speed << " speed=" << speed
@ -816,7 +819,7 @@ FGFlightRecorder::replay(double SimTime, const FGReplayData* _pNextBuffer,
n->addChild("value")->setDoubleValue(speed); n->addChild("value")->setDoubleValue(speed);
} }
pos_prev = pos; pos_prev = pos;
simtime_prev = SimTime; t_prev = t;
} }
Offset += SignalCount * sizeof(double); Offset += SignalCount * sizeof(double);