Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
600008e2
Commit
600008e2
authored
Jun 22, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dealing with brief features and telemetry.
parent
4283729f
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
124 additions
and
52 deletions
+124
-52
AirMapFlightPlanManager.cc
src/Airmap/AirMapFlightPlanManager.cc
+66
-39
AirMapFlightPlanManager.h
src/Airmap/AirMapFlightPlanManager.h
+5
-2
AirMapManager.cc
src/Airmap/AirMapManager.cc
+2
-2
AirMapRulesetsManager.cc
src/Airmap/AirMapRulesetsManager.cc
+28
-0
AirMapRulesetsManager.h
src/Airmap/AirMapRulesetsManager.h
+1
-1
AirMapTelemetry.cc
src/Airmap/AirMapTelemetry.cc
+1
-0
AirMapVehicleManager.cc
src/Airmap/AirMapVehicleManager.cc
+13
-5
AirmapSettings.qml
src/Airmap/AirmapSettings.qml
+2
-2
FlightFeature.qml
src/Airmap/FlightFeature.qml
+3
-1
AirspaceVehicleManager.cc
src/AirspaceManagement/AirspaceVehicleManager.cc
+3
-0
No files found.
src/Airmap/AirMapFlightPlanManager.cc
View file @
600008e2
...
...
@@ -254,7 +254,7 @@ AirMapFlightPlanManager::updateFlightPlan()
}
_flightPermitStatus
=
AirspaceFlightPlanProvider
::
PermitPending
;
emit
flightPermitStatusChanged
();
_updateFlightPlan
();
_updateFlightPlan
(
true
);
}
//-----------------------------------------------------------------------------
...
...
@@ -373,9 +373,6 @@ AirMapFlightPlanManager::_createFlightPlan()
qCDebug
(
AirMapManagerLog
)
<<
"Flight Start:"
<<
flightStartTime
().
toString
();
qCDebug
(
AirMapManagerLog
)
<<
"Flight End: "
<<
flightEndTime
().
toString
();
//-- Not Yet
//return;
if
(
_pilotID
==
""
)
{
//-- Need to get the pilot id before uploading the flight plan
qCDebug
(
AirMapManagerLog
)
<<
"Getting pilot ID"
;
...
...
@@ -413,7 +410,7 @@ AirMapFlightPlanManager::_createFlightPlan()
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_updateRulesAndFeatures
(
std
::
vector
<
RuleSet
::
Id
>&
rulesets
,
std
::
unordered_map
<
std
::
string
,
RuleSet
::
Feature
::
Value
>&
features
)
AirMapFlightPlanManager
::
_updateRulesAndFeatures
(
std
::
vector
<
RuleSet
::
Id
>&
rulesets
,
std
::
unordered_map
<
std
::
string
,
RuleSet
::
Feature
::
Value
>&
features
,
bool
updateFeatures
)
{
AirMapRulesetsManager
*
pRulesMgr
=
dynamic_cast
<
AirMapRulesetsManager
*>
(
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
ruleSets
());
if
(
pRulesMgr
)
{
...
...
@@ -422,18 +419,25 @@ AirMapFlightPlanManager::_updateRulesAndFeatures(std::vector<RuleSet::Id>& rules
//-- If this ruleset is selected
if
(
ruleSet
&&
ruleSet
->
selected
())
{
rulesets
.
push_back
(
ruleSet
->
id
().
toStdString
());
//-- Features within each rule
//-- Features within each rule (only when updating)
if
(
updateFeatures
)
{
for
(
int
r
=
0
;
r
<
ruleSet
->
rules
()
->
count
();
r
++
)
{
AirMapRule
*
rule
=
qobject_cast
<
AirMapRule
*>
(
ruleSet
->
rules
()
->
get
(
r
));
if
(
rule
)
{
for
(
int
f
=
0
;
f
<
rule
->
features
()
->
count
();
f
++
)
{
AirMapRuleFeature
*
feature
=
qobject_cast
<
AirMapRuleFeature
*>
(
rule
->
features
()
->
get
(
f
));
if
(
features
.
find
(
feature
->
name
().
toStdString
())
!=
features
.
end
())
{
qCDebug
(
AirMapManagerLog
)
<<
"Removing duplicate:"
<<
feature
->
name
();
continue
;
}
if
(
feature
&&
feature
->
value
().
isValid
())
{
switch
(
feature
->
type
())
{
case
AirspaceRuleFeature
:
:
Boolean
:
//-- Skip not set responses (feature->value is initialized to "2")
if
(
feature
->
value
().
toInt
()
==
0
||
feature
->
value
().
toInt
()
==
1
)
{
features
[
feature
->
name
().
toStdString
()]
=
RuleSet
::
Feature
::
Value
(
feature
->
value
().
toBool
());
}
else
{
//-- If not set, default to false
features
[
feature
->
name
().
toStdString
()]
=
RuleSet
::
Feature
::
Value
(
false
);
}
break
;
case
AirspaceRuleFeature
:
:
Float
:
...
...
@@ -458,6 +462,7 @@ AirMapFlightPlanManager::_updateRulesAndFeatures(std::vector<RuleSet::Id>& rules
}
}
}
}
}
//-----------------------------------------------------------------------------
...
...
@@ -516,15 +521,19 @@ AirMapFlightPlanManager::_uploadFlightPlan()
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_updateFlightPlan
()
AirMapFlightPlanManager
::
_updateFlightPlan
OnTimer
()
{
//-- TODO: This is broken as the parameters for updating the plan have
// little to do with those used when creating it.
_updateFlightPlan
(
false
);
}
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_updateFlightPlan
(
bool
interactive
)
{
qCDebug
(
AirMapManagerLog
)
<<
"Updating flight plan. State:"
<<
(
int
)
_state
;
if
(
_state
!=
State
::
Idle
)
{
QTimer
::
singleShot
(
100
,
this
,
&
AirMapFlightPlanManager
::
_updateFlightPlan
);
QTimer
::
singleShot
(
100
,
this
,
&
AirMapFlightPlanManager
::
_updateFlightPlan
OnTimer
);
return
;
}
//-- Get flight data
...
...
@@ -546,7 +555,8 @@ AirMapFlightPlanManager::_updateFlightPlan()
//-- Rules & Features
_flightPlan
.
rulesets
.
clear
();
_flightPlan
.
features
.
clear
();
_updateRulesAndFeatures
(
_flightPlan
.
rulesets
,
_flightPlan
.
features
);
//-- If interactive, we collect features otherwise we don't
_updateRulesAndFeatures
(
_flightPlan
.
rulesets
,
_flightPlan
.
features
,
interactive
);
//-- Geometry: polygon
Geometry
::
Polygon
polygon
;
for
(
const
auto
&
qcoord
:
_flight
.
coords
)
{
...
...
@@ -600,6 +610,19 @@ rules_sort(QObject* a, QObject* b)
return
(
int
)
aa
->
status
()
>
(
int
)
bb
->
status
();
}
//-----------------------------------------------------------------------------
bool
AirMapFlightPlanManager
::
_findBriefFeature
(
const
QString
&
name
)
{
for
(
int
i
=
0
;
i
<
_briefFeatures
.
count
();
i
++
)
{
AirMapRuleFeature
*
feature
=
qobject_cast
<
AirMapRuleFeature
*>
(
_briefFeatures
.
get
(
i
));
if
(
feature
&&
feature
->
name
()
==
name
)
{
return
true
;
}
}
return
false
;
}
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_pollBriefing
()
...
...
@@ -657,8 +680,12 @@ AirMapFlightPlanManager::_pollBriefing()
AirMapRuleFeature
*
pFeature
=
new
AirMapRuleFeature
(
feature
,
this
);
pRule
->
_features
.
append
(
pFeature
);
if
(
rule
.
status
==
RuleSet
::
Rule
::
Status
::
missing_info
)
{
if
(
!
_findBriefFeature
(
pFeature
->
name
()))
{
_briefFeatures
.
append
(
pFeature
);
qCDebug
(
AirMapManagerLog
)
<<
"Adding briefing feature"
<<
pFeature
->
name
()
<<
pFeature
->
description
()
<<
pFeature
->
type
();
}
else
{
qCDebug
(
AirMapManagerLog
)
<<
"Skipping briefing feature duplicate"
<<
pFeature
->
name
()
<<
pFeature
->
description
()
<<
pFeature
->
type
();
}
}
}
pRuleSet
->
_rules
.
append
(
pRule
);
...
...
src/Airmap/AirMapFlightPlanManager.h
View file @
600008e2
...
...
@@ -90,6 +90,7 @@ public:
AirspaceFlightModel
*
flightList
()
override
{
return
&
_flightList
;
}
bool
loadingFlightList
()
override
{
return
_loadingFlightList
;
}
QString
flightPlanID
()
{
return
QString
::
fromStdString
(
_flightPlan
.
id
);
}
QString
flightID
()
{
return
_flightId
;
}
void
updateFlightPlan
()
override
;
void
submitFlightPlan
()
override
;
...
...
@@ -107,13 +108,15 @@ private slots:
void
_missionChanged
();
void
_endFlight
();
void
_uploadFlightPlan
();
void
_updateFlightPlan
();
void
_updateFlightPlan
OnTimer
();
void
_loadFlightList
();
private:
void
_createFlightPlan
();
bool
_collectFlightDtata
();
void
_updateRulesAndFeatures
(
std
::
vector
<
airmap
::
RuleSet
::
Id
>&
rulesets
,
std
::
unordered_map
<
std
::
string
,
airmap
::
RuleSet
::
Feature
::
Value
>&
features
);
void
_updateFlightPlan
(
bool
interactive
=
false
);
bool
_findBriefFeature
(
const
QString
&
name
);
void
_updateRulesAndFeatures
(
std
::
vector
<
airmap
::
RuleSet
::
Id
>&
rulesets
,
std
::
unordered_map
<
std
::
string
,
airmap
::
RuleSet
::
Feature
::
Value
>&
features
,
bool
updateFeatures
=
false
);
private:
enum
class
State
{
...
...
src/Airmap/AirMapManager.cc
View file @
600008e2
...
...
@@ -42,8 +42,8 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox)
{
_logger
=
std
::
make_shared
<
qt
::
Logger
>
();
qt
::
register_types
();
// TODO: still needed?
_logger
->
logging_category
().
setEnabled
(
QtDebugMsg
,
tru
e
);
_logger
->
logging_category
().
setEnabled
(
QtInfoMsg
,
tru
e
);
_logger
->
logging_category
().
setEnabled
(
QtDebugMsg
,
fals
e
);
_logger
->
logging_category
().
setEnabled
(
QtInfoMsg
,
fals
e
);
_logger
->
logging_category
().
setEnabled
(
QtWarningMsg
,
false
);
_dispatchingLogger
=
std
::
make_shared
<
qt
::
DispatchingLogger
>
(
_logger
);
connect
(
&
_shared
,
&
AirMapSharedState
::
error
,
this
,
&
AirMapManager
::
_error
);
...
...
src/Airmap/AirMapRulesetsManager.cc
View file @
600008e2
...
...
@@ -31,6 +31,7 @@ AirMapRuleFeature::AirMapRuleFeature(airmap::RuleSet::Feature feature, QObject*
settings
.
beginGroup
(
kAirMapFeatureGroup
);
switch
(
_feature
.
type
)
{
case
RuleSet
:
:
Feature
::
Type
::
boolean
:
//-- For boolean, we have 3 states: 0 - false, 1 - true and 2 - not set
_value
=
settings
.
value
(
name
(),
2
);
break
;;
case
RuleSet
:
:
Feature
::
Type
::
floating_point
:
...
...
@@ -45,6 +46,14 @@ AirMapRuleFeature::AirMapRuleFeature(airmap::RuleSet::Feature feature, QObject*
settings
.
endGroup
();
}
//-----------------------------------------------------------------------------
QVariant
AirMapRuleFeature
::
value
()
{
//qCDebug(AirMapManagerLog) << "Value of" << name() << "==>" << _value << type();
return
_value
;
}
//-----------------------------------------------------------------------------
AirspaceRuleFeature
::
Type
AirMapRuleFeature
::
type
()
...
...
@@ -100,6 +109,25 @@ AirMapRuleFeature::measurement()
void
AirMapRuleFeature
::
setValue
(
const
QVariant
val
)
{
switch
(
_feature
.
type
)
{
case
RuleSet
:
:
Feature
::
Type
::
boolean
:
if
(
val
.
toInt
()
!=
0
&&
val
.
toInt
()
!=
1
)
{
return
;
}
break
;
case
RuleSet
:
:
Feature
::
Type
::
floating_point
:
if
(
!
std
::
isfinite
(
val
.
toDouble
()))
{
return
;
}
break
;;
case
RuleSet
:
:
Feature
::
Type
::
string
:
if
(
val
.
toString
().
isEmpty
())
{
return
;
}
break
;;
default:
return
;
}
_value
=
val
;
//-- Make value persistent
QSettings
settings
;
...
...
src/Airmap/AirMapRulesetsManager.h
View file @
600008e2
...
...
@@ -39,7 +39,7 @@ public:
Measurement
measurement
()
override
;
QString
name
()
override
{
return
QString
::
fromStdString
(
_feature
.
name
);
}
QString
description
()
override
{
return
QString
::
fromStdString
(
_feature
.
description
);
}
QVariant
value
()
override
{
return
_value
;
}
QVariant
value
()
override
;
void
setValue
(
const
QVariant
val
)
override
;
private:
airmap
::
RuleSet
::
Feature
_feature
;
...
...
src/Airmap/AirMapTelemetry.cc
View file @
600008e2
...
...
@@ -84,6 +84,7 @@ AirMapTelemetry::_handleGlobalPositionInt(const mavlink_message_t& message)
globalPosition
.
vz
/
100.
f
};
//qCDebug(AirMapManagerLog) << "Telemetry:" << globalPosition.lat / 1e7 << globalPosition.lon / 1e7;
Flight
flight
;
flight
.
id
=
_flightID
.
toStdString
();
_shared
.
client
()
->
telemetry
().
submit_updates
(
flight
,
_key
,
...
...
src/Airmap/AirMapVehicleManager.cc
View file @
600008e2
...
...
@@ -7,9 +7,12 @@
*
****************************************************************************/
#include "AirspaceFlightPlanProvider.h"
#include "AirMapFlightPlanManager.h"
#include "AirMapVehicleManager.h"
#include "AirMapManager.h"
#include "QGCApplication.h"
#include "Vehicle.h"
//-----------------------------------------------------------------------------
...
...
@@ -30,9 +33,13 @@ AirMapVehicleManager::AirMapVehicleManager(AirMapSharedState& shared, const Vehi
void
AirMapVehicleManager
::
startTelemetryStream
()
{
if
(
!
_flightManager
.
flightID
().
isEmpty
())
{
//-- TODO: This will start telemetry using the current flight ID in memory
_telemetry
.
startTelemetryStream
(
_flightManager
.
flightID
());
AirMapFlightPlanManager
*
planMgr
=
(
AirMapFlightPlanManager
*
)
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
flightPlan
();
if
(
!
planMgr
->
flightID
().
isEmpty
())
{
//-- TODO: This will start telemetry using the current flight ID in memory (current flight in AirMapFlightPlanManager)
qCDebug
(
AirMapManagerLog
)
<<
"AirMap telemetry stream enabled"
;
_telemetry
.
startTelemetryStream
(
planMgr
->
flightID
());
}
else
{
qCDebug
(
AirMapManagerLog
)
<<
"AirMap telemetry stream not possible (No Flight ID)"
;
}
}
...
...
@@ -54,8 +61,9 @@ AirMapVehicleManager::isTelemetryStreaming()
void
AirMapVehicleManager
::
endFlight
()
{
if
(
!
_flightManager
.
flightID
().
isEmpty
())
{
_flightManager
.
endFlight
(
_flightManager
.
flightID
());
AirMapFlightPlanManager
*
planMgr
=
(
AirMapFlightPlanManager
*
)
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
flightPlan
();
if
(
!
planMgr
->
flightID
().
isEmpty
())
{
_flightManager
.
endFlight
(
planMgr
->
flightID
());
}
_trafficMonitor
.
stop
();
}
...
...
src/Airmap/AirmapSettings.qml
View file @
600008e2
...
...
@@ -312,11 +312,11 @@ QGCView {
anchors.fill
:
parent
TableView
{
id
:
tableView
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
model
:
_flightList
selectionMode
:
SelectionMode
.
SingleSelection
Layout.alignment
:
Qt
.
AlignVCenter
Layout.fillWidth
:
true
Layout.fillHeight
:
true
onCurrentRowChanged
:
{
var
o
=
_flightList
.
get
(
tableView
.
currentRow
)
if
(
o
)
{
...
...
src/Airmap/FlightFeature.qml
View file @
600008e2
...
...
@@ -56,10 +56,12 @@ Rectangle {
QGCCheckBox
{
id
:
checkBox
text
:
""
checked
:
feature
.
value
&&
feature
.
value
<
2
?
feature
.
value
:
false
onClicked
:
feature
.
value
=
checked
anchors.left
:
parent
.
left
anchors.verticalCenter
:
parent
.
verticalCenter
Component.onCompleted
:
{
checked
=
feature
.
value
&&
feature
.
value
<
2
?
feature
.
value
:
false
}
}
QGCLabel
{
id
:
label
...
...
src/AirspaceManagement/AirspaceVehicleManager.cc
View file @
600008e2
...
...
@@ -16,6 +16,7 @@
AirspaceVehicleManager
::
AirspaceVehicleManager
(
const
Vehicle
&
vehicle
)
:
_vehicle
(
vehicle
)
{
qCDebug
(
AirspaceManagementLog
)
<<
"Instatiating AirspaceVehicleManager"
;
connect
(
&
_vehicle
,
&
Vehicle
::
armedChanged
,
this
,
&
AirspaceVehicleManager
::
_vehicleArmedChanged
);
connect
(
&
_vehicle
,
&
Vehicle
::
mavlinkMessageReceived
,
this
,
&
AirspaceVehicleManager
::
vehicleMavlinkMessageReceived
);
}
...
...
@@ -23,9 +24,11 @@ AirspaceVehicleManager::AirspaceVehicleManager(const Vehicle& vehicle)
void
AirspaceVehicleManager
::
_vehicleArmedChanged
(
bool
armed
)
{
if
(
armed
)
{
qCDebug
(
AirspaceManagementLog
)
<<
"Starting telemetry"
;
startTelemetryStream
();
_vehicleWasInMissionMode
=
_vehicle
.
flightMode
()
==
_vehicle
.
missionFlightMode
();
}
else
{
qCDebug
(
AirspaceManagementLog
)
<<
"Stopping telemetry"
;
stopTelemetryStream
();
// end the flight if we were in mission mode during arming or disarming
// TODO: needs to be improved. for instance if we do RTL and then want to continue the mission...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment