1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

Added code to check for invalid parameters.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2827 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-21 11:15:39 +00:00 committed by pip
parent 32ae936df5
commit 4a1842f3be

View File

@ -43,18 +43,35 @@ namespace Utils {
// Initialize();
}
// input params: LLA
//
// output params: ECEF, RNE and Be
int HomeLocationUtil::getDetails(double LLA[3], double ECEF[3], double RNE[9], double Be[3])
{
QDateTime dt = QDateTime::currentDateTime().toUTC();
// *************
// check input parms
// double current_altitude = obj->getField("Altitude")->getDouble();
double latitude = LLA[0];
double longitude = LLA[1];
double altitude = LLA[2];
if (latitude != latitude) return -1; // prevent nan error
if (longitude != longitude) return -2; // prevent nan error
if (altitude != altitude) return -3; // prevent nan error
if (latitude < -90 || latitude > 90) return -4; // range checking
if (longitude < -180 || longitude > 180) return -5; // range checking
// *************
QDateTime dt = QDateTime::currentDateTime().toUTC();
CoordinateConversions().LLA2ECEF(LLA, ECEF);
CoordinateConversions().RneFromLLA(LLA, (double (*)[3])RNE);
if (WorldMagModel().GetMagVector(LLA, dt.date().month(), dt.date().day(), dt.date().year(), Be) < 0)
return -1;
return -6;
return 0; // OK
return 0; // OK
}
}