1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-834 home location related error reporting improvments and comment

cleanups
This commit is contained in:
Philippe Renon 2013-02-22 22:34:24 +01:00 committed by Alessio Morale
parent 8bd3c09860
commit ed83f282a5
3 changed files with 13 additions and 10 deletions

View File

@ -30,10 +30,8 @@
#include "homelocationutil.h" #include "homelocationutil.h"
#include <stdint.h> #include <stdint.h>
#include <QDebug>
#include <QDateTime> #include <QDateTime>
#include "coordinateconversions.h"
#include "worldmagmodel.h" #include "worldmagmodel.h"
namespace Utils { namespace Utils {
@ -46,7 +44,7 @@ namespace Utils {
* @brief Get local magnetic field * @brief Get local magnetic field
* @param[in] LLA The longitude-latitude-altitude coordinate to compute the magnetic field at * @param[in] LLA The longitude-latitude-altitude coordinate to compute the magnetic field at
* @param[out] Be The resulting magnetic field at that location and time in [mGau](?) * @param[out] Be The resulting magnetic field at that location and time in [mGau](?)
* @returns 0 if successful, -1 otherwise. * @returns 0 if successful, negative otherwise.
*/ */
int HomeLocationUtil::getDetails(double LLA[3], double Be[3]) int HomeLocationUtil::getDetails(double LLA[3], double Be[3])
{ {
@ -64,15 +62,13 @@ namespace Utils {
if (latitude < -90 || latitude > 90) return -4; // range checking if (latitude < -90 || latitude > 90) return -4; // range checking
if (longitude < -180 || longitude > 180) return -5; // range checking if (longitude < -180 || longitude > 180) return -5; // range checking
// *************
QDateTime dt = QDateTime::currentDateTime().toUTC(); QDateTime dt = QDateTime::currentDateTime().toUTC();
// Fetch world magnetic model // Fetch world magnetic model
int result = WorldMagModel().GetMagVector(LLA, dt.date().month(), dt.date().day(), dt.date().year(), Be); int result = WorldMagModel().GetMagVector(LLA, dt.date().month(), dt.date().day(), dt.date().year(), Be);
Q_ASSERT(result >= 0); Q_ASSERT(result == 0);
return 0; // OK return result;
} }
} }

View File

@ -154,6 +154,15 @@ namespace Utils {
Initialize(); Initialize();
} }
/**
* @brief
* @param[in] LLA The longitude-latitude-altitude coordinate to compute the magnetic field at
* @param[in] Month
* @param[in] Day
* @param[in] Year
* @param[out] Be The resulting magnetic field at that location and time in [mGau](?)
* @returns 0 if successful, negative otherwise.
*/
int WorldMagModel::GetMagVector(double LLA[3], int Month, int Day, int Year, double Be[3]) int WorldMagModel::GetMagVector(double LLA[3], int Month, int Day, int Year, double Be[3])
{ {
double Lat = LLA[0]; double Lat = LLA[0];

View File

@ -313,11 +313,9 @@ int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard)
double Be[3]; double Be[3];
int result = Utils::HomeLocationUtil().getDetails(LLA, Be); int result = Utils::HomeLocationUtil().getDetails(LLA, Be);
Q_ASSERT(result >= 0); Q_ASSERT(result == 0);
// ******************
// save the new settings // save the new settings
HomeLocation *homeLocation = HomeLocation::GetInstance(obm); HomeLocation *homeLocation = HomeLocation::GetInstance(obm);
Q_ASSERT(homeLocation != NULL); Q_ASSERT(homeLocation != NULL);