mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
GCS/Plugins/HiTL: Updated Xplane to provide correct measurements for all Stabilization and Guidance relevant data. Based on Export format for Xplane 9!
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3107 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
282661734e
commit
a4cbbfd016
@ -289,7 +289,7 @@ void IL2Simulator::processUpdate(const QByteArray& inp)
|
|||||||
for (int t=0;t<3;t++) {
|
for (int t=0;t<3;t++) {
|
||||||
rawData.accels[t]=current.ddX*Rbe[t][0]
|
rawData.accels[t]=current.ddX*Rbe[t][0]
|
||||||
+current.ddY*Rbe[t][1]
|
+current.ddY*Rbe[t][1]
|
||||||
+(current.ddZ+9.81)*Rbe[t][2];
|
+(current.ddZ+GEE)*Rbe[t][2];
|
||||||
}
|
}
|
||||||
rawData.accels[2]=-rawData.accels[2];
|
rawData.accels[2]=-rawData.accels[2];
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
volatile bool Simulator::isStarted = false;
|
volatile bool Simulator::isStarted = false;
|
||||||
|
|
||||||
|
const float Simulator::GEE = 9.81;
|
||||||
const float Simulator::FT2M = 0.3048;
|
const float Simulator::FT2M = 0.3048;
|
||||||
const float Simulator::KT2MPS = 0.514444444;
|
const float Simulator::KT2MPS = 0.514444444;
|
||||||
const float Simulator::INHG2KPA = 3.386;
|
const float Simulator::INHG2KPA = 3.386;
|
||||||
|
@ -156,6 +156,7 @@ private slots:
|
|||||||
virtual void processUpdate(const QByteArray& data) = 0;
|
virtual void processUpdate(const QByteArray& data) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static const float GEE;
|
||||||
static const float FT2M;
|
static const float FT2M;
|
||||||
static const float KT2MPS;
|
static const float KT2MPS;
|
||||||
static const float INHG2KPA;
|
static const float INHG2KPA;
|
||||||
|
@ -207,6 +207,9 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf)
|
|||||||
float dstX = 0;
|
float dstX = 0;
|
||||||
float dstY = 0;
|
float dstY = 0;
|
||||||
float dstZ = 0;
|
float dstZ = 0;
|
||||||
|
float accX = 0;
|
||||||
|
float accY = 0;
|
||||||
|
float accZ = 0;
|
||||||
float rollRate=0;
|
float rollRate=0;
|
||||||
float pitchRate=0;
|
float pitchRate=0;
|
||||||
float yawRate=0;
|
float yawRate=0;
|
||||||
@ -259,11 +262,11 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf)
|
|||||||
|
|
||||||
case XplaneSimulator::LocVelDistTraveled:
|
case XplaneSimulator::LocVelDistTraveled:
|
||||||
dstX = *((float*)(buf.data()+4*1));
|
dstX = *((float*)(buf.data()+4*1));
|
||||||
dstY = *((float*)(buf.data()+4*2));
|
dstY = - *((float*)(buf.data()+4*3));
|
||||||
dstZ = *((float*)(buf.data()+4*3));
|
dstZ = *((float*)(buf.data()+4*2));
|
||||||
velX = *((float*)(buf.data()+4*4));
|
velX = *((float*)(buf.data()+4*4));
|
||||||
velY = *((float*)(buf.data()+4*5));
|
velY = - *((float*)(buf.data()+4*6));
|
||||||
velZ = *((float*)(buf.data()+4*6));
|
velZ = *((float*)(buf.data()+4*5));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XplaneSimulator::AngularVelocities:
|
case XplaneSimulator::AngularVelocities:
|
||||||
@ -272,6 +275,12 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf)
|
|||||||
yawRate = *((float*)(buf.data()+4*3));
|
yawRate = *((float*)(buf.data()+4*3));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case XplaneSimulator::Gload:
|
||||||
|
accX = *((float*)(buf.data()+4*6)) * GEE;
|
||||||
|
accY = *((float*)(buf.data()+4*7)) * GEE;
|
||||||
|
accZ = *((float*)(buf.data()+4*5)) * GEE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -353,17 +362,17 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf)
|
|||||||
// Update VelocityActual.{Nort,East,Down}
|
// Update VelocityActual.{Nort,East,Down}
|
||||||
VelocityActual::DataFields velocityActualData;
|
VelocityActual::DataFields velocityActualData;
|
||||||
memset(&velocityActualData, 0, sizeof(VelocityActual::DataFields));
|
memset(&velocityActualData, 0, sizeof(VelocityActual::DataFields));
|
||||||
velocityActualData.North = velX*100;
|
velocityActualData.North = velY*100;
|
||||||
velocityActualData.East = velY*100;
|
velocityActualData.East = velX*100;
|
||||||
velocityActualData.Down = velZ*100;
|
velocityActualData.Down = -velZ*100;
|
||||||
velActual->setData(velocityActualData);
|
velActual->setData(velocityActualData);
|
||||||
|
|
||||||
// Update PositionActual.{Nort,East,Down}
|
// Update PositionActual.{Nort,East,Down}
|
||||||
PositionActual::DataFields positionActualData;
|
PositionActual::DataFields positionActualData;
|
||||||
memset(&positionActualData, 0, sizeof(PositionActual::DataFields));
|
memset(&positionActualData, 0, sizeof(PositionActual::DataFields));
|
||||||
positionActualData.North = (dstX-initX)*100;
|
positionActualData.North = (dstY-initY)*100;
|
||||||
positionActualData.East = (dstY-initY)*100;
|
positionActualData.East = (dstX-initX)*100;
|
||||||
positionActualData.Down = (dstZ-initZ)*100;
|
positionActualData.Down = -(dstZ-initZ)*100;
|
||||||
posActual->setData(positionActualData);
|
posActual->setData(positionActualData);
|
||||||
|
|
||||||
// Update AttitudeRaw object (filtered gyros only for now)
|
// Update AttitudeRaw object (filtered gyros only for now)
|
||||||
@ -375,6 +384,9 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf)
|
|||||||
//rawData.gyros_filtered[2] = cos(DEG2RAD * roll) * yawRate - sin(DEG2RAD * roll) * pitchRate;
|
//rawData.gyros_filtered[2] = cos(DEG2RAD * roll) * yawRate - sin(DEG2RAD * roll) * pitchRate;
|
||||||
rawData.gyros[1] = pitchRate;
|
rawData.gyros[1] = pitchRate;
|
||||||
rawData.gyros[2] = yawRate;
|
rawData.gyros[2] = yawRate;
|
||||||
|
rawData.accels[0] = accX;
|
||||||
|
rawData.accels[1] = accY;
|
||||||
|
rawData.accels[2] = -accZ;
|
||||||
attRaw->setData(rawData);
|
attRaw->setData(rawData);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user