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
ad6cb929
Commit
ad6cb929
authored
Apr 24, 2016
by
Jimmy Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding position manager
parent
37c62b78
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
442 additions
and
129 deletions
+442
-129
qgroundcontrol.pro
qgroundcontrol.pro
+5
-0
PX4FirmwarePlugin.cc
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
+1
-0
FollowMe.cc
src/FollowMe/FollowMe.cc
+38
-86
FollowMe.h
src/FollowMe/FollowMe.h
+6
-27
PositionManager.cpp
src/PositionManager/PositionManager.cpp
+88
-0
PositionManager.h
src/PositionManager/PositionManager.h
+62
-0
SimulatedPosition.cc
src/PositionManager/SimulatedPosition.cc
+136
-0
SimulatedPosition.h
src/PositionManager/SimulatedPosition.h
+75
-0
QGCApplication.cc
src/QGCApplication.cc
+4
-0
QGCToolbox.cc
src/QGCToolbox.cc
+6
-2
QGCToolbox.h
src/QGCToolbox.h
+3
-0
QGroundControlQmlGlobal.cc
src/QmlControls/QGroundControlQmlGlobal.cc
+2
-1
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+5
-1
MainWindowInner.qml
src/ui/MainWindowInner.qml
+11
-12
No files found.
qgroundcontrol.pro
View file @
ad6cb929
...
...
@@ -218,6 +218,7 @@ INCLUDEPATH += \
src
/
ViewWidgets
\
src
/
QtLocationPlugin
\
src
/
QtLocationPlugin
/
QMLControl
\
src
/
PositionManager
\
FORMS
+=
\
src
/
ui
/
MainWindow
.
ui
\
...
...
@@ -266,6 +267,7 @@ HEADERS += \
src
/
Joystick
/
Joystick
.
h
\
src
/
Joystick
/
JoystickManager
.
h
\
src
/
FollowMe
/
FollowMe
.
h
\
src
/
PositionManager
/
SimulatedPosition
.
h
\
src
/
JsonHelper
.
h
\
src
/
LogCompressor
.
h
\
src
/
MG
.
h
\
...
...
@@ -310,6 +312,7 @@ HEADERS += \
src
/
QmlControls
/
QGCImageProvider
.
h
\
src
/
AutoPilotPlugins
/
APM
/
APMRemoteParamsDownloader
.
h
\
src
/
QtLocationPlugin
/
QMLControl
/
QGCMapEngineManager
.
h
\
src
/
PositionManager
/
PositionManager
.
h
DebugBuild
{
HEADERS
+=
\
...
...
@@ -462,6 +465,8 @@ SOURCES += \
src
/
QmlControls
/
QGCImageProvider
.
cc
\
src
/
AutoPilotPlugins
/
APM
/
APMRemoteParamsDownloader
.
cc
\
src
/
QtLocationPlugin
/
QMLControl
/
QGCMapEngineManager
.
cc
\
src
/
PositionManager
/
SimulatedPosition
.
cc
\
src
/
PositionManager
/
PositionManager
.
cpp
DebugBuild
{
SOURCES
+=
\
...
...
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
View file @
ad6cb929
...
...
@@ -241,6 +241,7 @@ QList<MAV_CMD> PX4FirmwarePlugin::supportedMissionCommands(void)
<<
MAV_CMD_DO_SET_SERVO
<<
MAV_CMD_DO_CHANGE_SPEED
<<
MAV_CMD_NAV_PATHPLANNING
;
return
list
;
}
...
...
src/FollowMe/FollowMe.cc
View file @
ad6cb929
...
...
@@ -20,7 +20,6 @@
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include <QElapsedTimer>
#include <cmath>
...
...
@@ -29,47 +28,21 @@
#include "MAVLinkProtocol.h"
#include "FollowMe.h"
#include "Vehicle.h"
#ifdef QT_QML_DEBUG
FollowMe
::
simulated_motion_s
FollowMe
::
_simulated_motion
[
4
]
=
{{
0
,
500
},{
500
,
0
},{
0
,
-
500
},{
-
500
,
0
}};
#endif
#include "PositionManager.h"
FollowMe
::
FollowMe
(
QGCApplication
*
app
)
:
QGCTool
(
app
),
_followMeStr
(
PX4FirmwarePlugin
::
followMeFlightMode
)
:
QGCTool
(
app
),
estimatation_capabilities
(
0
)
{
#ifdef QT_QML_DEBUG
_simulate_motion_timer
=
0
;
_simulate_motion_index
=
0
;
_simulate_motion
=
false
;
#endif
memset
(
&
_motionReport
,
0
,
sizeof
(
motionReport_s
));
runTime
.
start
();
// set up the QT position connection slot
_locationInfo
=
QGeoPositionInfoSource
::
createDefaultSource
(
this
);
if
(
_locationInfo
!=
0
)
{
_locationInfo
->
setPreferredPositioningMethods
(
QGeoPositionInfoSource
::
SatellitePositioningMethods
);
_locationInfo
->
setUpdateInterval
(
_locationInfo
->
minimumUpdateInterval
());
connect
(
_locationInfo
,
SIGNAL
(
positionUpdated
(
QGeoPositionInfo
)),
this
,
SLOT
(
_setGPSLocation
(
QGeoPositionInfo
)));
// set up the mavlink motion report timer`
_gcsMotionReportTimer
.
setInterval
(
_locationInfo
->
minimumUpdateInterval
());
_gcsMotionReportTimer
.
setSingleShot
(
false
);
connect
(
&
_gcsMotionReportTimer
,
&
QTimer
::
timeout
,
this
,
&
FollowMe
::
_sendGCSMotionReport
);
runTime
.
start
();
}
_gcsMotionReportTimer
.
setSingleShot
(
false
);
connect
(
&
_gcsMotionReportTimer
,
&
QTimer
::
timeout
,
this
,
&
FollowMe
::
_sendGCSMotionReport
);
}
FollowMe
::~
FollowMe
()
{
disable
();
_
disable
();
}
void
FollowMe
::
followMeHandleManager
(
const
QString
&
)
...
...
@@ -78,29 +51,34 @@ void FollowMe::followMeHandleManager(const QString&)
for
(
int
i
=
0
;
i
<
vehicles
.
count
();
i
++
)
{
Vehicle
*
vehicle
=
qobject_cast
<
Vehicle
*>
(
vehicles
[
i
]);
if
(
vehicle
->
flightMode
().
compare
(
_followMeStr
,
Qt
::
CaseInsensitive
)
==
0
)
{
enable
();
if
(
vehicle
->
flightMode
().
compare
(
PX4FirmwarePlugin
::
followMeFlightMode
,
Qt
::
CaseInsensitive
)
==
0
)
{
_
enable
();
return
;
}
}
disable
();
_
disable
();
}
void
FollowMe
::
enable
()
void
FollowMe
::
_
enable
()
{
if
(
_locationInfo
!=
0
)
{
_locationInfo
->
startUpdates
();
_gcsMotionReportTimer
.
start
();
}
connect
(
_toolbox
->
qgcPositionManager
(),
SIGNAL
(
positionInfoUpdated
(
QGeoPositionInfo
)),
this
,
SLOT
(
_setGPSLocation
(
QGeoPositionInfo
)));
_gcsMotionReportTimer
.
setInterval
(
_toolbox
->
qgcPositionManager
()
->
updateInterval
());
_gcsMotionReportTimer
.
start
();
}
void
FollowMe
::
disable
()
void
FollowMe
::
_
disable
()
{
if
(
_locationInfo
!=
0
)
{
_locationInfo
->
stopUpdates
();
_gcsMotionReportTimer
.
stop
();
}
disconnect
(
_toolbox
->
qgcPositionManager
(),
SIGNAL
(
positionInfoUpdated
(
QGeoPositionInfo
)),
this
,
SLOT
(
_setGPSLocation
(
QGeoPositionInfo
)));
_gcsMotionReportTimer
.
stop
();
}
void
FollowMe
::
_setGPSLocation
(
QGeoPositionInfo
geoPositionInfo
)
...
...
@@ -115,13 +93,8 @@ void FollowMe::_setGPSLocation(QGeoPositionInfo geoPositionInfo)
_motionReport
.
lon_int
=
geoCoordinate
.
longitude
()
*
1e7
;
_motionReport
.
alt
=
geoCoordinate
.
altitude
();
#ifdef QT_QML_DEBUG
if
(
_simulate_motion
==
true
)
{
_motionReport
.
lat_int
=
47.3977420
*
1e7
;
_motionReport
.
lon_int
=
8.5455941
*
1e7
;
_motionReport
.
alt
=
488.00
;
}
#endif
estimatation_capabilities
|=
(
1
<<
POS
);
// get the current eph and epv
if
(
geoPositionInfo
.
hasAttribute
(
QGeoPositionInfo
::
HorizontalAccuracy
)
==
true
)
{
...
...
@@ -130,7 +103,7 @@ void FollowMe::_setGPSLocation(QGeoPositionInfo geoPositionInfo)
if
(
geoPositionInfo
.
hasAttribute
(
QGeoPositionInfo
::
VerticalAccuracy
)
==
true
)
{
_motionReport
.
pos_std_dev
[
2
]
=
geoPositionInfo
.
attribute
(
QGeoPositionInfo
::
VerticalAccuracy
);
}
}
// calculate z velocity if it's availible
...
...
@@ -143,11 +116,17 @@ void FollowMe::_setGPSLocation(QGeoPositionInfo geoPositionInfo)
if
((
geoPositionInfo
.
hasAttribute
(
QGeoPositionInfo
::
Direction
)
==
true
)
&&
(
geoPositionInfo
.
hasAttribute
(
QGeoPositionInfo
::
GroundSpeed
)
==
true
))
{
estimatation_capabilities
|=
(
1
<<
VEL
);
qreal
direction
=
_degreesToRadian
(
geoPositionInfo
.
attribute
(
QGeoPositionInfo
::
Direction
));
qreal
velocity
=
geoPositionInfo
.
attribute
(
QGeoPositionInfo
::
GroundSpeed
);
_motionReport
.
vx
=
cos
(
direction
)
*
velocity
;
_motionReport
.
vy
=
sin
(
direction
)
*
velocity
;
}
else
{
_motionReport
.
vx
=
0.0
f
;
_motionReport
.
vy
=
0.0
f
;
}
}
}
...
...
@@ -161,22 +140,20 @@ void FollowMe::_sendGCSMotionReport(void)
memset
(
&
follow_target
,
0
,
sizeof
(
mavlink_follow_target_t
));
follow_target
.
timestamp
=
runTime
.
nsecsElapsed
()
*
1e-6
;
follow_target
.
est_capabilities
=
(
1
<<
POS
)
;
follow_target
.
est_capabilities
=
estimatation_capabilities
;
follow_target
.
position_cov
[
0
]
=
_motionReport
.
pos_std_dev
[
0
];
follow_target
.
position_cov
[
2
]
=
_motionReport
.
pos_std_dev
[
2
];
follow_target
.
alt
=
_motionReport
.
alt
;
follow_target
.
lat
=
_motionReport
.
lat_int
;
follow_target
.
lon
=
_motionReport
.
lon_int
;
follow_target
.
vel
[
0
]
=
_motionReport
.
vx
;
follow_target
.
vel
[
1
]
=
_motionReport
.
vy
;
#ifdef QT_QML_DEBUG
if
(
_simulate_motion
==
true
)
{
_createSimulatedMotion
(
follow_target
);
}
#endif
qWarning
(
"Mavlink Sending %d %d"
,
_motionReport
.
lat_int
,
_motionReport
.
lon_int
);
for
(
int
i
=
0
;
i
<
vehicles
.
count
();
i
++
)
{
Vehicle
*
vehicle
=
qobject_cast
<
Vehicle
*>
(
vehicles
[
i
]);
if
(
vehicle
->
flightMode
().
compare
(
_followMeStr
,
Qt
::
CaseInsensitive
)
==
0
)
{
if
(
vehicle
->
flightMode
().
compare
(
PX4FirmwarePlugin
::
followMeFlightMode
,
Qt
::
CaseInsensitive
)
==
0
)
{
mavlink_message_t
message
;
mavlink_msg_follow_target_encode
(
mavlinkProtocol
->
getSystemId
(),
mavlinkProtocol
->
getComponentId
(),
...
...
@@ -191,28 +168,3 @@ double FollowMe::_degreesToRadian(double deg)
{
return
deg
*
M_PI
/
180.0
;
}
#ifdef QT_QML_DEBUG
void
FollowMe
::
_createSimulatedMotion
(
mavlink_follow_target_t
&
follow_target
)
{
static
int
f_lon
=
0
;
static
int
f_lat
=
0
;
static
float
rot
=
0
;
rot
+=
(
float
)
.1
;
if
(
!
(
_simulate_motion_timer
++%
50
))
{
_simulate_motion_index
++
;
if
(
_simulate_motion_index
>
3
)
{
_simulate_motion_index
=
0
;
}
}
f_lon
=
f_lon
+
_simulated_motion
[
_simulate_motion_index
].
lon
*
sin
(
rot
);
f_lat
=
f_lat
+
_simulated_motion
[
_simulate_motion_index
].
lat
;
follow_target
.
alt
=
_motionReport
.
alt
;
follow_target
.
lat
=
_motionReport
.
lat_int
+
f_lon
;
follow_target
.
lon
=
_motionReport
.
lon_int
+
f_lat
;
}
#endif
src/FollowMe/FollowMe.h
View file @
ad6cb929
...
...
@@ -30,7 +30,6 @@
#include <QGeoPositionInfoSource>
#include <QElapsedTimer>
#include "QGCLoggingCategory.h"
#include "QGCToolbox.h"
#include "MAVLinkProtocol.h"
...
...
@@ -52,8 +51,8 @@ private slots:
void
_sendGCSMotionReport
(
void
);
private:
Q
GeoPositionInfoSource
*
_locationInfo
;
Q
ElapsedTimer
runTime
;
Q
ElapsedTimer
runTime
;
Q
Timer
_gcsMotionReportTimer
;
// Timer to emit motion reports
struct
motionReport_s
{
uint32_t
timestamp
;
// time since boot
...
...
@@ -69,14 +68,6 @@ private:
float
pos_std_dev
[
3
];
// -1 for unknown
}
_motionReport
;
QString
_followMeStr
;
QTimer
_gcsMotionReportTimer
;
///< Timer to emit motion reports
double
_degreesToRadian
(
double
deg
);
void
disable
();
void
enable
();
// Mavlink defined motion reporting capabilities
enum
{
...
...
@@ -86,22 +77,10 @@ private:
ATT_RATES
=
3
};
#ifdef QT_QML_DEBUG
// items for simulating QGC movment in jMAVSIM
struct
simulated_motion_s
{
int
lon
;
int
lat
;
};
static
simulated_motion_s
_simulated_motion
[
4
];
uint8_t
estimatation_capabilities
;
int
_simulate_motion_timer
;
int
_simulate_motion_index
;
void
_disable
()
;
void
_enable
()
;
bool
_simulate_motion
;
void
_createSimulatedMotion
(
mavlink_follow_target_t
&
follow_target
);
#endif
double
_degreesToRadian
(
double
deg
);
};
src/PositionManager/PositionManager.cpp
0 → 100644
View file @
ad6cb929
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "PositionManager.h"
QGCPositionManager
::
QGCPositionManager
(
QGCApplication
*
app
)
:
QGCTool
(
app
),
_updateInterval
(
0
),
_currentSource
(
nullptr
)
{
_defaultSource
=
QGeoPositionInfoSource
::
createDefaultSource
(
this
);
_simulatedSource
=
new
SimulatedPosition
();
// if the default source is not availble for whatever reason
// fall back to a simulated source
if
(
_defaultSource
==
nullptr
)
{
_defaultSource
=
_simulatedSource
;
}
setPositionSource
(
QGCPositionSource
::
GPS
);
}
QGCPositionManager
::~
QGCPositionManager
()
{
delete
(
_simulatedSource
);
}
void
QGCPositionManager
::
positionUpdated
(
const
QGeoPositionInfo
&
update
)
{
QGeoCoordinate
position
(
update
.
coordinate
().
latitude
(),
update
.
coordinate
().
longitude
());
emit
lastPositionUpdated
(
update
.
isValid
(),
QVariant
::
fromValue
(
position
));
emit
positionInfoUpdated
(
update
);
}
int
QGCPositionManager
::
updateInterval
()
const
{
return
_updateInterval
;
}
void
QGCPositionManager
::
setPositionSource
(
QGCPositionManager
::
QGCPositionSource
source
)
{
if
(
_currentSource
!=
nullptr
)
{
_currentSource
->
stopUpdates
();
disconnect
(
_currentSource
,
SIGNAL
(
positionUpdated
(
QGeoPositionInfo
)),
this
,
SLOT
(
positionUpdated
(
QGeoPositionInfo
)));
}
switch
(
source
)
{
case
QGCPositionManager
:
:
Log
:
break
;
case
QGCPositionManager
:
:
Simulated
:
_currentSource
=
_simulatedSource
;
break
;
case
QGCPositionManager
:
:
GPS
:
default:
_currentSource
=
_defaultSource
;
break
;
}
_updateInterval
=
_currentSource
->
minimumUpdateInterval
();
_currentSource
->
setPreferredPositioningMethods
(
QGeoPositionInfoSource
::
SatellitePositioningMethods
);
_currentSource
->
setUpdateInterval
(
_updateInterval
);
_currentSource
->
startUpdates
();
connect
(
_currentSource
,
SIGNAL
(
positionUpdated
(
QGeoPositionInfo
)),
this
,
SLOT
(
positionUpdated
(
QGeoPositionInfo
)));
}
src/PositionManager/PositionManager.h
0 → 100644
View file @
ad6cb929
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#pragma once
#include <QtPositioning/qgeopositioninfosource.h>
#include <QVariant>
#include "QGCToolbox.h"
#include "SimulatedPosition.h"
class
QGCPositionManager
:
public
QGCTool
{
Q_OBJECT
public:
QGCPositionManager
(
QGCApplication
*
app
);
~
QGCPositionManager
();
enum
QGCPositionSource
{
Simulated
,
GPS
,
Log
};
void
setPositionSource
(
QGCPositionSource
source
);
int
updateInterval
()
const
;
private
slots
:
void
positionUpdated
(
const
QGeoPositionInfo
&
update
);
signals:
void
lastPositionUpdated
(
bool
valid
,
QVariant
lastPosition
);
void
positionInfoUpdated
(
QGeoPositionInfo
update
);
private:
int
_updateInterval
;
QGeoPositionInfoSource
*
_currentSource
;
QGeoPositionInfoSource
*
_defaultSource
;
QGeoPositionInfoSource
*
_simulatedSource
;
};
src/PositionManager/SimulatedPosition.cc
0 → 100644
View file @
ad6cb929
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include <QtCore>
#include <QDateTime>
#include <QDate>
#include "SimulatedPosition.h"
SimulatedPosition
::
simulated_motion_s
SimulatedPosition
::
_simulated_motion
[
5
]
=
{{
0
,
250
},{
0
,
0
},{
0
,
-
250
},{
-
250
,
0
},{
0
,
0
}};
SimulatedPosition
::
SimulatedPosition
()
:
QGeoPositionInfoSource
(
NULL
),
lat_int
(
47.3977420
*
1e7
),
lon_int
(
8.5455941
*
1e7
),
_step_cnt
(
0
),
_simulate_motion_index
(
0
),
_simulate_motion
(
true
),
_rotation
(
0.0
F
)
{
QDateTime
currentDateTime
=
QDateTime
::
currentDateTime
();
qsrand
(
currentDateTime
.
toTime_t
());
connect
(
&
update_timer
,
&
QTimer
::
timeout
,
this
,
&
SimulatedPosition
::
updatePosition
);
}
QGeoPositionInfo
SimulatedPosition
::
lastKnownPosition
(
bool
/*fromSatellitePositioningMethodsOnly*/
)
const
{
return
lastPosition
;
}
SimulatedPosition
::
PositioningMethods
SimulatedPosition
::
supportedPositioningMethods
()
const
{
return
AllPositioningMethods
;
}
int
SimulatedPosition
::
minimumUpdateInterval
()
const
{
return
1000
;
}
void
SimulatedPosition
::
startUpdates
()
{
int
interval
=
updateInterval
();
if
(
interval
<
minimumUpdateInterval
())
interval
=
minimumUpdateInterval
();
update_timer
.
setSingleShot
(
false
);
update_timer
.
start
(
interval
);
}
void
SimulatedPosition
::
stopUpdates
()
{
update_timer
.
stop
();
}
void
SimulatedPosition
::
requestUpdate
(
int
/*timeout*/
)
{
emit
updateTimeout
();
}
int
SimulatedPosition
::
getRandomNumber
(
int
size
)
{
if
(
size
==
0
)
{
return
0
;
}
int
num
=
(
qrand
()
%
2
>
1
)
?
-
1
:
1
;
return
num
*
qrand
()
%
size
;
}
void
SimulatedPosition
::
updatePosition
()
{
int32_t
lat_mov
=
0
;
int32_t
lon_mov
=
0
;
_rotation
+=
(
float
)
.1
;
if
(
!
(
_step_cnt
++%
30
))
{
_simulate_motion_index
++
;
if
(
_simulate_motion_index
>
4
)
{
_simulate_motion_index
=
0
;
}
}
lat_mov
=
_simulated_motion
[
_simulate_motion_index
].
lat
;
lon_mov
=
_simulated_motion
[
_simulate_motion_index
].
lon
*
sin
(
_rotation
);
lon_int
+=
lat_mov
;
lat_int
+=
lon_mov
;
double
latitude
=
((
double
)
(
lat_int
+
getRandomNumber
(
250
)))
*
1e-7
;
double
longitude
=
((
double
)
(
lon_int
+
getRandomNumber
(
250
)))
*
1e-7
;
QDateTime
timestamp
=
QDateTime
::
currentDateTime
();
QGeoCoordinate
position
(
latitude
,
longitude
);
QGeoPositionInfo
info
(
position
,
timestamp
);
if
(
lat_mov
||
lon_mov
)
{
info
.
setAttribute
(
QGeoPositionInfo
::
Attribute
::
Direction
,
3.14
/
2
);
info
.
setAttribute
(
QGeoPositionInfo
::
Attribute
::
GroundSpeed
,
5
);
}
lastPosition
=
info
;
emit
positionUpdated
(
info
);
}
QGeoPositionInfoSource
::
Error
SimulatedPosition
::
error
()
const
{
return
QGeoPositionInfoSource
::
NoError
;
}
src/PositionManager/SimulatedPosition.h
0 → 100644
View file @
ad6cb929
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#pragma once
#include <QtPositioning/qgeopositioninfosource.h>
#include "QGCToolbox.h"
#include <QTimer>
class
SimulatedPosition
:
public
QGeoPositionInfoSource
{
Q_OBJECT
public:
SimulatedPosition
();
QGeoPositionInfo
lastKnownPosition
(
bool
fromSatellitePositioningMethodsOnly
=
false
)
const
;
PositioningMethods
supportedPositioningMethods
()
const
;
int
minimumUpdateInterval
()
const
;
Error
error
()
const
;
public
slots
:
virtual
void
startUpdates
();
virtual
void
stopUpdates
();
virtual
void
requestUpdate
(
int
timeout
=
5000
);
private
slots
:
void
updatePosition
();
private:
QTimer
update_timer
;
QGeoPositionInfo
lastPosition
;
// items for simulating QGC movment in jMAVSIM
int32_t
lat_int
;
int32_t
lon_int
;
struct
simulated_motion_s
{
int
lon
;
int
lat
;
};
static
simulated_motion_s
_simulated_motion
[
5
];
int
getRandomNumber
(
int
size
);
int
_step_cnt
;
int
_simulate_motion_index
;
bool
_simulate_motion
;
float
_rotation
;
};
src/QGCApplication.cc
View file @
ad6cb929
...
...
@@ -103,6 +103,9 @@
#include "PX4AirframeLoader.h"
#include "ValuesWidgetController.h"
#include "AppMessages.h"
#include "SimulatedPosition.h"
#include "PositionManager.h"
#include "FollowMe.h"
#ifndef __ios__
#include "SerialLink.h"
...
...
@@ -440,6 +443,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType
<
MissionManager
>
(
"QGroundControl.Vehicle"
,
1
,
0
,
"MissionManager"
,
"Reference only"
);
qmlRegisterUncreatableType
<
JoystickManager
>
(
"QGroundControl.JoystickManager"
,
1
,
0
,
"JoystickManager"
,
"Reference only"
);
qmlRegisterUncreatableType
<
Joystick
>
(
"QGroundControl.JoystickManager"
,
1
,
0
,
"Joystick"
,
"Reference only"
);
qmlRegisterUncreatableType
<
QGCPositionManager
>
(
"QGroundControl.QGCPositionManager"
,
1
,
0
,
"QGCPositionManager"
,
"Reference only"
);
qmlRegisterType
<
ParameterEditorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ParameterEditorController"
);
qmlRegisterType
<
APMFlightModesComponentController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"APMFlightModesComponentController"
);
...
...
src/QGCToolbox.cc
View file @
ad6cb929
...
...
@@ -39,6 +39,7 @@
#include "UASMessageHandler.h"
#include "QGCMapEngineManager.h"
#include "FollowMe.h"
#include "PositionManager.h"
QGCToolbox
::
QGCToolbox
(
QGCApplication
*
app
)
:
_audioOutput
(
NULL
)
...
...
@@ -56,6 +57,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
,
_mapEngineManager
(
NULL
)
,
_uasMessageHandler
(
NULL
)
,
_followMe
(
NULL
)
,
_qgcPositionManager
(
NULL
)
{
_audioOutput
=
new
GAudioOutput
(
app
);
_autopilotPluginManager
=
new
AutoPilotPluginManager
(
app
);
...
...
@@ -72,8 +74,9 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_mavlinkProtocol
=
new
MAVLinkProtocol
(
app
);
_missionCommands
=
new
MissionCommands
(
app
);
_multiVehicleManager
=
new
MultiVehicleManager
(
app
);
_mapEngineManager
=
new
QGCMapEngineManager
(
app
);
_mapEngineManager
=
new
QGCMapEngineManager
(
app
);
_uasMessageHandler
=
new
UASMessageHandler
(
app
);
_qgcPositionManager
=
new
QGCPositionManager
(
app
);
_followMe
=
new
FollowMe
(
app
);
_audioOutput
->
setToolbox
(
this
);
...
...
@@ -94,9 +97,9 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_mapEngineManager
->
setToolbox
(
this
);
_uasMessageHandler
->
setToolbox
(
this
);
_followMe
->
setToolbox
(
this
);
//FIXME: make this configurable...
//_gpsManager->setupGPS("ttyACM0");
_qgcPositionManager
->
setToolbox
(
this
);
}
QGCToolbox
::~
QGCToolbox
()
...
...
@@ -115,6 +118,7 @@ QGCToolbox::~QGCToolbox()
delete
_multiVehicleManager
;
delete
_uasMessageHandler
;
delete
_followMe
;
delete
_qgcPositionManager
;
}
QGCTool
::
QGCTool
(
QGCApplication
*
app
)
...
...
src/QGCToolbox.h
View file @
ad6cb929
...
...
@@ -43,6 +43,7 @@ class QGCMapEngineManager;
class
QGCApplication
;
class