summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2020-10-11 20:58:57 -0700
committerKevin Tang <zhikait@codeaurora.org>2020-10-12 23:23:32 -0700
commit3beea52ea6c34dcf40887caa2fa17c751dccbae0 (patch)
treecadb21e72056d724adb64528ed1953dff0c65cf1
parent577ae9b36d34cdc585e8d0bce3bd98eca9e8c13c (diff)
parent005a322b96f1bf1df4b71cf9a3d4319b538daf73 (diff)
Merge remote-tracking branch 'quic/location.lnx.4.0' into HEAD
Change-Id: I28d5e29a9790ca3f28f44b5c5d9e4c5037c646d8 CRs-Fixed: 2794929
-rw-r--r--gnss/GnssAdapter.cpp288
-rw-r--r--gnss/GnssAdapter.h3
-rw-r--r--location/LocationAPI.h10
-rw-r--r--location/LocationAPIClientBase.cpp2
-rw-r--r--location/LocationDataTypes.h14
-rw-r--r--utils/gps_extended_c.h3
-rw-r--r--utils/loc_misc_utils.cpp117
-rw-r--r--utils/loc_misc_utils.h39
-rw-r--r--utils/loc_nmea.cpp11
-rw-r--r--utils/log_util.h2
10 files changed, 377 insertions, 112 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index dcf6317..dc06da9 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -50,6 +50,7 @@
#include <gps_extended_c.h>
#define RAD2DEG (180.0 / M_PI)
+#define DEG2RAD (M_PI / 180.0)
#define PROCESS_NAME_ENGINE_SERVICE "engine-service"
#define MIN_TRACKING_INTERVAL (100) // 100 msec
@@ -61,6 +62,11 @@
using namespace loc_core;
+static int loadEngHubForExternalEngine = 0;
+static loc_param_s_type izatConfParamTable[] = {
+ {"LOAD_ENGHUB_FOR_EXTERNAL_ENGINE", &loadEngHubForExternalEngine, nullptr,'n'}
+};
+
/* Method to fetch status cb from loc_net_iface library */
typedef AgpsCbInfo& (*LocAgpsGetAgpsCbInfo)(LocAgpsOpenResultCb openResultCb,
LocAgpsCloseResultCb closeResultCb, void* userDataPtr);
@@ -293,6 +299,12 @@ GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation,
if (LOC_POS_TECH_MASK_PPE & techMask) {
out.techMask |= LOCATION_TECHNOLOGY_PPE_BIT;
}
+ if (LOC_POS_TECH_MASK_VEH & techMask) {
+ out.techMask |= LOCATION_TECHNOLOGY_VEH_BIT;
+ }
+ if (LOC_POS_TECH_MASK_VIS & techMask) {
+ out.techMask |= LOCATION_TECHNOLOGY_VIS_BIT;
+ }
if (LOC_GPS_LOCATION_HAS_SPOOF_MASK & ulpLocation.gpsLocation.flags) {
out.flags |= LOCATION_HAS_SPOOF_MASK;
@@ -580,35 +592,6 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
out.bodyFrameDataExt.yaw = locationExtended.bodyFrameDataExt.yaw;
out.bodyFrameDataExt.yawUnc = locationExtended.bodyFrameDataExt.yawUnc;
}
- if (GPS_LOCATION_EXTENDED_HAS_GPS_TIME & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_GPS_TIME;
- out.gnssSystemTime.gnssSystemTimeSrc = locationExtended.gnssSystemTime.gnssSystemTimeSrc;
- out.gnssSystemTime.u = locationExtended.gnssSystemTime.u;
- }
- if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL;
- out.northVelocity = locationExtended.northVelocity;
- }
- if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL;
- out.eastVelocity = locationExtended.eastVelocity;
- }
- if (GPS_LOCATION_EXTENDED_HAS_UP_VEL & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL;
- out.upVelocity = locationExtended.upVelocity;
- }
- if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC;
- out.northVelocityStdDeviation = locationExtended.northVelocityStdDeviation;
- }
- if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC;
- out.eastVelocityStdDeviation = locationExtended.eastVelocityStdDeviation;
- }
- if (GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC & locationExtended.flags) {
- out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC;
- out.upVelocityStdDeviation = locationExtended.upVelocityStdDeviation;
- }
// Validity of this structure is established from the timeSrc of the GnssSystemTime structure.
out.gnssSystemTime = locationExtended.gnssSystemTime;
@@ -667,8 +650,6 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
}
}
-
-
inline uint32_t
GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion)
{
@@ -1263,19 +1244,26 @@ GnssAdapter::gnssUpdateConfigCommand(const GnssConfig& config)
mApi(api),
mConfig(config),
mCount(count),
- mIds(ids) {}
- inline MsgGnssUpdateConfig(const MsgGnssUpdateConfig& obj) :
- MsgGnssUpdateConfig(obj.mAdapter, obj.mApi, obj.mConfig,
- new uint32_t[obj.mCount], obj.mCount) {
- if (mIds != nullptr) {
- for (int i = 0; i < mCount; ++i) {
- mIds[i] = obj.mIds[i];
+ mIds(nullptr) {
+ if (mCount > 0) {
+ mIds = new uint32_t[count];
+ if (mIds) {
+ for (uint32_t index = 0; index < count; index++) {
+ mIds[index] = ids[index];
+ }
+ } else {
+ LOC_LOGe("memory allocation for mIds failed");
+ }
}
- }
}
+
+ inline MsgGnssUpdateConfig(const MsgGnssUpdateConfig& obj) :
+ MsgGnssUpdateConfig(obj.mAdapter, obj.mApi, obj.mConfig,
+ obj.mIds, obj.mCount) {}
+
inline virtual ~MsgGnssUpdateConfig()
{
- delete[] mIds;
+ if (nullptr != mIds) delete[] mIds;
}
inline virtual void proc() const {
@@ -1546,21 +1534,27 @@ GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) {
mAdapter(adapter),
mApi(api),
mConfigMask(configMask),
- mIds(ids),
- mCount(count) {}
+ mIds(nullptr),
+ mCount(count) {
+ if (mCount > 0) {
+ mIds = new uint32_t[count];
+ if (mIds) {
+ for (uint32_t index = 0; index < count; index++) {
+ mIds[index] = ids[index];
+ }
+ } else {
+ LOC_LOGe("memory allocation for mIds failed");
+ }
+ }
+ }
inline MsgGnssGetConfig(const MsgGnssGetConfig& obj) :
MsgGnssGetConfig(obj.mAdapter, obj.mApi, obj.mConfigMask,
- new uint32_t[obj.mCount], obj.mCount) {
- if (mIds != nullptr) {
- for (int i = 0; i < mCount; ++i) {
- mIds[i] = obj.mIds[i];
- }
- }
- }
+ obj.mIds, obj.mCount) {}
+
inline virtual ~MsgGnssGetConfig()
{
- delete[] mIds;
+ if (nullptr != mIds) delete[] mIds;
}
inline virtual void proc() const {
if (!mAdapter.isEngineCapabilitiesKnown()) {
@@ -2190,7 +2184,17 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data)
}
}
- mAdapter.mEngHubProxy->gnssDeleteAidingData(mData);
+ bool retVal = mAdapter.mEngHubProxy->gnssDeleteAidingData(mData);
+ // When SPE engine is invoked, responseCb will be invoked
+ // from QMI Loc API call.
+ // When SPE engine is not invoked, we also need to deliver responseCb
+ if ((mData.posEngineMask & STANDARD_POSITIONING_ENGINE) == 0) {
+ LocationError err = LOCATION_ERROR_NOT_SUPPORTED;
+ if (retVal == true) {
+ err = LOCATION_ERROR_SUCCESS;
+ }
+ mAdapter.reportResponse(err, mSessionId);
+ }
}
};
@@ -3550,6 +3554,63 @@ GnssAdapter::disableCommand(uint32_t id)
}
+// This function computes the VRP based latitude, longitude and alittude, and
+// north, east and up velocity and save the result into EHubTechReport.
+void
+GnssAdapter::computeVRPBasedLla(const UlpLocation& loc, GpsLocationExtended& locExt,
+ const LeverArmConfigInfo& leverArmConfigInfo) {
+
+ float leverArm[3];
+ float rollPitchYaw[3];
+ double lla[3];
+
+ uint16_t locFlags = loc.gpsLocation.flags;
+ uint64_t locExtFlags = locExt.flags;
+
+ // check for SPE fix
+ if (!((locExtFlags & GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_TYPE) &&
+ (locExt.locOutputEngType == LOC_OUTPUT_ENGINE_SPE))){
+ LOC_LOGv("not SPE fix, return");
+ return;
+ }
+
+ // we can only do translation if we have VRP based lever ARM info
+ LeverArmTypeMask leverArmFlags = leverArmConfigInfo.leverArmValidMask;
+ if (!(leverArmFlags & LEVER_ARM_TYPE_GNSS_TO_VRP_BIT)) {
+ LOC_LOGd("no VRP based lever ARM info");
+ return;
+ }
+
+ leverArm[0] = leverArmConfigInfo.gnssToVRP.forwardOffsetMeters;
+ leverArm[1] = leverArmConfigInfo.gnssToVRP.sidewaysOffsetMeters;
+ leverArm[2] = leverArmConfigInfo.gnssToVRP.upOffsetMeters;
+
+ if ((locFlags & LOC_GPS_LOCATION_HAS_LAT_LONG) &&
+ (locFlags & LOC_GPS_LOCATION_HAS_ALTITUDE) &&
+ (locFlags & LOCATION_HAS_BEARING_BIT)) {
+
+ lla[0] = loc.gpsLocation.latitude * DEG2RAD;
+ lla[1] = loc.gpsLocation.longitude * DEG2RAD;
+ lla[2] = loc.gpsLocation.altitude;
+
+ rollPitchYaw[0] = 0.0f;
+ rollPitchYaw[1] = 0.0f;
+ rollPitchYaw[2] = loc.gpsLocation.bearing * DEG2RAD;
+
+ loc_convert_lla_gnss_to_vrp(lla, rollPitchYaw, leverArm);
+
+ // assign the converted value into position report and
+ // set up valid mask
+ locExt.llaVRPBased.latitude = lla[0] * RAD2DEG;
+ locExt.llaVRPBased.longitude = lla[1] * RAD2DEG;
+ locExt.llaVRPBased.altitude = lla[2];
+ locExt.flags |= GPS_LOCATION_EXTENDED_HAS_LLA_VRP_BASED;
+ } else {
+ LOC_LOGd("SPE fix missing latitude/longitude/alitutde");
+ return;
+ }
+}
+
void
GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
@@ -3565,63 +3626,90 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
locationExtended.locOutputEngType,
ulpLocation.unpropagatedPosition, status, msInWeek);
- if (false == ulpLocation.unpropagatedPosition && pDataNotify != nullptr) {
- reportDataEvent((GnssDataNotification&)(*pDataNotify), msInWeek);
- }
-
- if (true == initEngHubProxy()){
- // send the SPE fix to engine hub
- mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status);
- // report out all SPE fix if it is not propagated, even for failed fix
- if (false == ulpLocation.unpropagatedPosition) {
- EngineLocationInfo engLocationInfo = {};
- engLocationInfo.location = ulpLocation;
- engLocationInfo.locationExtended = locationExtended;
- engLocationInfo.sessionStatus = status;
- reportEnginePositionsEvent(1, &engLocationInfo);
- }
- return;
- }
-
- // unpropagated report: is only for engine hub to consume and no need
- // to send out to the clients
- if (true == ulpLocation.unpropagatedPosition) {
- return;
- }
-
- // Fix is from QMI, and it is not an unpropagated position and engine hub
- // is not loaded, queue the message when message is processed, the position
- // can be dispatched to requesting client that registers for SPE report
- struct MsgReportPosition : public LocMsg {
+ struct MsgReportSPEPosition : public LocMsg {
GnssAdapter& mAdapter;
- const UlpLocation mUlpLocation;
- const GpsLocationExtended mLocationExtended;
- loc_sess_status mStatus;
+ mutable UlpLocation mUlpLocation;
+ mutable GpsLocationExtended mLocationExtended;
+ enum loc_sess_status mStatus;
LocPosTechMask mTechMask;
- inline MsgReportPosition(GnssAdapter& adapter,
- const UlpLocation& ulpLocation,
- const GpsLocationExtended& locationExtended,
- loc_sess_status status,
- LocPosTechMask techMask) :
+ mutable GnssDataNotification mDataNotify;
+ int mMsInWeek;
+
+ inline MsgReportSPEPosition(GnssAdapter& adapter,
+ const UlpLocation& ulpLocation,
+ const GpsLocationExtended& locationExtended,
+ enum loc_sess_status status,
+ LocPosTechMask techMask,
+ GnssDataNotification dataNotify,
+ int msInWeek) :
LocMsg(),
mAdapter(adapter),
mUlpLocation(ulpLocation),
mLocationExtended(locationExtended),
mStatus(status),
- mTechMask(techMask) {}
+ mTechMask(techMask),
+ mDataNotify(dataNotify),
+ mMsInWeek(msInWeek) {}
inline virtual void proc() const {
+ if (mAdapter.mTimeBasedTrackingSessions.empty() &&
+ mAdapter.mDistanceBasedTrackingSessions.empty()) {
+ LOC_LOGd("reportPositionEvent, no session on-going, throw away the SPE reports");
+ return;
+ }
+
+ if (false == mUlpLocation.unpropagatedPosition && mDataNotify.size != 0) {
+ if (mMsInWeek >= 0) {
+ mAdapter.getDataInformation((GnssDataNotification&)mDataNotify,
+ mMsInWeek);
+ }
+ mAdapter.reportData(mDataNotify);
+ }
+
+ if (true == mAdapter.initEngHubProxy()){
+ // send the SPE fix to engine hub
+ mAdapter.mEngHubProxy->gnssReportPosition(mUlpLocation, mLocationExtended, mStatus);
+ // report out all SPE fix if it is not propagated, even for failed fix
+ if (false == mUlpLocation.unpropagatedPosition) {
+ EngineLocationInfo engLocationInfo = {};
+ engLocationInfo.location = mUlpLocation;
+ engLocationInfo.locationExtended = mLocationExtended;
+ engLocationInfo.sessionStatus = mStatus;
+
+ // obtain the VRP based latitude/longitude/altitude for SPE fix
+ computeVRPBasedLla(engLocationInfo.location,
+ engLocationInfo.locationExtended,
+ mAdapter.mLocConfigInfo.leverArmConfigInfo);
+ mAdapter.reportEnginePositions(1, &engLocationInfo);
+ }
+ return;
+ }
+
+ // unpropagated report: is only for engine hub to consume and no need
+ // to send out to the clients
+ if (true == mUlpLocation.unpropagatedPosition) {
+ return;
+ }
+
// extract bug report info - this returns true if consumed by systemstatus
SystemStatus* s = mAdapter.getSystemStatus();
if ((nullptr != s) &&
((LOC_SESS_SUCCESS == mStatus) || (LOC_SESS_INTERMEDIATE == mStatus))){
s->eventPosition(mUlpLocation, mLocationExtended);
}
+
mAdapter.reportPosition(mUlpLocation, mLocationExtended, mStatus, mTechMask);
}
};
- sendMsg(new MsgReportPosition(*this, ulpLocation, locationExtended,
- status, techMask));
+ if (mContext != NULL) {
+ GnssDataNotification dataNotifyCopy = {};
+ if (pDataNotify) {
+ dataNotifyCopy = *pDataNotify;
+ dataNotifyCopy.size = sizeof(dataNotifyCopy);
+ }
+ sendMsg(new MsgReportSPEPosition(*this, ulpLocation, locationExtended,
+ status, techMask, dataNotifyCopy, msInWeek));
+ }
}
void
@@ -4131,8 +4219,8 @@ GnssAdapter::reportDataEvent(const GnssDataNotification& dataNotify,
GnssDataNotification mDataNotify;
int mMsInWeek;
inline MsgReportData(GnssAdapter& adapter,
- const GnssDataNotification& dataNotify,
- int msInWeek) :
+ const GnssDataNotification& dataNotify,
+ int msInWeek) :
LocMsg(),
mAdapter(adapter),
mDataNotify(dataNotify),
@@ -5836,6 +5924,13 @@ GnssAdapter::configLeverArmCommand(const LeverArmConfigInfo& configInfo) {
mSessionId(sessionId),
mConfigInfo(configInfo) {}
inline virtual void proc() const {
+ // save the lever ARM config info for translate position from GNSS antenna based
+ // to VRP based
+ if (mConfigInfo.leverArmValidMask & LEVER_ARM_TYPE_GNSS_TO_VRP_BIT) {
+ mAdapter.mLocConfigInfo.leverArmConfigInfo.leverArmValidMask |=
+ LEVER_ARM_TYPE_GNSS_TO_VRP_BIT;
+ mAdapter.mLocConfigInfo.leverArmConfigInfo.gnssToVRP = mConfigInfo.gnssToVRP;
+ }
mAdapter.configLeverArm(mSessionId, mConfigInfo);
}
};
@@ -6162,9 +6257,14 @@ GnssAdapter::initEngHubProxy() {
}
}
- // no plugin daemon is enabled for this platform, no need to load eng hub .so
+ // no plugin daemon is enabled for this platform,
+ // check if external engine is present for which we need
+ // libloc_eng_hub.so to be loaded
if (pluginDaemonEnabled == false) {
- break;
+ UTIL_READ_CONF(LOC_PATH_IZAT_CONF, izatConfParamTable);
+ if (!loadEngHubForExternalEngine) {
+ break;
+ }
}
// load the engine hub .so, if the .so is not present
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index b9adf50..ddadb13 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -146,6 +146,7 @@ typedef struct {
TuncConfigInfo tuncConfigInfo;
PaceConfigInfo paceConfigInfo;
RobustLocationConfigInfo robustLocationConfigInfo;
+ LeverArmConfigInfo leverArmConfigInfo;
} LocIntegrationConfigInfo;
using namespace loc_core;
@@ -564,6 +565,8 @@ public:
static void convertGnssSvIdMaskToList(
uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds,
GnssSvId initialSvId, GnssSvType svType);
+ static void computeVRPBasedLla(const UlpLocation& loc, GpsLocationExtended& locExt,
+ const LeverArmConfigInfo& leverArmConfigInfo);
void injectLocationCommand(double latitude, double longitude, float accuracy);
void injectLocationExtCommand(const GnssLocationInfoNotification &locationInfo);
diff --git a/location/LocationAPI.h b/location/LocationAPI.h
index 5646ec8..21a3a1f 100644
--- a/location/LocationAPI.h
+++ b/location/LocationAPI.h
@@ -235,7 +235,10 @@ public:
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
- LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
+ LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason
+
+ PLEASE NOTE: It is caller's resposibility to FREE the memory of the return value.
+ The memory must be freed by delete [].*/
virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) override;
/* gnssGetConfig fetches the current constellation and SV configuration
@@ -250,7 +253,10 @@ public:
LOCATION_ERROR_CALLBACK_MISSING If no gnssConfigCallback
was passed in createInstance
LOCATION_ERROR_NOT_SUPPORTED If read of requested configuration
- is not supported */
+ is not supported
+
+ PLEASE NOTE: It is caller's resposibility to FREE the memory of the return value.
+ The memory must be freed by delete [].*/
uint32_t* gnssGetConfig(GnssConfigFlagsMask mask);
/* delete specific gnss aiding data for testing, which returns a session id
diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp
index ef28bce..4865a16 100644
--- a/location/LocationAPIClientBase.cpp
+++ b/location/LocationAPIClientBase.cpp
@@ -158,6 +158,7 @@ uint32_t LocationAPIControlClient::locAPIGnssUpdateConfig(GnssConfig config)
}
mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].push(new GnssUpdateConfigRequest(*this));
retVal = LOCATION_ERROR_SUCCESS;
+ delete [] idArray;
}
}
}
@@ -180,6 +181,7 @@ uint32_t LocationAPIControlClient::locAPIGnssGetConfig(GnssConfigFlagsMask mask)
}
mRequestQueues[CTRL_REQUEST_CONFIG_GET].push(new GnssGetConfigRequest(*this));
retVal = LOCATION_ERROR_SUCCESS;
+ delete [] idArray;
}
}
pthread_mutex_unlock(&mMutex);
diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h
index a7f3a6c..aa80479 100644
--- a/location/LocationDataTypes.h
+++ b/location/LocationDataTypes.h
@@ -91,7 +91,9 @@ typedef enum {
LOCATION_TECHNOLOGY_INJECTED_COARSE_POSITION_BIT = (1<<5), // using CPI
LOCATION_TECHNOLOGY_AFLT_BIT = (1<<6), // AFLT
LOCATION_TECHNOLOGY_HYBRID_BIT = (1<<7), // HYBRID
- LOCATION_TECHNOLOGY_PPE_BIT = (1<<8) // PPE
+ LOCATION_TECHNOLOGY_PPE_BIT = (1<<8), // PPE
+ LOCATION_TECHNOLOGY_VEH_BIT = (1<<9), // using vehicular data
+ LOCATION_TECHNOLOGY_VIS_BIT = (1<<10) // using visual data
} LocationTechnologyBits;
typedef uint32_t LocationSpoofMask;
@@ -717,10 +719,12 @@ typedef uint32_t PositioningEngineMask;
typedef enum {
STANDARD_POSITIONING_ENGINE = (1 << 0),
DEAD_RECKONING_ENGINE = (1 << 1),
- PRECISE_POSITIONING_ENGINE = (1 << 2)
+ PRECISE_POSITIONING_ENGINE = (1 << 2),
+ VP_POSITIONING_ENGINE = (1 << 3)
} PositioningEngineBits;
#define POSITION_ENGINE_MASK_ALL \
- (STANDARD_POSITIONING_ENGINE|DEAD_RECKONING_ENGINE|PRECISE_POSITIONING_ENGINE)
+ (STANDARD_POSITIONING_ENGINE|DEAD_RECKONING_ENGINE| \
+ PRECISE_POSITIONING_ENGINE|VP_POSITIONING_ENGINE)
typedef uint64_t GnssDataMask;
typedef enum {
@@ -821,6 +825,7 @@ typedef enum {
LOC_REQ_ENGINE_FUSED_BIT = (1<<0),
LOC_REQ_ENGINE_SPE_BIT = (1<<1),
LOC_REQ_ENGINE_PPE_BIT = (1<<2),
+ LOC_REQ_ENGINE_VPE_BIT = (1<<3)
} LocReqEngineTypeMask;
typedef enum {
@@ -829,6 +834,7 @@ typedef enum {
LOC_OUTPUT_ENGINE_SPE = 1,
/** This is the GNSS fix with correction PPP/RTK correction */
LOC_OUTPUT_ENGINE_PPE = 2,
+ LOC_OUTPUT_ENGINE_VPE = 3,
LOC_OUTPUT_ENGINE_COUNT,
} LocOutputEngineType;
@@ -1127,7 +1133,7 @@ typedef struct {
// location engine type. When the fix. when the type is set to
// LOC_ENGINE_SRC_FUSED, the fix is the propagated/aggregated
// reports from all engines running on the system (e.g.:
- // DR/SPE/PPE). To check which location engine contributes to
+ // DR/SPE/PPE/VPE). To check which location engine contributes to
// the fused output, check for locOutputEngMask.
LocOutputEngineType locOutputEngType;
// when loc output eng type is set to fused, this field
diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h
index 51afd0c..8e47ef7 100644
--- a/utils/gps_extended_c.h
+++ b/utils/gps_extended_c.h
@@ -115,6 +115,9 @@ typedef uint32_t LocPosTechMask;
#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
#define LOC_POS_TECH_MASK_PPE ((LocPosTechMask)0x00000100)
+#define LOC_POS_TECH_MASK_VEH ((LocPosTechMask)0x00000200)
+#define LOC_POS_TECH_MASK_VIS ((LocPosTechMask)0x00000400)
+
enum loc_registration_mask_status {
LOC_REGISTRATION_MASK_ENABLED,
diff --git a/utils/loc_misc_utils.cpp b/utils/loc_misc_utils.cpp
index 7143466..43856c6 100644
--- a/utils/loc_misc_utils.cpp
+++ b/utils/loc_misc_utils.cpp
@@ -32,6 +32,7 @@
#include <string.h>
#include <inttypes.h>
#include <dlfcn.h>
+#include <math.h>
#include <log_util.h>
#include <loc_misc_utils.h>
#include <ctype.h>
@@ -232,3 +233,119 @@ uint64_t getBootTimeMilliSec()
clock_gettime(CLOCK_BOOTTIME, &curTs);
return (uint64_t)GET_MSEC_FROM_TS(curTs);
}
+
+// Used for convert position/velocity from GSNS antenna based to VRP based
+void Matrix_MxV(float a[3][3], float b[3], float c[3]) {
+ int i, j;
+
+ for (i=0; i<3; i++) {
+ c[i] = 0.0f;
+ for (j=0; j<3; j++)
+ c[i] += a[i][j] * b[j];
+ }
+}
+
+// Used for convert position/velocity from GNSS antenna based to VRP based
+void Matrix_Skew(float a[3], float c[3][3]) {
+ c[0][0] = 0.0f;
+ c[0][1] = -a[2];
+ c[0][2] = a[1];
+ c[1][0] = a[2];
+ c[1][1] = 0.0f;
+ c[1][2] = -a[0];
+ c[2][0] = -a[1];
+ c[2][1] = a[0];
+ c[2][2] = 0.0f;
+}
+
+// Used for convert position/velocity from GNSS antenna based to VRP based
+void Euler2Dcm(float euler[3], float dcm[3][3]) {
+ float cr = 0.0, sr = 0.0, cp = 0.0, sp = 0.0, ch = 0.0, sh = 0.0;
+
+ cr = cosf(euler[0]);
+ sr = sinf(euler[0]);
+ cp = cosf(euler[1]);
+ sp = sinf(euler[1]);
+ ch = cosf(euler[2]);
+ sh = sinf(euler[2]);
+
+ dcm[0][0] = cp * ch;
+ dcm[0][1] = (sp*sr*ch) - (cr*sh);
+ dcm[0][2] = (cr*sp*ch) + (sh*sr);
+
+ dcm[1][0] = cp * sh;
+ dcm[1][1] = (sr*sp*sh) + (cr*ch);
+ dcm[1][2] = (cr*sp*sh) - (sr*ch);
+
+ dcm[2][0] = -sp;
+ dcm[2][1] = sr * cp;
+ dcm[2][2] = cr * cp;
+}
+
+// Used for convert position from GSNS based to VRP based
+// The converted position will be stored in the llaInfo parameter.
+#define A6DOF_WGS_A (6378137.0f)
+#define A6DOF_WGS_B (6335439.0f)
+#define A6DOF_WGS_E2 (0.00669437999014f)
+void loc_convert_lla_gnss_to_vrp(double lla[3], float rollPitchYaw[3],
+ float leverArm[3]) {
+ LOC_LOGv("lla: %f, %f, %f, lever arm: %f %f %f, "
+ "rollpitchyaw: %f %f %f",
+ lla[0], lla[1], lla[2],
+ leverArm[0], leverArm[1], leverArm[2],
+ rollPitchYaw[0], rollPitchYaw[1], rollPitchYaw[2]);
+
+ float cnb[3][3];
+ memset(cnb, 0, sizeof(cnb));
+ Euler2Dcm(rollPitchYaw, cnb);
+
+ float sl = sin(lla[0]);
+ float cl = cos(lla[0]);
+ float sf = 1.0f / (1.0f - A6DOF_WGS_E2 * sl* sl);
+ float sfr = sqrtf(sf);
+
+ float rn = A6DOF_WGS_B * sf * sfr + lla[2];
+ float re = A6DOF_WGS_A * sfr + lla[2];
+
+ float deltaNED[3];
+
+ // gps_pos_lla = imu_pos_lla + Cbn*la_b .* [1/geo.Rn; 1/(geo.Re*geo.cL); -1];
+ Matrix_MxV(cnb, leverArm, deltaNED);
+
+ // NED to lla conversion
+ lla[0] = lla[0] + deltaNED[0] / rn;
+ lla[1] = lla[1] + deltaNED[1] / (re * cl);
+ lla[2] = lla[2] - deltaNED[2];
+}
+
+// Used for convert velocity from GSNS based to VRP based
+// The converted velocity will be stored in the enuVelocity parameter.
+void loc_convert_velocity_gnss_to_vrp(float enuVelocity[3], float rollPitchYaw[3],
+ float rollPitchYawRate[3], float leverArm[3]) {
+
+ LOC_LOGv("enu velocity: %f, %f, %f, lever arm: %f %f %f, roll pitch yaw: %f %f %f,"
+ "rollpitchyawRate: %f %f %f",
+ enuVelocity[0], enuVelocity[1], enuVelocity[2],
+ leverArm[0], leverArm[1], leverArm[2],
+ rollPitchYaw[0], rollPitchYaw[1], rollPitchYaw[2],
+ rollPitchYawRate[0], rollPitchYawRate[1], rollPitchYawRate[2]);
+
+ float cnb[3][3];
+ memset(cnb, 0, sizeof(cnb));
+ Euler2Dcm(rollPitchYaw, cnb);
+
+ float skewLA[3][3];
+ memset(skewLA, 0, sizeof(skewLA));
+ Matrix_Skew(leverArm, skewLA);
+
+ float tmp[3];
+ float deltaEnuVelocity[3];
+ memset(tmp, 0, sizeof(tmp));
+ memset(deltaEnuVelocity, 0, sizeof(deltaEnuVelocity));
+ Matrix_MxV(skewLA, rollPitchYawRate, tmp);
+ Matrix_MxV(cnb, tmp, deltaEnuVelocity);
+
+ enuVelocity[0] = enuVelocity[0] - deltaEnuVelocity[0];
+ enuVelocity[1] = enuVelocity[1] - deltaEnuVelocity[1];
+ enuVelocity[2] = enuVelocity[2] - deltaEnuVelocity[2];
+}
diff --git a/utils/loc_misc_utils.h b/utils/loc_misc_utils.h
index 796beab..2335e57 100644
--- a/utils/loc_misc_utils.h
+++ b/utils/loc_misc_utils.h
@@ -279,4 +279,43 @@ inline uint64_t qTimerTicksToNanos(double qTimer) {
return (uint64_t((qTimer * double(10000ull)) / (double)192ull));
}
+/*===========================================================================
+FUNCTION loc_convert_lla_gnss_to_vrp
+
+DESCRIPTION
+ This function converts lat/long/altitude from GNSS antenna based
+ to vehicle reference point based.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ The converted lat/long/altitude will be stored in the parameter of llaInfo.
+
+SIDE EFFECTS
+ N/A
+===========================================================================*/
+void loc_convert_lla_gnss_to_vrp(double lla[3], float rollPitchYaw[3],
+ float leverArm[3]);
+
+/*===========================================================================
+FUNCTION loc_convert_velocity_gnss_to_vrp
+
+DESCRIPTION
+ This function converts east/north/up velocity from GNSS antenna based
+ to vehicle reference point based.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ The converted east/north/up velocity will be stored in the parameter of
+ enuVelocity.
+
+SIDE EFFECTS
+ N/A
+===========================================================================*/
+void loc_convert_velocity_gnss_to_vrp(float enuVelocity[3], float rollPitchYaw[3],
+ float rollPitchYawRate[3], float leverArm[3]);
+
#endif //_LOC_MISC_UTILS_H_
diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp
index 1cadac4..237910c 100644
--- a/utils/loc_nmea.cpp
+++ b/utils/loc_nmea.cpp
@@ -1083,17 +1083,6 @@ static void loc_nmea_get_fix_quality(const UlpLocation & location,
memset(gnsModeIndicator, 'N', 6); // N means no fix
gnsModeIndicator[6] = '\0';
do {
- // GGA fix quality is defined in NMEA spec as below:
- // https://www.trimble.com/OEM_ReceiverHelp/V4.44/en/NMEA-0183messages_GGA.html
- // Fix quality: 0 = invalid
- // 1 = GPS fix (SPS)
- // 2 = DGPS fix
- // 3 = PPS fix
- // 4 = Real Time Kinematic
- // 5 = Float RTK
- // 6 = estimated (dead reckoning) (2.3 feature)
- // 7 = Manual input mode
- // 8 = Simulation mode
if (!(location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG)){
break;
}
diff --git a/utils/log_util.h b/utils/log_util.h
index 5cdcf25..78ed478 100644
--- a/utils/log_util.h
+++ b/utils/log_util.h
@@ -53,7 +53,7 @@
#endif /* LOG_TAG */
// LE targets with no logcat support
-#ifdef FEATURE_EXTERNAL_AP
+#if defined(FEATURE_EXTERNAL_AP) || defined(USE_SYSLOG_LOGGING)
#include <syslog.h>
#define ALOGE(...) syslog(LOG_ERR, "LOC_LOGE: " __VA_ARGS__);
#define ALOGW(...) syslog(LOG_WARNING, "LOC_LOGW: " __VA_ARGS__);