Skip to content

Commit

Permalink
Skip antenna height correction when IMU is active (#4503)
Browse files Browse the repository at this point in the history
* Skip antenna height correction when IMU is active

* Move antenna height logic to the receiver
  • Loading branch information
domi4484 authored and nirvn committed Aug 19, 2023
1 parent e535576 commit f1a302c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/core/positioning/internalgnssreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
***************************************************************************/

#include "internalgnssreceiver.h"
#include "positioning.h"

#include <QGuiApplication>
#include <qgsapplication.h>
Expand Down Expand Up @@ -132,10 +133,15 @@ void InternalGnssReceiver::handlePositionUpdated( const QGeoPositionInfo &positi
longitude = positionInfo.coordinate().longitude();
updatePositionInformation = true;
}

double antennaHeight = 0.0;
if ( Positioning *positioning = qobject_cast<Positioning *>( parent() ) )
antennaHeight = positioning->antennaHeight();

double elevation = mLastGnssPositionInformation.elevation();
if ( !qgsDoubleNear( positionInfo.coordinate().altitude(), elevation ) )
{
elevation = positionInfo.coordinate().altitude();
elevation = positionInfo.coordinate().altitude() - antennaHeight;
updatePositionInformation = true;
}

Expand Down
8 changes: 7 additions & 1 deletion src/core/positioning/nmeagnssreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ void NmeaGnssReceiver::stateChanged( const QgsGpsInformation &info )
mLastGnssPositionValid = !std::isnan( info.latitude );

bool ellipsoidalElevation = false;
double antennaHeight = 0.0;
if ( Positioning *positioning = qobject_cast<Positioning *>( parent() ) )
{
ellipsoidalElevation = positioning->ellipsoidalElevation();
antennaHeight = positioning->antennaHeight();
}

if ( info.utcTime != mLastGnssPositionUtcTime )
Expand All @@ -73,9 +75,13 @@ void NmeaGnssReceiver::stateChanged( const QgsGpsInformation &info )
emit lastGnssPositionInformationChanged( mLastGnssPositionInformation );
}

double elevation = info.elevation - antennaHeight;
if ( ellipsoidalElevation )
elevation += info.elevation_diff;

// QgsGpsInformation's speed is served in km/h, translate to m/s
mCurrentNmeaGnssPositionInformation = GnssPositionInformation( info.latitude, info.longitude,
ellipsoidalElevation ? info.elevation + info.elevation_diff : info.elevation,
elevation,
info.speed * 1000 / 60 / 60, info.direction, info.satellitesInView, info.pdop, info.hdop, info.vdop,
info.hacc, info.vacc, info.utcDateTime, info.fixMode, info.fixType, info.quality, info.satellitesUsed, info.status,
info.satPrn, info.satInfoComplete, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
Expand Down
10 changes: 10 additions & 0 deletions src/core/positioning/positioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ void Positioning::setEllipsoidalElevation( bool ellipsoidal )
emit ellipsoidalElevationChanged();
}

void Positioning::setAntennaHeight( double antennaHeight )
{
if ( mAntennaHeight == antennaHeight )
return;

mAntennaHeight = antennaHeight;

emit antennaHeightChanged();
}

void Positioning::setCoordinateTransformer( QgsQuickCoordinateTransformer *coordinateTransformer )
{
if ( mCoordinateTransformer == coordinateTransformer )
Expand Down
16 changes: 16 additions & 0 deletions src/core/positioning/positioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Positioning : public QObject
Q_PROPERTY( int averagedPositionCount READ averagedPositionCount NOTIFY averagedPositionCountChanged )

Q_PROPERTY( bool ellipsoidalElevation READ ellipsoidalElevation WRITE setEllipsoidalElevation NOTIFY ellipsoidalElevationChanged )
Q_PROPERTY( double antennaHeight READ antennaHeight WRITE setAntennaHeight NOTIFY antennaHeightChanged )

Q_PROPERTY( bool logging READ logging WRITE setLogging NOTIFY loggingChanged )

Expand Down Expand Up @@ -155,6 +156,19 @@ class Positioning : public QObject
*/
void setEllipsoidalElevation( bool ellipsoidal );

/**
* Sets the GNSS device antenna height. This should be the pole height + sensore phase height.
* \note When IMU is active this value is ignored as the device does the correction internally.
**/
double antennaHeight() const { return mAntennaHeight; }

/**
* Returns the GNSS device antenna height. This should be the pole height + sensore phase height.
* \note When IMU is active this value is ignored as the device does the correction internally.
**/
void setAntennaHeight( double antennaHeight );


/**
* Returns whether GNSS devices will log their incoming position stream into a logfile.
* \note Requires a device type with logging capability
Expand All @@ -179,6 +193,7 @@ class Positioning : public QObject
void averagedPositionCountChanged();
void projectedPositionChanged();
void ellipsoidalElevationChanged();
void antennaHeightChanged();
void loggingChanged();

private slots:
Expand Down Expand Up @@ -209,6 +224,7 @@ class Positioning : public QObject
bool mAveragedPosition = false;

bool mEllipsoidalElevation = false;
double mAntennaHeight = 0.0;

bool mLogging = false;

Expand Down
3 changes: 2 additions & 1 deletion src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ ApplicationWindow {
coordinateTransformer: CoordinateTransformer {
destinationCrs: mapCanvas.mapSettings.destinationCrs
transformContext: qgisProject ? qgisProject.transformContext : CoordinateReferenceSystemUtils.emptyTransformContext()
deltaZ: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight * -1 : 0
deltaZ: 0
skipAltitudeTransformation: positioningSettings.skipAltitudeCorrection
verticalGrid: positioningSettings.verticalGrid
}

ellipsoidalElevation: positioningSettings.ellipsoidalElevation
antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : 0
logging: positioningSettings.logging

onProjectedPositionChanged: {
Expand Down

0 comments on commit f1a302c

Please sign in to comment.