diff --git a/ChangeLog.md b/ChangeLog.md index d6c1baded032315e881239e92345adba4d52e31b..9b0a6ebd04e3593c2c0be05ce92f7ab1c2ebc7f6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,13 @@ Note: This file only contains high level features or important fixes. ## 3.4 +### 3.4.5 - Not yet released +* Plan GeoFence: Fix loading of fence from intermediate 3.4 code +* Orbit: Turn off for PX4 since still not supported +* Structure Scan: Fix loading of structure scan height +* ArduPilot: Fix location of planned home position when not connected to vehicle. Issue #6840. +* Fix loading of parameters from multiple components. Would report download complete too early, thus missing all default component params. + ### 3.4.4 - Stable * Stable desktop versions now inform user at boot if newer version is available. * Multi-Vehicle Start Mission and Pause now work correctly. Issue #6864. diff --git a/src/FactSystem/ParameterManager.cc b/src/FactSystem/ParameterManager.cc index 4c088ccd27114e729c3dd5ae969305e75eee5433..26093d6ea5761c669f549fa2b26f5f8ebae161ed 100644 --- a/src/FactSystem/ParameterManager.cc +++ b/src/FactSystem/ParameterManager.cc @@ -347,12 +347,12 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString // Add meta data to default component. We need to do this before we setup the group map since group // map requires meta data. _addMetaDataToDefaultComponent(); - } - // When we are getting the very last component param index, reset the group maps to update for the - // new params. By handling this here, we can pick up components which finish up later than the default - // component param set. - _setupCategoryMap(); + // When we are getting the very last component param index, reset the group maps to update for the + // new params. By handling this here, we can pick up components which finish up later than the default + // component param set. + _setupCategoryMap(); + } } // Update param cache. The param cache is only used on PX4 Firmware since ArduPilot and Solo have volatile params diff --git a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc index c85bb70db9289980e4e28409cda380907bc1128d..044976c00ace9100962c66ecae77d2a6a31f7232 100644 --- a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc +++ b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc @@ -233,7 +233,7 @@ bool PX4FirmwarePlugin::isCapable(const Vehicle *vehicle, FirmwareCapabilities c { int available = SetFlightModeCapability | PauseVehicleCapability | GuidedModeCapability; if (vehicle->multiRotor() || vehicle->vtol()) { - available |= TakeoffVehicleCapability | OrbitModeCapability; + available |= TakeoffVehicleCapability; } return (capabilities & available) == capabilities; diff --git a/src/MissionManager/GeoFenceController.cc b/src/MissionManager/GeoFenceController.cc index 5d3733ea1036d9aea7040711f5dc5548ef815af2..f3e004a117e5b4617af6f776fb8fba26614da4f6 100644 --- a/src/MissionManager/GeoFenceController.cc +++ b/src/MissionManager/GeoFenceController.cc @@ -123,8 +123,9 @@ bool GeoFenceController::load(const QJsonObject& json, QString& errorString) errorString.clear(); - if (json.contains(JsonHelper::jsonVersionKey) && json[JsonHelper::jsonVersionKey].toInt() == 1) { - // We just ignore old version 1 data + if (!json.contains(JsonHelper::jsonVersionKey) || + (json.contains(JsonHelper::jsonVersionKey) && json[JsonHelper::jsonVersionKey].toInt() == 1)) { + // We just ignore old version 1 or prior data return true; } diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 6f26b67c8566d98c65307b4a705670e654df6f59..e259c05b4663502a3b5003effeaa1225a0d0b351 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -375,7 +375,9 @@ int MissionController::insertSimpleMissionItem(QGeoCoordinate coordinate, int i) newItem->setMissionFlightStatus(_missionFlightStatus); _visualItems->insert(i, newItem); - _recalcAll(); + // We send the click coordinate through here to be able to set the planned home position from the user click location if needed + _recalcAllWithClickCoordinate(coordinate); + return newItem->sequenceNumber(); } @@ -1526,8 +1528,10 @@ void MissionController::_recalcChildItems(void) } } -void MissionController::_setPlannedHomePositionFromFirstCoordinate(void) +void MissionController::_setPlannedHomePositionFromFirstCoordinate(const QGeoCoordinate& clickCoordinate) { + QGeoCoordinate firstCoordinate; + if (_settingsItem->coordinate().isValid()) { return; } @@ -1537,18 +1541,28 @@ void MissionController::_setPlannedHomePositionFromFirstCoordinate(void) VisualMissionItem* item = _visualItems->value(i); if (item->specifiesCoordinate()) { - QGeoCoordinate plannedHomeCoord = item->coordinate().atDistanceAndAzimuth(30, 0); - plannedHomeCoord.setAltitude(0); - _settingsItem->setCoordinate(plannedHomeCoord); + firstCoordinate = item->coordinate(); + break; } } -} + // No item specifying a coordinate was found, in this case it we have a clickCoordinate use that + if (!firstCoordinate.isValid()) { + firstCoordinate = clickCoordinate; + } -void MissionController::_recalcAll(void) + if (firstCoordinate.isValid()) { + QGeoCoordinate plannedHomeCoord = firstCoordinate.atDistanceAndAzimuth(30, 0); + plannedHomeCoord.setAltitude(0); + _settingsItem->setCoordinate(plannedHomeCoord); + } +} + +/// @param clickCoordinate The location of the user click when inserting a new item +void MissionController::_recalcAllWithClickCoordinate(QGeoCoordinate& clickCoordinate) { if (!_flyView) { - _setPlannedHomePositionFromFirstCoordinate(); + _setPlannedHomePositionFromFirstCoordinate(clickCoordinate); } _recalcSequence(); _recalcChildItems(); @@ -1556,6 +1570,12 @@ void MissionController::_recalcAll(void) _updateTimer.start(UPDATE_TIMEOUT); } +void MissionController::_recalcAll(void) +{ + QGeoCoordinate emptyCoord; + _recalcAllWithClickCoordinate(emptyCoord); +} + /// Initializes a new set of mission items void MissionController::_initAllVisualItems(void) { diff --git a/src/MissionManager/MissionController.h b/src/MissionManager/MissionController.h index 293807f6ffd390c9fa01187c69dd529eeeff33e4..127d1ed1a7e989bc3e2adecf374187251044fa75 100644 --- a/src/MissionManager/MissionController.h +++ b/src/MissionManager/MissionController.h @@ -234,12 +234,13 @@ private slots: void _managerRemoveAllComplete(bool error); void _updateTimeout(); void _complexBoundingBoxChanged(); + void _recalcAll(void); private: void _init(void); void _recalcSequence(void); void _recalcChildItems(void); - void _recalcAll(void); + void _recalcAllWithClickCoordinate(QGeoCoordinate& clickCoordinate); void _initAllVisualItems(void); void _deinitAllVisualItems(void); void _initVisualItem(VisualMissionItem* item); @@ -258,7 +259,7 @@ private: int _nextSequenceNumber(void); void _scanForAdditionalSettings(QmlObjectListModel* visualItems, Vehicle* vehicle); static bool _convertToMissionItems(QmlObjectListModel* visualMissionItems, QList& rgMissionItems, QObject* missionItemParent); - void _setPlannedHomePositionFromFirstCoordinate(void); + void _setPlannedHomePositionFromFirstCoordinate(const QGeoCoordinate& clickCoordinate); void _resetMissionFlightStatus(void); void _addHoverTime(double hoverTime, double hoverDistance, int waypointIndex); void _addCruiseTime(double cruiseTime, double cruiseDistance, int wayPointIndex); diff --git a/src/MissionManager/MissionControllerTest.cc b/src/MissionManager/MissionControllerTest.cc index de06cccfff75035fcf8242e981923bc65f236883..b6b4793c986c890b73e172f3929b61459b9d0609 100644 --- a/src/MissionManager/MissionControllerTest.cc +++ b/src/MissionManager/MissionControllerTest.cc @@ -135,9 +135,8 @@ void MissionControllerTest::_testAddWaypointWorker(MAV_AUTOPILOT firmwareType) QCOMPARE((MAV_CMD)simpleItem->command(), MAV_CMD_NAV_TAKEOFF); QCOMPARE(simpleItem->childItems()->count(), 0); - // If the first item added specifies a coordinate, then planned home position will be set - bool plannedHomePositionValue = firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA ? false : true; - QCOMPARE(settingsItem->coordinate().isValid(), plannedHomePositionValue); + // Planned home position should always be set after first item + QVERIFY(settingsItem->coordinate().isValid()); // ArduPilot takeoff command has no coordinate, so should be child item QCOMPARE(settingsItem->childItems()->count(), firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA ? 1 : 0); diff --git a/src/MissionManager/StructureScan.SettingsGroup.json b/src/MissionManager/StructureScan.SettingsGroup.json index 15ff6ce55fd8fe534e820ee0bc713a30465a4cfe..ac79f33887cf79cc1673019757be80449c2ba943 100644 --- a/src/MissionManager/StructureScan.SettingsGroup.json +++ b/src/MissionManager/StructureScan.SettingsGroup.json @@ -28,6 +28,7 @@ "name": "StructureHeight", "shortDescription": "Height of structure being scanned.", "type": "double", + "decimalPlaces": 2, "units": "m", "min": 1, "defaultValue": 100 diff --git a/src/MissionManager/StructureScanComplexItem.cc b/src/MissionManager/StructureScanComplexItem.cc index b84a1d23215e07dde15a9e1cd34dd7f88d231484..3928afc46c45a72222a48831d9e4a87c5082aca0 100644 --- a/src/MissionManager/StructureScanComplexItem.cc +++ b/src/MissionManager/StructureScanComplexItem.cc @@ -215,9 +215,11 @@ bool StructureScanComplexItem::load(const QJsonObject& complexObject, int sequen return false; } - _altitudeFact.setRawValue (complexObject[altitudeName].toDouble()); - _layersFact.setRawValue (complexObject[layersName].toDouble()); - _altitudeRelative = complexObject[_jsonAltitudeRelativeKey].toBool(true); + _altitudeFact.setRawValue (complexObject[altitudeName].toDouble()); + _layersFact.setRawValue (complexObject[layersName].toDouble()); + _structureHeightFact.setRawValue(complexObject[structureHeightName].toDouble()); + + _altitudeRelative = complexObject[_jsonAltitudeRelativeKey].toBool(true); double gimbalPitchValue = 0; if (complexObject.contains(gimbalPitchName)) {