Unverified Commit 5b94043d authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6051 from DonLakeFlyer/StructureHeight

Structure Scan: Structure height support
parents cf4bbcc9 37c29077
......@@ -21,8 +21,9 @@ public:
CameraCalc(Vehicle* vehicle, QObject* parent = NULL);
Q_PROPERTY(QString cameraName READ cameraName WRITE setCameraName NOTIFY cameraNameChanged)
Q_PROPERTY(QString customCameraName READ customCameraName CONSTANT) // Camera name for custom camera setting
Q_PROPERTY(QString manualCameraName READ manualCameraName CONSTANT) // Camera name for manual camera setting
Q_PROPERTY(QString customCameraName READ customCameraName CONSTANT) ///< Camera name for custom camera setting
Q_PROPERTY(QString manualCameraName READ manualCameraName CONSTANT) ///< Camera name for manual camera setting
Q_PROPERTY(bool isManualCamera READ isManualCamera NOTIFY cameraNameChanged) ///< true: using manual camera
Q_PROPERTY(Fact* valueSetIsDistance READ valueSetIsDistance CONSTANT) ///< true: distance specified, resolution calculated
Q_PROPERTY(Fact* distanceToSurface READ distanceToSurface CONSTANT) ///< Distance to surface for image foot print calculation
Q_PROPERTY(Fact* imageDensity READ imageDensity CONSTANT) ///< Image density on surface (cm/px)
......@@ -48,8 +49,9 @@ public:
Fact* adjustedFootprintSide (void) { return &_adjustedFootprintSideFact; }
Fact* adjustedFootprintFrontal (void) { return &_adjustedFootprintFrontalFact; }
double imageFootprintSide (void) const { return _imageFootprintSide; }
double imageFootprintFrontal (void) const { return _imageFootprintFrontal; }
bool isManualCamera (void) { return cameraName() == manualCameraName(); }
double imageFootprintSide (void) const { return _imageFootprintSide; }
double imageFootprintFrontal (void) const { return _imageFootprintFrontal; }
bool dirty (void) const { return _dirty; }
void setDirty (bool dirty);
......
......@@ -302,6 +302,6 @@ void MissionSettingsItem::_setHomeAltFromTerrain(double terrainAltitude)
_plannedHomePositionAltitudeFact.setSendValueChangedSignals(false);
_plannedHomePositionAltitudeFact.setRawValue(terrainAltitude);
_plannedHomePositionAltitudeFact.clearDeferredValueChangeSignal();
_plannedHomePositionAltitudeFact.setSendValueChangedSignals(false);
_plannedHomePositionAltitudeFact.setSendValueChangedSignals(true);
}
}
......@@ -22,6 +22,7 @@
QGC_LOGGING_CATEGORY(StructureScanComplexItemLog, "StructureScanComplexItemLog")
const char* StructureScanComplexItem::_altitudeFactName = "Altitude";
const char* StructureScanComplexItem::_structureHeightFactName = "StructureHeight";
const char* StructureScanComplexItem::_layersFactName = "Layers";
const char* StructureScanComplexItem::_gimbalPitchFactName = "GimbalPitch";
const char* StructureScanComplexItem::_gimbalYawFactName = "GimbalYaw";
......@@ -71,6 +72,10 @@ StructureScanComplexItem::StructureScanComplexItem(Vehicle* vehicle, QObject* pa
connect(&_gimbalPitchFact, &Fact::valueChanged, this, &StructureScanComplexItem::_setDirty);
connect(&_gimbalYawFact, &Fact::valueChanged, this, &StructureScanComplexItem::_setDirty);
connect(&_layersFact, &Fact::valueChanged, this, &StructureScanComplexItem::_recalcLayerInfo);
connect(&_structureHeightFact, &Fact::valueChanged, this, &StructureScanComplexItem::_recalcLayerInfo);
connect(_cameraCalc.adjustedFootprintFrontal(), &Fact::valueChanged, this, &StructureScanComplexItem::_recalcLayerInfo);
connect(this, &StructureScanComplexItem::altitudeRelativeChanged, this, &StructureScanComplexItem::_setDirty);
connect(this, &StructureScanComplexItem::altitudeRelativeChanged, this, &StructureScanComplexItem::coordinateHasRelativeAltitudeChanged);
connect(this, &StructureScanComplexItem::altitudeRelativeChanged, this, &StructureScanComplexItem::exitCoordinateHasRelativeAltitudeChanged);
......@@ -89,6 +94,8 @@ StructureScanComplexItem::StructureScanComplexItem(Vehicle* vehicle, QObject* pa
connect(&_flightPolygon, &QGCMapPolygon::pathChanged, this, &StructureScanComplexItem::_recalcCameraShots);
connect(_cameraCalc.adjustedFootprintSide(), &Fact::valueChanged, this, &StructureScanComplexItem::_recalcCameraShots);
connect(&_layersFact, &Fact::valueChanged, this, &StructureScanComplexItem::_recalcCameraShots);
_recalcLayerInfo();
}
void StructureScanComplexItem::_setScanDistance(double scanDistance)
......@@ -143,13 +150,14 @@ void StructureScanComplexItem::save(QJsonArray& missionItems)
QJsonObject saveObject;
// Header
saveObject[JsonHelper::jsonVersionKey] = 1;
saveObject[JsonHelper::jsonVersionKey] = 2;
saveObject[VisualMissionItem::jsonTypeKey] = VisualMissionItem::jsonTypeComplexItemValue;
saveObject[ComplexMissionItem::jsonComplexItemTypeKey] = jsonComplexItemTypeValue;
saveObject[_gimbalPitchFactName] = _gimbalPitchFact.rawValue().toDouble();
saveObject[_gimbalYawFactName] = _gimbalYawFact.rawValue().toDouble();
saveObject[_altitudeFactName] = _altitudeFact.rawValue().toDouble();
saveObject[_structureHeightFactName] = _structureHeightFact.rawValue().toDouble();
saveObject[_jsonAltitudeRelativeKey] = _altitudeRelative;
saveObject[_layersFactName] = _layersFact.rawValue().toDouble();
......@@ -181,7 +189,8 @@ bool StructureScanComplexItem::load(const QJsonObject& complexObject, int sequen
{ _gimbalPitchFactName, QJsonValue::Double, true },
{ _gimbalYawFactName, QJsonValue::Double, true },
{ _altitudeFactName, QJsonValue::Double, true },
{ _jsonAltitudeRelativeKey, QJsonValue::Bool, false },
{ _structureHeightFactName, QJsonValue::Double, true },
{ _jsonAltitudeRelativeKey, QJsonValue::Bool, true },
{ _layersFactName, QJsonValue::Double, true },
{ _jsonCameraCalcKey, QJsonValue::Object, true },
};
......@@ -199,7 +208,7 @@ bool StructureScanComplexItem::load(const QJsonObject& complexObject, int sequen
}
int version = complexObject[JsonHelper::jsonVersionKey].toInt();
if (version != 1) {
if (version != 2) {
errorString = tr("%1 complex item version %2 not supported").arg(jsonComplexItemTypeValue).arg(version);
return false;
}
......@@ -273,7 +282,9 @@ void StructureScanComplexItem::appendMissionItems(QList<MissionItem*>& items, QO
for (int layer=0; layer<_layersFact.rawValue().toInt(); layer++) {
bool addTriggerStart = true;
double layerAltitude = baseAltitude + (layer * _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble());
// baseAltitude is the bottom of the first layer. Hence we need to move up half the distance of the camera footprint to center the camera
// within the layer.
double layerAltitude = baseAltitude + (_cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble() / 2.0) + (layer * _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble());
for (int i=0; i<_flightPolygon.count(); i++) {
QGeoCoordinate vertexCoord = _flightPolygon.vertexCoordinate(i);
......@@ -449,3 +460,20 @@ void StructureScanComplexItem::setAltitudeRelative(bool altitudeRelative)
emit altitudeRelativeChanged(altitudeRelative);
}
}
void StructureScanComplexItem::_recalcLayerInfo(void)
{
if (_cameraCalc.isManualCamera()) {
// Structure height is calculated from layer count, layer height.
_structureHeightFact.setSendValueChangedSignals(false);
_structureHeightFact.setRawValue(_layersFact.rawValue().toInt() * _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble());
_structureHeightFact.clearDeferredValueChangeSignal();
_structureHeightFact.setSendValueChangedSignals(true);
} else {
// Layer count is calculated from structure and layer heights
_layersFact.setSendValueChangedSignals(false);
_layersFact.setRawValue(qCeil(_structureHeightFact.rawValue().toDouble() / _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble()));
_layersFact.clearDeferredValueChangeSignal();
_layersFact.setSendValueChangedSignals(true);
}
}
......@@ -31,6 +31,7 @@ public:
Q_PROPERTY(Fact* gimbalPitch READ gimbalPitch CONSTANT)
Q_PROPERTY(Fact* gimbalYaw READ gimbalYaw CONSTANT)
Q_PROPERTY(Fact* altitude READ altitude CONSTANT)
Q_PROPERTY(Fact* structureHeight READ structureHeight CONSTANT)
Q_PROPERTY(Fact* layers READ layers CONSTANT)
Q_PROPERTY(bool altitudeRelative READ altitudeRelative WRITE setAltitudeRelative NOTIFY altitudeRelativeChanged)
Q_PROPERTY(int cameraShots READ cameraShots NOTIFY cameraShotsChanged)
......@@ -41,6 +42,7 @@ public:
CameraCalc* cameraCalc (void) { return &_cameraCalc; }
Fact* altitude (void) { return &_altitudeFact; }
Fact* structureHeight (void) { return &_structureHeightFact; }
Fact* layers (void) { return &_layersFact; }
bool altitudeRelative (void) const { return _altitudeRelative; }
......@@ -110,6 +112,7 @@ private slots:
void _rebuildFlightPolygon (void);
void _recalcCameraShots (void);
void _resetGimbal (void);
void _recalcLayerInfo (void);
private:
void _setExitCoordinate(const QGeoCoordinate& coordinate);
......@@ -135,11 +138,13 @@ private:
static QMap<QString, FactMetaData*> _metaDataMap;
Fact _altitudeFact;
Fact _structureHeightFact;
Fact _layersFact;
Fact _gimbalPitchFact;
Fact _gimbalYawFact;
static const char* _altitudeFactName;
static const char* _structureHeightFactName;
static const char* _layersFactName;
static const char* _gimbalPitchFactName;
static const char* _gimbalYawFactName;
......
......@@ -248,6 +248,8 @@ Column {
}
// Calculated values
/*
Taking these out for now since they take up so much space. May come back at a later time.
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
......@@ -269,6 +271,7 @@ Column {
enabled: false
}
} // GridLayout
*/
} // Column - Camera spec based ui
......
......@@ -87,7 +87,7 @@ Rectangle {
columnSpacing: ScreenTools.defaultFontPixelWidth / 2
rowSpacing: 0
columns: 3
enabled: missionItem.cameraCalc.cameraName === missionItem.cameraCalc.manualCameraName
visible: missionItem.cameraCalc.isManualCamera
Item { width: 1; height: 1 }
QGCLabel { text: qsTr("Pitch") }
......@@ -126,13 +126,27 @@ Rectangle {
rowSpacing: _margin
columns: 2
QGCLabel { text: qsTr("Layers") }
QGCLabel {
text: qsTr("Structure height")
visible: !missionItem.cameraCalc.isManualCamera
}
FactTextField {
fact: missionItem.structureHeight
Layout.fillWidth: true
visible: !missionItem.cameraCalc.isManualCamera
}
QGCLabel {
text: qsTr("# Layers")
visible: missionItem.cameraCalc.isManualCamera
}
FactTextField {
fact: missionItem.layers
Layout.fillWidth: true
visible: missionItem.cameraCalc.isManualCamera
}
QGCLabel { text: qsTr("Altitude") }
QGCLabel { text: qsTr("Bottom layer alt") }
FactTextField {
fact: missionItem.altitude
Layout.fillWidth: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment