diff --git a/ChangeLog.md b/ChangeLog.md index d67c4b62f92894a359c57ec44aad6d5403a4df73..c4e9947115641c19eb2ecc71bafd3454727bf17b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ Note: This file only contains high level features or important fixes. ### 3.6.0 - Daily Build +* Compass Instrument: Add indicators for Home, COG and Next Waypoint headings. * Log Replay: Support changing speed of playback * Basic object avoidance added to vehicles. * Added ability to set a joystick button to be single action or repeated action while the button is held down. diff --git a/qgcimages.qrc b/qgcimages.qrc index 9033a6a12cc4ec011f8ac1bf8e8acc2216a8fdc0..031ea95f2c56156268fb45afbf19d5ada73e5e5d 100644 --- a/qgcimages.qrc +++ b/qgcimages.qrc @@ -69,6 +69,8 @@ src/MissionManager/CogWheel.svg src/FlightMap/Images/compassInstrumentArrow.svg src/FlightMap/Images/compassInstrumentDial.svg + src/FlightMap/Images/compassDottedLine.svg + src/FlightMap/Images/cOGPointer.svg src/ui/toolbar/Images/Connect.svg src/FlightMap/Images/crossHair.svg src/AutoPilotPlugins/PX4/Images/DatalinkLoss.svg diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 0554db1fb93884aad138324b99cb1b6066456830..172290b5ccd1b97ad54131fd58386c0d24f03ae0 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -494,7 +494,6 @@ Item { anchors.topMargin: ScreenTools.toolbarHeight + _margins anchors.rightMargin: _margins anchors.right: parent.right - anchors.top: parent.top spacing: ScreenTools.defaultFontPixelWidth z: _mapAndVideo.z + 4 visible: QGroundControl.multiVehicleManager.vehicles.count > 1 && QGroundControl.corePlugin.options.enableMultiVehicleList @@ -519,6 +518,7 @@ Item { anchors.left: parent.left anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right anchors.bottom: parent.bottom + anchors.top: singleMultiSelector.visible? singleMultiSelector.bottom:undefined useLightColors: isBackgroundDark missionController: _missionController visible: singleVehicleView.checked && !QGroundControl.videoManager.fullScreen diff --git a/src/FlightDisplay/MultiVehicleList.qml b/src/FlightDisplay/MultiVehicleList.qml index cdb1b5cdff72c3c5fcdb421458d9d6b5a8fc2ddb..f8a7890a6f1e79d1a33b73ac0a16402e489002d3 100644 --- a/src/FlightDisplay/MultiVehicleList.qml +++ b/src/FlightDisplay/MultiVehicleList.qml @@ -135,6 +135,7 @@ Item { QGCCompassWidget { size: _widgetHeight + usedByMultipleVehicleList: true vehicle: _vehicle } diff --git a/src/FlightMap/Images/cOGPointer.svg b/src/FlightMap/Images/cOGPointer.svg new file mode 100644 index 0000000000000000000000000000000000000000..584aa6c6d0168b3f5a6dd29777ba054b60ea9c55 --- /dev/null +++ b/src/FlightMap/Images/cOGPointer.svg @@ -0,0 +1,53 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/src/FlightMap/Images/compassDottedLine.svg b/src/FlightMap/Images/compassDottedLine.svg new file mode 100644 index 0000000000000000000000000000000000000000..2ad83c477ea8899e6baf9fb91f840602c6fa8af8 --- /dev/null +++ b/src/FlightMap/Images/compassDottedLine.svg @@ -0,0 +1,50 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/src/FlightMap/Widgets/QGCCompassWidget.qml b/src/FlightMap/Widgets/QGCCompassWidget.qml index 3d2307f661a535668ccf9ddde571981863016633..a42399fcbfe8d3b483f5f49d94df5e3bc7deb6ad 100644 --- a/src/FlightMap/Widgets/QGCCompassWidget.qml +++ b/src/FlightMap/Widgets/QGCCompassWidget.qml @@ -17,10 +17,11 @@ import QtQuick 2.3 import QtGraphicalEffects 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Vehicle 1.0 -import QGroundControl.Palette 1.0 +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Vehicle 1.0 +import QGroundControl.Palette 1.0 Item { id: root @@ -30,10 +31,40 @@ Item { property real size: _defaultSize property var vehicle: null - property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10) - property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize - property int _fontSize: ScreenTools.defaultFontPointSize * _sizeRatio - property real _heading: vehicle ? vehicle.heading.rawValue : 0 + property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10) + property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize + property int _fontSize: ScreenTools.defaultFontPointSize * _sizeRatio + property real _heading: vehicle ? vehicle.heading.rawValue : 0 + property real _headingToHome: vehicle ? vehicle.headingToHome.rawValue : 0 + property real _groundSpeed: vehicle ? vehicle.groundSpeed.rawValue : 0 + property real _headingToNextWP: vehicle ? vehicle.headingToNextWP.rawValue : 0 + property real _courseOverGround:activeVehicle ? activeVehicle.gps.courseOverGround.rawValue : 0 + + property bool usedByMultipleVehicleList: false + + function isCOGAngleOK(){ + if(_groundSpeed < 0.5){ + return false + } + else{ + return vehicle && _showAdditionalIndicatorsCompass + } + } + + function isHeadingHomeOK(){ + return vehicle && _showAdditionalIndicatorsCompass && !isNaN(_headingToHome) + } + + function isHeadingToNextWPOK(){ + return vehicle && _showAdditionalIndicatorsCompass && !isNaN(_headingToNextWP) + } + + function isNoseUpLocked(){ + return _lockNoseUpCompass + } + + readonly property bool _showAdditionalIndicatorsCompass: QGroundControl.settingsManager.flyViewSettings.showAdditionalIndicatorsCompass.value && !usedByMultipleVehicleList + readonly property bool _lockNoseUpCompass: QGroundControl.settingsManager.flyViewSettings.lockNoseUpCompass.value QGCPalette { id: qgcPal; colorGroupEnabled: enabled } @@ -51,6 +82,55 @@ Item { anchors.fill: parent visible: false + + Image { + id: cOGPointer + source: isCOGAngleOK() ? "/qmlimages/cOGPointer.svg" : "" + mipmap: true + fillMode: Image.PreserveAspectFit + anchors.fill: parent + sourceSize.height: parent.height + + transform: Rotation { + property var _angle:isNoseUpLocked()?_courseOverGround-_heading:_courseOverGround + origin.x: cOGPointer.width / 2 + origin.y: cOGPointer.height / 2 + angle: _angle + } + } + + Image { + id: nextWPPointer + source: isHeadingToNextWPOK() ? "/qmlimages/compassDottedLine.svg":"" + mipmap: true + fillMode: Image.PreserveAspectFit + anchors.fill: parent + sourceSize.height: parent.height + + transform: Rotation { + property var _angle: isNoseUpLocked()?_headingToNextWP-_heading:_headingToNextWP + origin.x: cOGPointer.width / 2 + origin.y: cOGPointer.height / 2 + angle: _angle + } + } + + Image { + id: homePointer + width: size * 0.1 + source: isHeadingHomeOK() ? "/qmlimages/Home.svg" : "" + mipmap: true + fillMode: Image.PreserveAspectFit + anchors.centerIn: parent + sourceSize.width: width + + transform: Translate { + property double _angle: isNoseUpLocked()?-_heading+_headingToHome:_headingToHome + x: size/2.3 * Math.sin((_angle)*(3.14/180)) + y: - size/2.3 * Math.cos((_angle)*(3.14/180)) + } + } + Image { id: pointer width: size * 0.65 @@ -62,10 +142,11 @@ Item { transform: Rotation { origin.x: pointer.width / 2 origin.y: pointer.height / 2 - angle: _heading + angle: isNoseUpLocked()?0:_heading } } + QGCColoredImage { id: compassDial source: "/qmlimages/compassInstrumentDial.svg" @@ -74,8 +155,14 @@ Item { anchors.fill: parent sourceSize.height: parent.height color: qgcPal.text + transform: Rotation { + origin.x: compassDial.width / 2 + origin.y: compassDial.height / 2 + angle: isNoseUpLocked()?-_heading:0 + } } + Rectangle { anchors.centerIn: parent width: size * 0.35 diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 2fe5a260a740ba02c48e12ea61ef71e521071ef9..524a9a72e4f2ddc736e3ae5807d5e9f15d90644a 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -19,7 +19,7 @@ import QGroundControl.Palette 1.0 Rectangle { id: root - width: getPreferredInstrumentWidth() * 0.7 + width: getPreferredInstrumentWidth() height: _outerRadius * 4 + _valuesWidget.height radius: _outerRadius color: qgcPal.window diff --git a/src/Settings/FlyView.SettingsGroup.json b/src/Settings/FlyView.SettingsGroup.json index a426507b336cf266b239aa87c2780f410bc00401..085ed88380da344a230db5fa811249a819e22782 100644 --- a/src/Settings/FlyView.SettingsGroup.json +++ b/src/Settings/FlyView.SettingsGroup.json @@ -25,6 +25,18 @@ "type": "bool", "defaultValue": false }, +{ + "name": "showAdditionalIndicatorsCompass", + "shortDescription": "Show additional heading indicators on Compass", + "type": "bool", + "defaultValue": false +}, +{ + "name": "lockNoseUpCompass", + "shortDescription": "Lock Compass Nose-Up", + "type": "bool", + "defaultValue": false +}, { "name": "maxGoToLocationDistance", "shortDescription": "Maximum distance allowed for Go To Location.", diff --git a/src/Settings/FlyViewSettings.cc b/src/Settings/FlyViewSettings.cc index 603fed613ef6c2dbc4938af8f4765155e0292e2d..867cf2b68e9b0e7be4ed8d362cc8ad4041057e2e 100644 --- a/src/Settings/FlyViewSettings.cc +++ b/src/Settings/FlyViewSettings.cc @@ -21,4 +21,6 @@ DECLARE_SETTINGSFACT(FlyViewSettings, guidedMinimumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, guidedMaximumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, showLogReplayStatusBar) DECLARE_SETTINGSFACT(FlyViewSettings, alternateInstrumentPanel) +DECLARE_SETTINGSFACT(FlyViewSettings, showAdditionalIndicatorsCompass) +DECLARE_SETTINGSFACT(FlyViewSettings, lockNoseUpCompass) DECLARE_SETTINGSFACT(FlyViewSettings, maxGoToLocationDistance) diff --git a/src/Settings/FlyViewSettings.h b/src/Settings/FlyViewSettings.h index 67d4fd5a1c1c45d15a2d098ee247608401a8dc86..1623406d4786e3d2882376f6b988d0dad5cce823 100644 --- a/src/Settings/FlyViewSettings.h +++ b/src/Settings/FlyViewSettings.h @@ -23,5 +23,7 @@ public: DEFINE_SETTINGFACT(guidedMaximumAltitude) DEFINE_SETTINGFACT(showLogReplayStatusBar) DEFINE_SETTINGFACT(alternateInstrumentPanel) + DEFINE_SETTINGFACT(showAdditionalIndicatorsCompass) + DEFINE_SETTINGFACT(lockNoseUpCompass) DEFINE_SETTINGFACT(maxGoToLocationDistance) }; diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index efd7b6fd8cad109c771253a93655377b4a01bb63..1e88478e1ce3f16ad34e90a26a2d5d630577c950 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -73,6 +73,7 @@ const char* Vehicle::_altitudeAMSLFactName = "altitudeAMSL"; const char* Vehicle::_flightDistanceFactName = "flightDistance"; const char* Vehicle::_flightTimeFactName = "flightTime"; const char* Vehicle::_distanceToHomeFactName = "distanceToHome"; +const char* Vehicle::_headingToNextWPFactName = "headingToNextWP"; const char* Vehicle::_headingToHomeFactName = "headingToHome"; const char* Vehicle::_distanceToGCSFactName = "distanceToGCS"; const char* Vehicle::_hobbsFactName = "hobbs"; @@ -203,6 +204,7 @@ Vehicle::Vehicle(LinkInterface* link, , _flightDistanceFact (0, _flightDistanceFactName, FactMetaData::valueTypeDouble) , _flightTimeFact (0, _flightTimeFactName, FactMetaData::valueTypeElapsedTimeInSeconds) , _distanceToHomeFact (0, _distanceToHomeFactName, FactMetaData::valueTypeDouble) + , _headingToNextWPFact (0, _headingToNextWPFactName, FactMetaData::valueTypeDouble) , _headingToHomeFact (0, _headingToHomeFactName, FactMetaData::valueTypeDouble) , _distanceToGCSFact (0, _distanceToGCSFactName, FactMetaData::valueTypeDouble) , _hobbsFact (0, _hobbsFactName, FactMetaData::valueTypeString) @@ -404,6 +406,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, , _flightDistanceFact (0, _flightDistanceFactName, FactMetaData::valueTypeDouble) , _flightTimeFact (0, _flightTimeFactName, FactMetaData::valueTypeElapsedTimeInSeconds) , _distanceToHomeFact (0, _distanceToHomeFactName, FactMetaData::valueTypeDouble) + , _headingToNextWPFact (0, _headingToNextWPFactName, FactMetaData::valueTypeDouble) , _headingToHomeFact (0, _headingToHomeFactName, FactMetaData::valueTypeDouble) , _distanceToGCSFact (0, _distanceToGCSFactName, FactMetaData::valueTypeDouble) , _hobbsFact (0, _hobbsFactName, FactMetaData::valueTypeString) @@ -438,6 +441,7 @@ void Vehicle::_commonInit(void) connect(this, &Vehicle::homePositionChanged, this, &Vehicle::_updateDistanceHeadingToHome); connect(this, &Vehicle::hobbsMeterChanged, this, &Vehicle::_updateHobbsMeter); + connect(_toolbox->qgcPositionManager(), &QGCPositionManager::gcsPositionChanged, this, &Vehicle::_updateDistanceToGCS); _missionManager = new MissionManager(this); @@ -447,6 +451,7 @@ void Vehicle::_commonInit(void) connect(_missionManager, &MissionManager::newMissionItemsAvailable, this, &Vehicle::_clearTrajectoryPoints); connect(_missionManager, &MissionManager::sendComplete, this, &Vehicle::_clearCameraTriggerPoints); connect(_missionManager, &MissionManager::sendComplete, this, &Vehicle::_clearTrajectoryPoints); + connect(_missionManager, &MissionManager::currentIndexChanged, this, &Vehicle::_updateHeadingToNextWP); _parameterManager = new ParameterManager(this); connect(_parameterManager, &ParameterManager::parametersReadyChanged, this, &Vehicle::_parametersReady); @@ -481,6 +486,7 @@ void Vehicle::_commonInit(void) _addFact(&_flightDistanceFact, _flightDistanceFactName); _addFact(&_flightTimeFact, _flightTimeFactName); _addFact(&_distanceToHomeFact, _distanceToHomeFactName); + _addFact(&_headingToNextWPFact, _headingToNextWPFactName); _addFact(&_headingToHomeFact, _headingToHomeFactName); _addFact(&_distanceToGCSFact, _distanceToGCSFactName); _addFact(&_throttlePctFact, _throttlePctFactName); @@ -3795,6 +3801,23 @@ void Vehicle::_updateDistanceHeadingToHome(void) } } +void Vehicle::_updateHeadingToNextWP(void) +{ + const int _currentIndex = _missionManager->currentIndex(); + MissionItem _currentItem; + QList llist = _missionManager->missionItems(); + + if(llist.size()>_currentIndex && _currentIndex!=-1 + && llist[_currentIndex]->coordinate().longitude()!=0.0 + && coordinate().distanceTo(llist[_currentIndex]->coordinate())>5.0 ){ + + _headingToNextWPFact.setRawValue(coordinate().azimuthTo(llist[_currentIndex]->coordinate())); + } + else{ + _headingToNextWPFact.setRawValue(qQNaN()); + } +} + void Vehicle::_updateDistanceToGCS(void) { QGeoCoordinate gcsPosition = _toolbox->qgcPositionManager()->gcsPosition(); diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index f4e35b61e1472ea7e8fbc98bf086ed36f48dfde5..b989976ab326e02a409409499b94781a63a17060 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -671,6 +671,7 @@ public: Q_PROPERTY(Fact* altitudeAMSL READ altitudeAMSL CONSTANT) Q_PROPERTY(Fact* flightDistance READ flightDistance CONSTANT) Q_PROPERTY(Fact* distanceToHome READ distanceToHome CONSTANT) + Q_PROPERTY(Fact* headingToNextWP READ headingToNextWP CONSTANT) Q_PROPERTY(Fact* headingToHome READ headingToHome CONSTANT) Q_PROPERTY(Fact* distanceToGCS READ distanceToGCS CONSTANT) Q_PROPERTY(Fact* hobbs READ hobbs CONSTANT) @@ -973,6 +974,7 @@ public: Fact* altitudeAMSL (void) { return &_altitudeAMSLFact; } Fact* flightDistance (void) { return &_flightDistanceFact; } Fact* distanceToHome (void) { return &_distanceToHomeFact; } + Fact* headingToNextWP (void) { return &_headingToNextWPFact; } Fact* headingToHome (void) { return &_headingToHomeFact; } Fact* distanceToGCS (void) { return &_distanceToGCSFact; } Fact* hobbs (void) { return &_hobbsFact; } @@ -1246,6 +1248,7 @@ private slots: void _clearTrajectoryPoints(void); void _clearCameraTriggerPoints(void); void _updateDistanceHeadingToHome(void); + void _updateHeadingToNextWP(void); void _updateDistanceToGCS(void); void _updateHobbsMeter(void); void _vehicleParamLoaded(bool ready); @@ -1540,6 +1543,7 @@ private: Fact _flightDistanceFact; Fact _flightTimeFact; Fact _distanceToHomeFact; + Fact _headingToNextWPFact; Fact _headingToHomeFact; Fact _distanceToGCSFact; Fact _hobbsFact; @@ -1570,6 +1574,7 @@ private: static const char* _flightDistanceFactName; static const char* _flightTimeFactName; static const char* _distanceToHomeFactName; + static const char* _headingToNextWPFactName; static const char* _headingToHomeFactName; static const char* _distanceToGCSFactName; static const char* _hobbsFactName; diff --git a/src/Vehicle/VehicleFact.json b/src/Vehicle/VehicleFact.json index ce0b5d391e9f57a6b6b25602a12aced568df0b5c..07af7b11872e52139e35c51dcdb68d9ed971552e 100644 --- a/src/Vehicle/VehicleFact.json +++ b/src/Vehicle/VehicleFact.json @@ -104,6 +104,13 @@ "decimalPlaces": 1, "units": "m" }, +{ + "name": "headingToNextWP", + "shortDescription": "Next WP Heading", + "type": "double", + "decimalPlaces": 0, + "units": "deg" +}, { "name": "flightTime", "shortDescription": "Flight Time", diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 3491dc88e75756f6227f017476eb2b445b0d77a0..d0dc21807577c9eb0b92130a6d1b28735be12ac9 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -482,6 +482,21 @@ Rectangle { property Fact _alternateInstrumentPanel: QGroundControl.settingsManager.flyViewSettings.alternateInstrumentPanel } + FactCheckBox { + text: qsTr("Show additional heading indicators on Compass") + visible: _showAdditionalIndicatorsCompass.visible + fact: _showAdditionalIndicatorsCompass + + property Fact _showAdditionalIndicatorsCompass: QGroundControl.settingsManager.flyViewSettings.showAdditionalIndicatorsCompass + } + FactCheckBox { + text: qsTr("Lock Compass Nose-Up") + visible: _lockNoseUpCompass.visible + fact: _lockNoseUpCompass + + property Fact _lockNoseUpCompass: QGroundControl.settingsManager.flyViewSettings.lockNoseUpCompass + } + GridLayout { columns: 2