Skip to content

Pr base station menu #12686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/GPS/GPSProvider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,15 @@ GPSBaseStationSupport *GPSProvider::_connectGPS()
return nullptr;
}

gpsDriver->setSurveyInSpecs(_rtkData.surveyInAccMeters * 10000.f, _rtkData.surveyInDurationSecs);

if (_rtkData.useFixedBaseLoction) {
gpsDriver->setBasePosition(_rtkData.fixedBaseLatitude, _rtkData.fixedBaseLongitude, _rtkData.fixedBaseAltitudeMeters, _rtkData.fixedBaseAccuracyMeters * 1000.0f);
switch(_rtkData.baseMode){
case BaseModeDefinition::Mode::BaseFixed:
gpsDriver->setBasePosition(_rtkData.fixedBaseLatitude, _rtkData.fixedBaseLongitude, _rtkData.fixedBaseAltitudeMeters, _rtkData.fixedBaseAccuracyMeters * 1000.0f);
break;

case BaseModeDefinition::Mode::BaseSurveyIn:
default:
gpsDriver->setSurveyInSpecs(_rtkData.surveyInAccMeters * 10000.f, _rtkData.surveyInDurationSecs);
break;
}

_gpsConfig.output_mode = GPSHelper::OutputMode::RTCM;
Expand Down
3 changes: 2 additions & 1 deletion src/GPS/GPSProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QtCore/QThread>

#include <gps_helper.h>
#include "Settings/RTKSettings.h"

#include "satellite_info.h"
#include "sensor_gnss_relative.h"
Expand All @@ -42,7 +43,7 @@ class GPSProvider : public QThread
struct rtk_data_s {
double surveyInAccMeters = 0;
int surveyInDurationSecs = 0;
bool useFixedBaseLoction = false;
BaseModeDefinition::Mode baseMode = BaseModeDefinition::Mode::BaseSurveyIn;
double fixedBaseLatitude = 0.;
double fixedBaseLongitude = 0.;
float fixedBaseAltitudeMeters = 0.f;
Expand Down
18 changes: 15 additions & 3 deletions src/GPS/GPSRtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,40 @@ void GPSRtk::_onGPSSurveyInStatus(float duration, float accuracyMM, double lati
void GPSRtk::connectGPS(const QString &device, QStringView gps_type)
{
GPSProvider::GPSType type;
RTKSettings* rtkSettings = SettingsManager::instance()->rtkSettings();

if (gps_type.contains(QStringLiteral("trimble"), Qt::CaseInsensitive)) {
type = GPSProvider::GPSType::trimble;
rtkSettings->baseReceiverManufacturers()->setRawValue(2);
qCDebug(GPSRtkLog) << "Connecting Trimble device";

} else if (gps_type.contains(QStringLiteral("septentrio"), Qt::CaseInsensitive)) {
type = GPSProvider::GPSType::septentrio;
rtkSettings->baseReceiverManufacturers()->setRawValue(3);
qCDebug(GPSRtkLog) << "Connecting Septentrio device";

} else if (gps_type.contains(QStringLiteral("femtomes"), Qt::CaseInsensitive)) {
type = GPSProvider::GPSType::femto;
rtkSettings->baseReceiverManufacturers()->setRawValue(4);
qCDebug(GPSRtkLog) << "Connecting Femtomes device";
} else {

} else if(gps_type.contains(QStringLiteral("blox"), Qt::CaseInsensitive)) {
type = GPSProvider::GPSType::u_blox;
rtkSettings->baseReceiverManufacturers()->setRawValue(5); // Ublox
qCDebug(GPSRtkLog) << "Connecting U-blox device";
}else{
type = GPSProvider::GPSType::u_blox;
rtkSettings->baseReceiverManufacturers()->setRawValue(0); // Standart
qCDebug(GPSRtkLog) << "Connecting device has U-blox by default";
}

disconnectGPS();

RTKSettings* const rtkSettings = SettingsManager::instance()->rtkSettings();
_requestGpsStop = false;
const GPSProvider::rtk_data_s rtkData = {
rtkSettings->surveyInAccuracyLimit()->rawValue().toDouble(),
rtkSettings->surveyInMinObservationDuration()->rawValue().toInt(),
rtkSettings->useFixedBasePosition()->rawValue().toBool(),
static_cast<BaseModeDefinition::Mode>(rtkSettings->baseMode()->rawValue().toInt()),
rtkSettings->fixedBasePositionLatitude()->rawValue().toDouble(),
rtkSettings->fixedBasePositionLongitude()->rawValue().toDouble(),
rtkSettings->fixedBasePositionAltitude()->rawValue().toFloat(),
Expand Down
107 changes: 92 additions & 15 deletions src/QmlControls/GPSIndicatorPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import QGroundControl.ScreenTools
import QGroundControl.Palette
import QGroundControl.FactSystem
import QGroundControl.FactControls
import QGroundControl.SettingsManager 1.0

// This indicator page is used both when showing RTK status only with no vehicle connect and when showing GPS/RTK status with a vehicle connected

Expand All @@ -27,7 +28,50 @@ ToolIndicatorPage {
property string na: qsTr("N/A", "No data to display")
property string valueNA: qsTr("--.--", "No data to display")
property var rtkSettings: QGroundControl.settingsManager.rtkSettings
property bool useFixedPosition: rtkSettings.useFixedBasePosition.rawValue
property var baseMode: rtkSettings.baseMode.rawValue
property var manufacturer: rtkSettings.baseReceiverManufacturers.rawValue

readonly property var _standard: 0b00001
readonly property var _trimble: 0b00010
readonly property var _septentrio: 0b00100
readonly property var _femtomes: 0b01000
readonly property var _ublox: 0b10000
readonly property var _all: 0b11111
property var settingsDisplayId: _all

function updateSettingsDisplayId() {
switch(manufacturer) {
case 0: // Standard
settingsDisplayId = _standard
break
case 1: // All
settingsDisplayId = _standard | _trimble | _septentrio | _femtomes | _ublox
break
case 2: // Trimble
settingsDisplayId = _standard | _trimble
break
case 3: // Septentrio
settingsDisplayId = _standard | _septentrio
break
case 4: // Femtomes
settingsDisplayId = _standard | _femtomes
break
case 5: // UBlox
settingsDisplayId = _standard | _ublox
break
default:
settingsDisplayId = _standard
}
}

onManufacturerChanged: {
updateSettingsDisplayId()
}

Component.onCompleted: {
updateSettingsDisplayId()
}


contentComponent: Component {
ColumnLayout {
Expand Down Expand Up @@ -103,29 +147,46 @@ ToolIndicatorPage {
visible: fact.visible
}

RowLayout {
visible: rtkSettings.useFixedBasePosition.visible
GridLayout {
columns: 2

QGCLabel {
text: qsTr("Settings displayed")
}
FactComboBox {
Layout.fillWidth: true
fact: QGroundControl.settingsManager.rtkSettings.baseReceiverManufacturers
visible: QGroundControl.settingsManager.rtkSettings.baseReceiverManufacturers.visible
}
}

RowLayout {
QGCRadioButton {
text: qsTr("Survey-In")
checked: !useFixedPosition
onClicked: rtkSettings.useFixedBasePosition.rawValue = false
checked: baseMode == BaseMode.BaseSurveyIn
onClicked: rtkSettings.baseMode.rawValue = BaseMode.BaseSurveyIn
visible: settingsDisplayId & _standard
}

QGCRadioButton {
text: qsTr("Specify position")
checked: useFixedPosition
onClicked: rtkSettings.useFixedBasePosition.rawValue = true
checked: baseMode == BaseMode.BaseFixed
onClicked: rtkSettings.baseMode.rawValue = BaseMode.BaseFixed
visible: settingsDisplayId & _standard
}
}

FactSlider {
Layout.fillWidth: true
Layout.preferredWidth: sliderWidth
label: qsTr("Accuracy (u-blox only)")
label: qsTr("Accuracy")
fact: QGroundControl.settingsManager.rtkSettings.surveyInAccuracyLimit
majorTickStepSize: 0.1
visible: !useFixedPosition && rtkSettings.surveyInAccuracyLimit.visible
visible: (
baseMode == BaseMode.BaseSurveyIn
&& rtkSettings.surveyInAccuracyLimit.visible
&& (settingsDisplayId & _ublox)
)
}

FactSlider {
Expand All @@ -134,37 +195,53 @@ ToolIndicatorPage {
label: qsTr("Min Duration")
fact: rtkSettings.surveyInMinObservationDuration
majorTickStepSize: 10
visible: !useFixedPosition && rtkSettings.surveyInMinObservationDuration.visible
visible: (
baseMode == BaseMode.BaseSurveyIn
&& rtkSettings.surveyInMinObservationDuration.visible
&& (settingsDisplayId & (_ublox | _femtomes | _trimble))
)
}

LabelledFactTextField {
label: rtkSettings.fixedBasePositionLatitude.shortDescription
fact: rtkSettings.fixedBasePositionLatitude
visible: useFixedPosition && rtkSettings.fixedBasePositionLatitude.visible
visible: (
baseMode == BaseMode.BaseFixed
&& (settingsDisplayId & _standard)
)
}

LabelledFactTextField {
label: rtkSettings.fixedBasePositionLongitude.shortDescription
fact: rtkSettings.fixedBasePositionLongitude
visible: useFixedPosition && rtkSettings.fixedBasePositionLongitude.visible
visible: (
baseMode == BaseMode.BaseFixed
&& (settingsDisplayId & _standard)
)
}

LabelledFactTextField {
label: rtkSettings.fixedBasePositionAltitude.shortDescription
fact: rtkSettings.fixedBasePositionAltitude
visible: useFixedPosition && rtkSettings.fixedBasePositionAltitude.visible
visible: (
baseMode == BaseMode.BaseFixed
&& (settingsDisplayId & _standard)
)
}

LabelledFactTextField {
label: rtkSettings.fixedBasePositionAccuracy.shortDescription
fact: rtkSettings.fixedBasePositionAccuracy
visible: useFixedPosition && rtkSettings.fixedBasePositionAccuracy.visible
visible: (
baseMode == BaseMode.BaseFixed
&& (settingsDisplayId & _ublox)
)
}

LabelledButton {
label: qsTr("Current Base Position")
buttonText: enabled ? qsTr("Save") : qsTr("Not Yet Valid")
visible: useFixedPosition
visible: baseMode == BaseMode.BaseFixed
enabled: QGroundControl.gpsRtk.valid.value

onClicked: {
Expand Down
20 changes: 14 additions & 6 deletions src/Settings/RTK.SettingsGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "baseReceiverManufacturers",
"shortDesc": "GPS manufacturers for settings",
"type": "uint8",
"enumStrings": "Standard,All,Trimble,Septentrio,Femtomes,UBlox",
"enumValues": "0,1,2,3,4,5",
"default": 1
},
{
"name": "surveyInAccuracyLimit",
"shortDesc": "Survey in accuracy (U-blox only)",
"shortDesc": "Survey in accuracy",
"longDesc": "The minimum accuracy value that Survey-In must achieve before it can complete.",
"type": "double",
"default": 2.0,
Expand All @@ -30,11 +38,11 @@
"qgcRebootRequired": true
},
{
"name": "useFixedBasePosition",
"shortDesc": "Use specified base position",
"longDesc": "Specify the values for the RTK base position without having to do a survey in.",
"type": "bool",
"default": false,
"name": "baseMode",
"shortDesc": "Use specified base mode",
"longDesc": "Specify the mode for the RTK base 0: Survey-In (Fixed + Auto) 1: Specify position (Fixed + Manual)",
"type": "uint8",
"default": 0,
"qgcRebootRequired": true
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/Settings/RTKSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@
****************************************************************************/

#include "RTKSettings.h"
// #include "BaseMode.h" // Removed, definition now in RTKSettings.h

#include <QtQml/QQmlEngine>

DECLARE_SETTINGGROUP(RTK, "RTK")
{
qmlRegisterUncreatableType<RTKSettings>("QGroundControl.SettingsManager", 1, 0, "RTKSettings", "Reference only"); \
qRegisterMetaType<BaseModeDefinition::Mode>("BaseModeDefinition::Mode"); \
qmlRegisterUncreatableType<BaseModeDefinition>("QGroundControl.SettingsManager", 1, 0, "BaseMode", "Reference to BaseModeDefinition enum holding class");
}

DECLARE_SETTINGSFACT(RTKSettings, baseReceiverManufacturers)
DECLARE_SETTINGSFACT(RTKSettings, surveyInAccuracyLimit)
DECLARE_SETTINGSFACT(RTKSettings, surveyInMinObservationDuration)
DECLARE_SETTINGSFACT(RTKSettings, useFixedBasePosition)
DECLARE_SETTINGSFACT(RTKSettings, baseMode)
DECLARE_SETTINGSFACT(RTKSettings, fixedBasePositionLatitude)
DECLARE_SETTINGSFACT(RTKSettings, fixedBasePositionLongitude)
DECLARE_SETTINGSFACT(RTKSettings, fixedBasePositionAltitude)
Expand Down
18 changes: 17 additions & 1 deletion src/Settings/RTKSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,32 @@
#pragma once

#include "SettingsGroup.h"
#include <QObject>

// Definition of BaseMode moved here
class BaseModeDefinition {
Q_GADGET
public:
enum class Mode {
BaseSurveyIn = 0,
BaseFixed = 1
};
Q_ENUM(Mode)

private:
explicit BaseModeDefinition(); // Prevent instantiation
};

class RTKSettings : public SettingsGroup
{
Q_OBJECT
public:
RTKSettings(QObject* parent = nullptr);
DEFINE_SETTING_NAME_GROUP()
DEFINE_SETTINGFACT(baseReceiverManufacturers)
DEFINE_SETTINGFACT(surveyInAccuracyLimit)
DEFINE_SETTINGFACT(surveyInMinObservationDuration)
DEFINE_SETTINGFACT(useFixedBasePosition)
DEFINE_SETTINGFACT(baseMode)
DEFINE_SETTINGFACT(fixedBasePositionLatitude)
DEFINE_SETTINGFACT(fixedBasePositionLongitude)
DEFINE_SETTINGFACT(fixedBasePositionAltitude)
Expand Down
Loading