From b7ea870fd651c97ea0b72877a44ab53b80da6c07 Mon Sep 17 00:00:00 2001 From: Nate Weibley Date: Thu, 10 Mar 2016 16:05:34 -0500 Subject: [PATCH] Implement click-to-retask via MISSION_SET_CURRENT in flight view for #2275 --- src/FlightMap/MapItems/MissionItemView.qml | 3 +-- src/MissionManager/VisualMissionItem.cc | 5 +++++ src/MissionManager/VisualMissionItem.h | 2 ++ src/Vehicle/Vehicle.cc | 10 ++++++++++ src/Vehicle/Vehicle.h | 2 ++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/FlightMap/MapItems/MissionItemView.qml b/src/FlightMap/MapItems/MissionItemView.qml index 930495398..b66ee66df 100644 --- a/src/FlightMap/MapItems/MissionItemView.qml +++ b/src/FlightMap/MapItems/MissionItemView.qml @@ -42,6 +42,7 @@ MapItemView { z: QGroundControl.zOrderMapItems missionItem: object sequenceNumber: object.sequenceNumber + onClicked: object.tryMakingCurrent() // These are the non-coordinate child mission items attached to this item Row { @@ -55,8 +56,6 @@ MapItemView { label: object.sequenceNumber isCurrentItem: object.isCurrentItem z: 2 - - onClicked: setCurrentItem(object.sequenceNumber) } } } diff --git a/src/MissionManager/VisualMissionItem.cc b/src/MissionManager/VisualMissionItem.cc index 9362e0287..6679e66b7 100644 --- a/src/MissionManager/VisualMissionItem.cc +++ b/src/MissionManager/VisualMissionItem.cc @@ -103,3 +103,8 @@ void VisualMissionItem::setAzimuth(double azimuth) _azimuth = azimuth; emit azimuthChanged(_azimuth); } + +void VisualMissionItem::tryMakingCurrent() +{ + _vehicle->setCurrentMissionSequence(sequenceNumber()); +} diff --git a/src/MissionManager/VisualMissionItem.h b/src/MissionManager/VisualMissionItem.h index d682ade1d..c10ce1427 100644 --- a/src/MissionManager/VisualMissionItem.h +++ b/src/MissionManager/VisualMissionItem.h @@ -92,6 +92,8 @@ public: /// are shown next to the exitCoordinate indidcator in the ui. Q_PROPERTY(QmlObjectListModel* childItems READ childItems CONSTANT) + Q_INVOKABLE void tryMakingCurrent(); + // Property accesors double altDifference (void) const { return _altDifference; } diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 1bc034573..7bb7ea886 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -1136,6 +1136,16 @@ void Vehicle::setFlightMode(const QString& flightMode) } } +void Vehicle::setCurrentMissionSequence(int seq) +{ + if (!_firmwarePlugin->sendHomePositionToVehicle()) { + seq--; + } + mavlink_message_t msg; + mavlink_msg_mission_set_current_pack(_mavlink->getSystemId(), _mavlink->getComponentId(), &msg, id(), _compID, seq); + sendMessage(msg); +} + bool Vehicle::hilMode(void) { return _base_mode & MAV_MODE_FLAG_HIL_ENABLED; diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 560b4ba9c..aed6bd14c 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -430,6 +430,8 @@ public: QString flightMode(void) const; void setFlightMode(const QString& flightMode); + void setCurrentMissionSequence(int seq); + bool hilMode(void); void setHilMode(bool hilMode); -- 2.22.0