Skip to content
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

Add support for UTM adapter functionality in qgroundcontrol #4

Closed
wants to merge 5 commits into from
Closed
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
6 changes: 6 additions & 0 deletions QGCExternalLibs.pri
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,9 @@ contains (DEFINES, DISABLE_ZEROCONF) {
} else {
message("Skipping support for Zeroconf (unsupported platform)")
}

# UTM Adapter Enabled
contains (DEFINES, CONFIG_UTM_ADAPTER){
INCLUDEPATH += $$PWD/libs/libevents/libevents/libs/cpp/parse/nlohmann_json/include
LIBS += -lboost_system -lboost_thread -lssl -lcrypto
}
46 changes: 46 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -1451,3 +1451,49 @@ LinuxBuild {

INSTALLS += target share_qgroundcontrol share_icons share_metainfo share_applications
}

# UTM Adapter Enabled
contains (DEFINES, CONFIG_UTM_ADAPTER) {

#-- To test with UTM Adapter Enabled Flag
LIBS += -lboost_system -lboost_thread -lssl -lcrypto
INCLUDEPATH += \
src/UTMSP \

RESOURCES += \
src/UTMSP/utmsp.qrc

HEADERS += \
src/UTMSP/UTMSPLogger.h \
src/UTMSP/UTMSPRestInterface.h \
src/UTMSP/UTMSPBlenderRestInterface.h \
src/UTMSP/UTMSPAuthorization.h \
src/UTMSP/UTMSPNetworkRemoteIDManager.h \
src/UTMSP/UTMSPAircraft.h \
src/UTMSP/UTMSPFlightDetails.h \
src/UTMSP/UTMSPOperator.h \
src/UTMSP/UTMSPFlightPlanManager.h \
src/UTMSP/UTMSPServiceController.h \
src/UTMSP/UTMSPVehicle.h \
src/UTMSP/UTMSPManager.h

SOURCES += \
src/UTMSP/UTMSPRestInterface.cpp \
src/UTMSP/UTMSPBlenderRestInterface.cpp \
src/UTMSP/UTMSPAuthorization.cpp \
src/UTMSP/UTMSPNetworkRemoteIDManager.cpp \
src/UTMSP/UTMSPAircraft.cpp \
src/UTMSP/UTMSPFlightDetails.cpp \
src/UTMSP/UTMSPOperator.cpp \
src/UTMSP/UTMSPFlightPlanManager.cpp \
src/UTMSP/UTMSPServiceController.cpp \
src/UTMSP/UTMSPVehicle.cpp \
src/UTMSP/UTMSPManager.cpp
}
else {
#-- Dummy UTM Adapter resource file created to override UTM adapter qml files
INCLUDEPATH += \
src/UTMSP/dummy
RESOURCES += \
src/UTMSP/dummy/utmsp_dummy.qrc
}
4 changes: 4 additions & 0 deletions src/FlightDisplay/FlyView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Item {
property var planController: _planController
property var guidedController: _guidedController

// Properties of UTM adapter
property bool utmspSendActTrigger

PlanMasterController {
id: _planController
flyView: true
Expand Down Expand Up @@ -83,6 +86,7 @@ Item {
parentToolInsets: _toolInsets
mapControl: _mapControl
visible: !QGroundControl.videoManager.fullScreen
utmspActTrigger: utmspSendActTrigger
}


Expand Down
3 changes: 3 additions & 0 deletions src/FlightDisplay/FlyViewWidgetLayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Item {
property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
property alias _gripperMenu: gripperOptions

property bool utmspActTrigger

QGCToolInsets {
id: _totalToolInsets
leftEdgeTopInset: toolStrip.leftEdgeTopInset
Expand Down Expand Up @@ -113,6 +115,7 @@ Item {
z: QGroundControl.zOrderTopMost
guidedController: _guidedController
guidedValueSlider: _guidedValueSlider
utmspSliderTrigger: utmspActTrigger
}

FlyViewInstrumentPanel {
Expand Down
8 changes: 7 additions & 1 deletion src/FlightDisplay/GuidedActionConfirm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Rectangle {
height: mainLayout.height + (_margins * 2)
radius: ScreenTools.defaultFontPixelWidth / 2
color: qgcPal.window
visible: false
visible: _utmspEnabled === true ? utmspSliderTrigger: false

property var guidedController
property var guidedValueSlider
Expand All @@ -38,6 +38,10 @@ Rectangle {
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property bool _emergencyAction: action === guidedController.actionEmergencyStop

// Properties of UTM adapter
property bool utmspSliderTrigger
property bool _utmspEnabled: QGroundControl.utmspSupported

Component.onCompleted: guidedController.confirmDialog = this

onVisibleChanged: {
Expand Down Expand Up @@ -112,6 +116,8 @@ Rectangle {
id: slider
confirmText: ScreenTools.isMobile ? qsTr("Slide to confirm") : qsTr("Slide or hold spacebar")
Layout.fillWidth: true
enabled: _utmspEnabled === true? utmspSliderTrigger : true
opacity: if(_utmspEnabled){utmspSliderTrigger === true ? 1 : 0.5} else{1}

onAccept: {
_root.visible = false
Expand Down
45 changes: 45 additions & 0 deletions src/MissionManager/GeoFenceController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,3 +602,48 @@ bool GeoFenceController::isEmpty(void) const
return _polygons.count() == 0 && _circles.count() == 0 && !_breachReturnPoint.isValid();

}

#ifdef CONFIG_UTM_ADAPTER
void GeoFenceController::loadFlightPlanData()
{
QJsonArray jsonPolygonArray;
QJsonDocument doc;
QList<QGeoCoordinate> geoCoordinates ;

for (int i = 0; i < _polygons.count(); i++) {
QJsonObject jsonPolygon;
QGCFencePolygon* fencePolygon = _polygons.value<QGCFencePolygon*>(i);
fencePolygon->saveToJson(jsonPolygon);
jsonPolygonArray.append(jsonPolygon);
}
doc.setArray(jsonPolygonArray);
QString dataToString(doc.toJson());

// Parse the JSON string into a QJsonArray
QJsonDocument polygonDoc = QJsonDocument::fromJson(dataToString.toUtf8());
QJsonArray jsonArray = polygonDoc.array();
QJsonObject jsonObject = jsonArray.at(0).toObject();
QJsonArray polygonArray = jsonObject.value("polygon").toArray();

for (int i = 0; i < polygonArray.size(); ++i) {
QJsonArray pointArray = polygonArray.at(i).toArray();
double latitude = pointArray.at(0).toDouble();
double longitude = pointArray.at(1).toDouble();
QGeoCoordinate geoCoordinate(latitude, longitude);
geoCoordinates.append(geoCoordinate);
}

// Append the first coordinate again to the end of the list
if (!geoCoordinates.isEmpty()) {
geoCoordinates.append(geoCoordinates.first());
}

emit polygonBoundarySent(geoCoordinates);
}
bool GeoFenceController::loadUploadFlag()
{
emit uploadFlagSent(true);

return true;
}
#endif
10 changes: 10 additions & 0 deletions src/MissionManager/GeoFenceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class GeoFenceController : public PlanElementController
/// Clears the interactive bit from all fence items
Q_INVOKABLE void clearAllInteractive(void);

#ifdef CONFIG_UTM_ADAPTER
Q_INVOKABLE void loadFlightPlanData(void);
Q_INVOKABLE bool loadUploadFlag(void);
#endif

double paramCircularFence (void);
Fact* breachReturnAltitude(void) { return &_breachReturnAltitudeFact; }

Expand Down Expand Up @@ -90,6 +95,11 @@ class GeoFenceController : public PlanElementController
void loadComplete (void);
void paramCircularFenceChanged (void);

#ifdef CONFIG_UTM_ADAPTER
void uploadFlagSent (bool flag);
void polygonBoundarySent (QList<QGeoCoordinate> coords);
#endif

private slots:
void _polygonDirtyChanged (bool dirty);
void _setDirty (void);
Expand Down
12 changes: 10 additions & 2 deletions src/MissionManager/QGCMapPolygonVisuals.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Item {
property string _instructionText: _polygonToolsText
property var _savedVertices: [ ]
property bool _savedCircleMode
property bool _utmspEnabled: QGroundControl.utmspSupported

property real _zorderDragHandle: QGroundControl.zOrderMapItems + 3 // Highest to prevent splitting when items overlap
property real _zorderSplitHandle: QGroundControl.zOrderMapItems + 2
Expand Down Expand Up @@ -575,8 +576,15 @@ Item {
z: QGroundControl.zOrderMapItems + 1 // Over item indicators

onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton && _root.interactive) {
mapPolygon.appendVertex(mapControl.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */))
if(_utmspEnabled){
if (mouse.button === Qt.LeftButton) {
mapPolygon.appendVertex(mapControl.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */))
}
}
else{
if (mouse.button === Qt.LeftButton && _root.interactive) {
mapPolygon.appendVertex(mapControl.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */))
}
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions src/PlanView/PlanToolBarIndicators.qml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ Item {

readonly property real _margins: ScreenTools.defaultFontPixelWidth

// Properties of UTM adapter
property var _utmspController: _planMasterController.geoFenceController
property bool _utmspEnabled: QGroundControl.utmspSupported
property bool responseFlag
// Dummy object when utm adapter flag is not enabled
QtObject {
id: dummyTarget
signal uploadFlagSent(bool flag)
}
Connections {
target: _utmspEnabled ? _utmspController: dummyTarget
onUploadFlagSent: function(flag) {
responseFlag = flag
}
}

function getMissionTime() {
if (!_missionTime) {
return "00:00:00"
Expand Down Expand Up @@ -244,10 +260,18 @@ Item {
QGCButton {
id: uploadButton
text: _controllerDirty ? qsTr("Upload Required") : qsTr("Upload")
enabled: !_controllerSyncInProgress
enabled: _utmspEnabled ? !_controllerSyncInProgress && responseFlag : !_controllerSyncInProgress
visible: !_controllerOffline && !_controllerSyncInProgress && !uploadCompleteText.visible
primary: _controllerDirty
onClicked: _planMasterController.upload()
onClicked: {
if(_utmspEnabled){
_planMasterController.upload()
QGroundControl.utmspManager.utmspVehicle.triggerUploadButton(true)
}
else{
_planMasterController.upload()
}
}

PropertyAnimation on opacity {
easing.type: Easing.OutQuart
Expand Down
Loading
Loading