1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Merge branch 'corvuscorax/OP-1353_Fix-flightgear-position' into next

This commit is contained in:
Corvus Corax 2014-05-19 16:16:47 +02:00
commit cc761b1212
3 changed files with 17 additions and 18 deletions

View File

@ -44,7 +44,7 @@ CoordinateConversions::CoordinateConversions()
* @param[in] LLA Longitude latitude altitude for this location
* @param[out] Rne[3][3] Rotation matrix
*/
void CoordinateConversions::RneFromLLA(double LLA[3], double Rne[3][3])
void CoordinateConversions::RneFromLLA(double LLA[3], float Rne[3][3])
{
float sinLat, sinLon, cosLat, cosLon;
@ -134,7 +134,7 @@ int CoordinateConversions::NED2LLA_HomeECEF(double BaseECEFm[3], double NED[3],
// stored value is in cm, convert to m
double BaseLLA[3];
double ECEF[3];
double Rne[3][3];
float Rne[3][3];
// Get LLA address to compute conversion matrix
ECEF2LLA(BaseECEFm, BaseLLA);

View File

@ -41,7 +41,7 @@ public:
CoordinateConversions();
int NED2LLA_HomeECEF(double BaseECEFcm[3], double NED[3], double position[3]);
int NED2LLA_HomeLLA(double LLA[3], double NED[3], double position[3]);
void RneFromLLA(double LLA[3], double Rne[3][3]);
void RneFromLLA(double LLA[3], float Rne[3][3]);
void LLA2ECEF(double LLA[3], double ECEF[3]);
int ECEF2LLA(double ECEF[3], double LLA[3]);
void LLA2Base(double LLA[3], double BaseECEF[3], float Rne[3][3], float NED[3]);

View File

@ -268,12 +268,12 @@ void FGSimulator::processUpdate(const QByteArray & inp)
float temperature = fields[19].toFloat();
// Get pressure (kpa)
float pressure = fields[20].toFloat() * INHG2KPA;
// Get VelocityState Down (cm/s)
float velocityStateDown = -fields[21].toFloat() * FPS2CMPS;
// Get VelocityState East (cm/s)
float velocityStateEast = fields[22].toFloat() * FPS2CMPS;
// Get VelocityState Down (cm/s)
float velocityStateNorth = fields[23].toFloat() * FPS2CMPS;
// Get VelocityState Down (m/s)
float velocityStateDown = -fields[21].toFloat() * FPS2CMPS * 1e-2f;
// Get VelocityState East (m/s)
float velocityStateEast = fields[22].toFloat() * FPS2CMPS * 1e-2f;
// Get VelocityState Down (m/s)
float velocityStateNorth = fields[23].toFloat() * FPS2CMPS * 1e-2f;
// Get UDP packets received by FG
int n = fields[24].toInt();
@ -286,16 +286,15 @@ void FGSimulator::processUpdate(const QByteArray & inp)
Output2Hardware out;
memset(&out, 0, sizeof(Output2Hardware));
HomeLocation::DataFields homeData = posHome->getData();
double HomeLLA[3] = { (double)homeData.Latitude * 1e-7, (double)homeData.Longitude * 1e-7, homeData.Altitude };
double HomeECEF[3];
float HomeRNE[3][3];
double LLA[3] = { latitude, longitude, altitude_msl };
float NED[3];
// convert from cm back to meters
double LLA[3] = { latitude, longitude, altitude_msl };
double ECEF[3];
double RNE[9];
Utils::CoordinateConversions().RneFromLLA(LLA, (double(*)[3])RNE);
Utils::CoordinateConversions().LLA2ECEF(LLA, ECEF);
Utils::CoordinateConversions().LLA2Base(LLA, ECEF, (float(*)[3])RNE, NED);
Utils::CoordinateConversions().RneFromLLA(HomeLLA, HomeRNE);
Utils::CoordinateConversions().LLA2ECEF(HomeLLA, HomeECEF);
Utils::CoordinateConversions().LLA2Base(LLA, HomeECEF, HomeRNE, NED);
// Update GPS Position objects
out.latitude = latitude * 1e7;