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
f109339e
Commit
f109339e
authored
Feb 22, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set mission bounding box as ROI if one exists.
parent
98088b35
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
102 additions
and
32 deletions
+102
-32
AirMapFlightPlanManager.cc
src/Airmap/AirMapFlightPlanManager.cc
+37
-11
AirMapFlightPlanManager.h
src/Airmap/AirMapFlightPlanManager.h
+4
-0
AirspaceFlightPlanProvider.h
src/AirspaceManagement/AirspaceFlightPlanProvider.h
+3
-0
AirspaceManager.cc
src/AirspaceManagement/AirspaceManager.cc
+16
-3
AirspaceManager.h
src/AirspaceManagement/AirspaceManager.h
+1
-1
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+1
-1
MissionController.cc
src/MissionManager/MissionController.cc
+2
-0
MissionController.h
src/MissionManager/MissionController.h
+2
-1
PlanView.qml
src/PlanView/PlanView.qml
+3
-3
QGCGeoBoundingCube.cc
src/QmlControls/QGCGeoBoundingCube.cc
+25
-6
QGCGeoBoundingCube.h
src/QmlControls/QGCGeoBoundingCube.h
+8
-6
No files found.
src/Airmap/AirMapFlightPlanManager.cc
View file @
f109339e
...
...
@@ -94,22 +94,24 @@ AirMapFlightPlanManager::startFlightPlanning(PlanMasterController *planControlle
}
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_c
reateFlightPlan
()
bool
AirMapFlightPlanManager
::
_c
ollectFlightDtata
()
{
_flight
.
reset
();
if
(
!
_planController
||
!
_planController
->
missionController
())
{
return
false
;
}
//-- Get flight bounding cube and prepare (box) polygon
QGCGeoBoundingCube
bc
=
_planController
->
missionController
()
->
travelBoundingCube
();
if
(
!
bc
.
area
())
{
QGCGeoBoundingCube
bc
=
*
_planController
->
missionController
()
->
travelBoundingCube
();
if
(
!
bc
.
isValid
()
||
!
bc
.
area
())
{
//-- TODO: If single point, we need to set a point and a radius instead
return
;
qCDebug
(
AirMapManagerLog
)
<<
"Not enough points for a flight plan."
;
return
false
;
}
_flight
.
maxAltitude
=
fmax
(
bc
.
pointNW
.
altitude
(),
bc
.
pointSE
.
altitude
());
_flight
.
takeoffCoord
=
_planController
->
missionController
()
->
takeoffCoordinate
();
_flight
.
coords
=
bc
.
polygon2D
();
_flight
.
bc
=
bc
;
emit
missionAreaChanged
();
//-- Flight Date/Time
if
(
_flightStartTime
.
isNull
()
||
_flightStartTime
<
QDateTime
::
currentDateTime
())
{
_flightStartTime
=
QDateTime
::
currentDateTime
().
addSecs
(
5
*
60
);
...
...
@@ -119,15 +121,28 @@ AirMapFlightPlanManager::_createFlightPlan()
_flightEndTime
=
_flightStartTime
.
addSecs
(
30
*
60
);
emit
flightEndTimeChanged
();
}
return
true
;
}
//-----------------------------------------------------------------------------
void
AirMapFlightPlanManager
::
_createFlightPlan
()
{
_flight
.
reset
();
//-- Get flight data
if
(
!
_collectFlightDtata
())
{
return
;
}
qCDebug
(
AirMapManagerLog
)
<<
"About to create flight plan"
;
qCDebug
(
AirMapManagerLog
)
<<
"Takeoff: "
<<
_flight
.
takeoffCoord
;
qCDebug
(
AirMapManagerLog
)
<<
"Bounding box:"
<<
bc
.
pointNW
<<
bc
.
pointSE
;
qCDebug
(
AirMapManagerLog
)
<<
"Bounding box:"
<<
_flight
.
bc
.
pointNW
<<
_flight
.
bc
.
pointSE
;
qCDebug
(
AirMapManagerLog
)
<<
"Flight Start:"
<<
_flightStartTime
;
qCDebug
(
AirMapManagerLog
)
<<
"Flight End: "
<<
_flightEndTime
;
//-- Not Yet
//
return;
return
;
if
(
_pilotID
==
""
)
{
//-- Need to get the pilot id before uploading the flight plan
...
...
@@ -259,6 +274,17 @@ AirMapFlightPlanManager::_updateFlightPlan()
// little to do with those used when creating it.
qCDebug
(
AirMapManagerLog
)
<<
"Updating flight plan"
;
//-- Get flight data
if
(
!
_collectFlightDtata
())
{
return
;
}
qCDebug
(
AirMapManagerLog
)
<<
"About to update the flight plan"
;
qCDebug
(
AirMapManagerLog
)
<<
"Takeoff: "
<<
_flight
.
takeoffCoord
;
qCDebug
(
AirMapManagerLog
)
<<
"Bounding box:"
<<
_flight
.
bc
.
pointNW
<<
_flight
.
bc
.
pointSE
;
qCDebug
(
AirMapManagerLog
)
<<
"Flight Start:"
<<
_flightStartTime
;
qCDebug
(
AirMapManagerLog
)
<<
"Flight End: "
<<
_flightEndTime
;
_state
=
State
::
FlightUpdate
;
std
::
weak_ptr
<
LifetimeChecker
>
isAlive
(
_instance
);
_shared
.
doRequestWithLogin
([
this
,
isAlive
](
const
QString
&
login_token
)
{
...
...
src/Airmap/AirMapFlightPlanManager.h
View file @
f109339e
...
...
@@ -36,6 +36,7 @@ public:
bool
valid
()
override
{
return
_valid
;
}
QmlObjectListModel
*
advisories
()
override
{
return
&
_advisories
;
}
QmlObjectListModel
*
ruleSets
()
override
{
return
&
_rulesets
;
}
QGCGeoBoundingCube
*
missionArea
()
override
{
return
&
_flight
.
bc
;
}
AirspaceAdvisoryProvider
::
AdvisoryColor
airspaceColor
()
override
{
return
_airspaceColor
;
}
void
startFlightPlanning
(
PlanMasterController
*
planController
)
override
;
...
...
@@ -54,6 +55,7 @@ private:
void
_updateFlightPlan
();
void
_createFlightPlan
();
void
_deleteFlightPlan
();
bool
_collectFlightDtata
();
private:
enum
class
State
{
...
...
@@ -66,10 +68,12 @@ private:
};
struct
Flight
{
QGCGeoBoundingCube
bc
;
QList
<
QGeoCoordinate
>
coords
;
QGeoCoordinate
takeoffCoord
;
float
maxAltitude
=
0
;
void
reset
()
{
bc
.
reset
();
coords
.
clear
();
maxAltitude
=
0
;
}
...
...
src/AirspaceManagement/AirspaceFlightPlanProvider.h
View file @
f109339e
...
...
@@ -46,11 +46,13 @@ public:
Q_PROPERTY
(
bool
valid
READ
valid
NOTIFY
advisoryChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
advisories
READ
advisories
NOTIFY
advisoryChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
ruleSets
READ
ruleSets
NOTIFY
advisoryChanged
)
Q_PROPERTY
(
QGCGeoBoundingCube
*
missionArea
READ
missionArea
NOTIFY
missionAreaChanged
)
Q_PROPERTY
(
AirspaceAdvisoryProvider
::
AdvisoryColor
airspaceColor
READ
airspaceColor
NOTIFY
advisoryChanged
)
virtual
PermitStatus
flightPermitStatus
()
const
{
return
PermitNone
;
}
virtual
QDateTime
flightStartTime
()
const
=
0
;
virtual
QDateTime
flightEndTime
()
const
=
0
;
virtual
QGCGeoBoundingCube
*
missionArea
()
=
0
;
virtual
bool
valid
()
=
0
;
///< Current advisory list is valid
virtual
QmlObjectListModel
*
advisories
()
=
0
;
///< List of AirspaceAdvisory
virtual
QmlObjectListModel
*
ruleSets
()
=
0
;
///< List of AirspaceRuleSet
...
...
@@ -65,4 +67,5 @@ signals:
void
flightStartTimeChanged
();
void
flightEndTimeChanged
();
void
advisoryChanged
();
void
missionAreaChanged
();
};
src/AirspaceManagement/AirspaceManager.cc
View file @
f109339e
...
...
@@ -70,15 +70,28 @@ void AirspaceManager::setToolbox(QGCToolbox* toolbox)
_flightPlan
=
_instantiateAirspaceFlightPlanProvider
();
}
void
AirspaceManager
::
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
)
void
AirspaceManager
::
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
,
bool
planView
)
{
if
(
planView
)
{
//-- Is there a mission?
if
(
_flightPlan
->
flightPermitStatus
()
!=
AirspaceFlightPlanProvider
::
PermitNone
)
{
//-- Is there a polygon to work with?
if
(
_flightPlan
->
missionArea
()
->
isValid
()
&&
_flightPlan
->
missionArea
()
->
area
()
>
0.0
)
{
_setROI
(
*
_flightPlan
->
missionArea
());
return
;
}
}
}
//-- Use screen coordinates (what you see is what you get)
_setROI
(
QGCGeoBoundingCube
(
pointNW
,
pointSE
));
}
void
AirspaceManager
::
_setROI
(
const
QGCGeoBoundingCube
&
roi
)
{
_roi
=
roi
;
_roiUpdateTimer
.
start
();
if
(
_roi
!=
roi
)
{
_roi
=
roi
;
_roiUpdateTimer
.
start
();
}
}
void
AirspaceManager
::
_updateToROI
()
...
...
src/AirspaceManagement/AirspaceManager.h
View file @
f109339e
...
...
@@ -65,7 +65,7 @@ public:
Q_PROPERTY
(
AirspaceFlightPlanProvider
*
flightPlan
READ
flightPlan
CONSTANT
)
Q_PROPERTY
(
bool
airspaceVisible
READ
airspaceVisible
WRITE
setAirspaceVisible
NOTIFY
airspaceVisibleChanged
)
Q_INVOKABLE
void
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
);
Q_INVOKABLE
void
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
,
bool
planView
);
AirspaceWeatherInfoProvider
*
weatherInfo
()
{
return
_weatherProvider
;
}
AirspaceAdvisoryProvider
*
advisories
()
{
return
_advisories
;
}
...
...
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
f109339e
...
...
@@ -62,7 +62,7 @@ FlightMap {
var
coordinateNW
=
flightMap
.
toCoordinate
(
Qt
.
point
(
0
,
0
),
false
/* clipToViewPort */
)
var
coordinateSE
=
flightMap
.
toCoordinate
(
Qt
.
point
(
width
,
height
),
false
/* clipToViewPort */
)
if
(
coordinateNW
.
isValid
&&
coordinateSE
.
isValid
)
{
QGroundControl
.
airspaceManager
.
setROI
(
coordinateNW
,
coordinateSE
)
QGroundControl
.
airspaceManager
.
setROI
(
coordinateNW
,
coordinateSE
,
false
/*planView*/
)
}
}
}
...
...
src/MissionManager/MissionController.cc
View file @
f109339e
...
...
@@ -1435,6 +1435,8 @@ void MissionController::_recalcMissionFlightStatus()
}
}
}
_updateTimer
.
start
(
UPDATE_TIMEOUT
);
}
// This will update the sequence numbers to be sequential starting from 0
...
...
src/MissionManager/MissionController.h
View file @
f109339e
...
...
@@ -90,6 +90,7 @@ public:
Q_PROPERTY
(
int
batteryChangePoint
READ
batteryChangePoint
NOTIFY
batteryChangePointChanged
)
Q_PROPERTY
(
int
batteriesRequired
READ
batteriesRequired
NOTIFY
batteriesRequiredChanged
)
Q_PROPERTY
(
QGCGeoBoundingCube
*
travelBoundingCube
READ
travelBoundingCube
NOTIFY
missionBoundingCubeChanged
)
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
...
...
@@ -125,7 +126,7 @@ public:
bool
loadJsonFile
(
QFile
&
file
,
QString
&
errorString
);
bool
loadTextFile
(
QFile
&
file
,
QString
&
errorString
);
QGCGeoBoundingCube
travelBoundingCube
()
{
return
_travelBoundingCube
;
}
QGCGeoBoundingCube
*
travelBoundingCube
()
{
return
&
_travelBoundingCube
;
}
QGeoCoordinate
takeoffCoordinate
()
{
return
_takeoffCoordinate
;
}
// Overrides from PlanElementController
...
...
src/PlanView/PlanView.qml
View file @
f109339e
...
...
@@ -73,9 +73,9 @@ QGCView {
function
addComplexItem
(
complexItemName
)
{
var
coordinate
=
editorMap
.
center
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
coordinate
.
altitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
coordinate
.
altitude
.
toFixed
(
_decimalPlaces
)
insertComplexMissionItem
(
complexItemName
,
coordinate
,
_missionController
.
visualItems
.
count
)
}
...
...
@@ -89,7 +89,7 @@ QGCView {
var
coordinateNW
=
editorMap
.
toCoordinate
(
Qt
.
point
(
0
,
0
),
false
/* clipToViewPort */
)
var
coordinateSE
=
editorMap
.
toCoordinate
(
Qt
.
point
(
width
,
height
),
false
/* clipToViewPort */
)
if
(
coordinateNW
.
isValid
&&
coordinateSE
.
isValid
)
{
QGroundControl
.
airspaceManager
.
setROI
(
coordinateNW
,
coordinateSE
)
QGroundControl
.
airspaceManager
.
setROI
(
coordinateNW
,
coordinateSE
,
true
/*planView*/
)
}
}
}
...
...
src/QmlControls/QGCGeoBoundingCube.cc
View file @
f109339e
...
...
@@ -25,14 +25,23 @@ QGCGeoBoundingCube::isValid() const
pointNW
.
longitude
()
!=
MaxEast
&&
pointSE
.
longitude
()
!=
MaxWest
&&
pointNW
.
altitude
()
<
MaxAlt
and
pointSE
.
altitude
()
>
MinAlt
;
}
//-----------------------------------------------------------------------------
void
QGCGeoBoundingCube
::
reset
()
{
pointSE
=
QGeoCoordinate
();
pointNW
=
QGeoCoordinate
();
}
//-----------------------------------------------------------------------------
QGeoCoordinate
QGCGeoBoundingCube
::
center
()
const
{
if
(
!
isValid
())
return
QGeoCoordinate
();
double
lat
=
(((
pointNW
.
latitude
()
+
90.0
)
+
(
pointSE
.
latitude
()
+
90.0
))
/
2.0
)
-
90.0
;
double
lon
=
(((
pointNW
.
longitude
()
+
180.0
)
+
(
pointSE
.
longitude
()
+
180.0
))
/
2.0
)
-
180.0
;
double
alt
=
(
pointNW
.
altitude
()
+
pointSE
.
altitude
())
/
2.0
;
//qDebug() << pointNW << pointSE << QGeoCoordinate(lat, lon, alt);
return
QGeoCoordinate
(
lat
,
lon
,
alt
);
}
...
...
@@ -41,11 +50,13 @@ QList<QGeoCoordinate>
QGCGeoBoundingCube
::
polygon2D
()
const
{
QList
<
QGeoCoordinate
>
coords
;
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointSE
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointSE
.
latitude
(),
pointSE
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointSE
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
if
(
isValid
())
{
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointSE
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointSE
.
latitude
(),
pointSE
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointSE
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
coords
.
append
(
QGeoCoordinate
(
pointNW
.
latitude
(),
pointNW
.
longitude
(),
pointSE
.
altitude
()));
}
return
coords
;
}
...
...
@@ -53,6 +64,8 @@ QGCGeoBoundingCube::polygon2D() const
double
QGCGeoBoundingCube
::
width
()
const
{
if
(
!
isValid
())
return
0.0
;
QGeoCoordinate
ne
=
QGeoCoordinate
(
pointNW
.
latitude
(),
pointSE
.
longitude
());
return
pointNW
.
distanceTo
(
ne
);
}
...
...
@@ -61,6 +74,8 @@ QGCGeoBoundingCube::width() const
double
QGCGeoBoundingCube
::
height
()
const
{
if
(
!
isValid
())
return
0.0
;
QGeoCoordinate
sw
=
QGeoCoordinate
(
pointSE
.
latitude
(),
pointNW
.
longitude
());
return
pointNW
.
distanceTo
(
sw
);
}
...
...
@@ -69,6 +84,8 @@ QGCGeoBoundingCube::height() const
double
QGCGeoBoundingCube
::
area
()
const
{
if
(
!
isValid
())
return
0.0
;
// Area in km^2
double
a
=
(
height
()
/
1000.0
)
*
(
width
()
/
1000.0
);
//qDebug() << "Area:" << a;
...
...
@@ -79,5 +96,7 @@ QGCGeoBoundingCube::area() const
double
QGCGeoBoundingCube
::
radius
()
const
{
if
(
!
isValid
())
return
0.0
;
return
pointNW
.
distanceTo
(
pointSE
)
/
2.0
;
}
src/QmlControls/QGCGeoBoundingCube.h
View file @
f109339e
...
...
@@ -39,8 +39,9 @@ public:
Q_PROPERTY
(
QGeoCoordinate
pointNW
MEMBER
pointNW
CONSTANT
)
Q_PROPERTY
(
QGeoCoordinate
pointSE
MEMBER
pointNW
CONSTANT
)
Q_INVOKABLE
bool
isValid
()
const
;
Q_INVOKABLE
QGeoCoordinate
center
()
const
;
Q_INVOKABLE
void
reset
();
Q_INVOKABLE
bool
isValid
()
const
;
Q_INVOKABLE
QGeoCoordinate
center
()
const
;
inline
bool
operator
==
(
const
QGCGeoBoundingCube
&
other
)
{
...
...
@@ -61,10 +62,11 @@ public:
//-- 2D
QList
<
QGeoCoordinate
>
polygon2D
()
const
;
double
width
()
const
;
double
height
()
const
;
double
area
()
const
;
double
radius
()
const
;
Q_INVOKABLE
double
width
()
const
;
Q_INVOKABLE
double
height
()
const
;
Q_INVOKABLE
double
area
()
const
;
Q_INVOKABLE
double
radius
()
const
;
QGeoCoordinate
pointNW
;
QGeoCoordinate
pointSE
;
...
...
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