From ed83f282a5967959147eec10c8e67cbf2ba06925 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 22 Feb 2013 22:34:24 +0100 Subject: [PATCH] OP-834 home location related error reporting improvments and comment cleanups --- .../openpilotgcs/src/libs/utils/homelocationutil.cpp | 10 +++------- ground/openpilotgcs/src/libs/utils/worldmagmodel.cpp | 9 +++++++++ .../src/plugins/uavobjectutil/uavobjectutilmanager.cpp | 4 +--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/homelocationutil.cpp b/ground/openpilotgcs/src/libs/utils/homelocationutil.cpp index 86307fdfe..549109b9a 100644 --- a/ground/openpilotgcs/src/libs/utils/homelocationutil.cpp +++ b/ground/openpilotgcs/src/libs/utils/homelocationutil.cpp @@ -30,10 +30,8 @@ #include "homelocationutil.h" #include -#include #include -#include "coordinateconversions.h" #include "worldmagmodel.h" namespace Utils { @@ -46,7 +44,7 @@ namespace Utils { * @brief Get local magnetic field * @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](?) - * @returns 0 if successful, -1 otherwise. + * @returns 0 if successful, negative otherwise. */ 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 (longitude < -180 || longitude > 180) return -5; // range checking - // ************* - QDateTime dt = QDateTime::currentDateTime().toUTC(); // Fetch world magnetic model 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; } } diff --git a/ground/openpilotgcs/src/libs/utils/worldmagmodel.cpp b/ground/openpilotgcs/src/libs/utils/worldmagmodel.cpp index 207d4b051..d93588684 100644 --- a/ground/openpilotgcs/src/libs/utils/worldmagmodel.cpp +++ b/ground/openpilotgcs/src/libs/utils/worldmagmodel.cpp @@ -154,6 +154,15 @@ namespace Utils { 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]) { double Lat = LLA[0]; diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp index 405c211e5..c04a6686e 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp @@ -313,11 +313,9 @@ int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard) double Be[3]; int result = Utils::HomeLocationUtil().getDetails(LLA, Be); - Q_ASSERT(result >= 0); + Q_ASSERT(result == 0); - // ****************** // save the new settings - HomeLocation *homeLocation = HomeLocation::GetInstance(obm); Q_ASSERT(homeLocation != NULL);