Commit 4ef772d6 authored by Don Gagne's avatar Don Gagne

Add support for flight track lines

parent 54e85068
......@@ -260,9 +260,11 @@ HEADERS += \
src/QGCQuickWidget.h \
src/QGCSingleton.h \
src/QGCTemporaryFile.h \
src/QmlControls/CoordinateVector.h \
src/QmlControls/MavlinkQmlSingleton.h \
src/QmlControls/ParameterEditorController.h \
src/QmlControls/ScreenToolsController.h \
src/QmlControls/QGCQGeoCoordinate.h \
src/QmlControls/QGroundControlQmlGlobal.h \
src/QmlControls/QmlObjectListModel.h \
src/SerialPortIds.h \
......@@ -390,8 +392,10 @@ SOURCES += \
src/QGCQuickWidget.cc \
src/QGCSingleton.cc \
src/QGCTemporaryFile.cc \
src/QmlControls/CoordinateVector.cc \
src/QmlControls/ParameterEditorController.cc \
src/QmlControls/ScreenToolsController.cc \
src/QmlControls/QGCQGeoCoordinate.cc \
src/QmlControls/QGroundControlQmlGlobal.cc \
src/QmlControls/QmlObjectListModel.cc \
src/uas/FileManager.cc \
......
......@@ -120,6 +120,22 @@ Item {
visible: _activeVehicle ? _activeVehicle.homePositionAvailable : false
}
// Add trajectory points to the map
MapItemView {
model: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.trajectoryPoints : 0
delegate:
MapPolyline {
line.width: 3
line.color: "orange"
path: [
{ latitude: object.coordinate1.latitude, longitude: object.coordinate1.longitude },
{ latitude: object.coordinate2.latitude, longitude: object.coordinate2.longitude },
]
}
}
// Add the vehicles to the map
MapItemView {
model: multiVehicleManager.vehicles
......
......@@ -84,6 +84,8 @@
#include "QGroundControlQmlGlobal.h"
#include "HomePositionManager.h"
#include "FlightMapSettings.h"
#include "QGCQGeoCoordinate.h"
#include "CoordinateVector.h"
#ifndef __ios__
#include "SerialLink.h"
......@@ -343,6 +345,8 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<JoystickManager> ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only");
qmlRegisterUncreatableType<Joystick> ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only");
qmlRegisterUncreatableType<QmlObjectListModel> ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only");
qmlRegisterUncreatableType<QGCQGeoCoordinate> ("QGroundControl", 1, 0, "QGCQGeoCoordinate", "Reference only");
qmlRegisterUncreatableType<CoordinateVector> ("QGroundControl", 1, 0, "CoordinateVector", "Reference only");
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "CoordinateVector.h"
CoordinateVector::CoordinateVector(QObject* parent)
: QObject(parent)
{
}
CoordinateVector::CoordinateVector(const QGeoCoordinate& coordinate1, const QGeoCoordinate& coordinate2, QObject* parent)
: QObject(parent)
, _coordinate1(coordinate1)
, _coordinate2(coordinate2)
{
}
CoordinateVector::~CoordinateVector()
{
}
void CoordinateVector::setCoordinates(const QGeoCoordinate& coordinate1, const QGeoCoordinate& coordinate2)
{
_coordinate1 = coordinate1;
_coordinate2 = coordinate2;
emit coordinate1Changed(_coordinate1);
emit coordinate2Changed(_coordinate2);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
#ifndef CoordinateVector_H
#define CoordinateVector_H
#include <QObject>
#include <QGeoCoordinate>
class CoordinateVector : public QObject
{
Q_OBJECT
public:
CoordinateVector(QObject* parent = NULL);
CoordinateVector(const QGeoCoordinate& coordinate1, const QGeoCoordinate& coordinate2, QObject* parent = NULL);
~CoordinateVector();
Q_PROPERTY(QGeoCoordinate coordinate1 MEMBER _coordinate1 NOTIFY coordinate1Changed)
Q_PROPERTY(QGeoCoordinate coordinate2 MEMBER _coordinate2 NOTIFY coordinate2Changed)
void setCoordinates(const QGeoCoordinate& coordinate1, const QGeoCoordinate& coordinate2);
signals:
void coordinate1Changed(QGeoCoordinate coordinate);
void coordinate2Changed(QGeoCoordinate coordinate);
private:
QGeoCoordinate _coordinate1;
QGeoCoordinate _coordinate2;
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "QGCQGeoCoordinate.h"
QGCQGeoCoordinate::QGCQGeoCoordinate(QObject* parent)
: QObject(parent)
{
}
QGCQGeoCoordinate::QGCQGeoCoordinate(const QGeoCoordinate& coordinate, QObject* parent)
: QObject(parent)
, _coordinate(coordinate)
{
}
QGCQGeoCoordinate::~QGCQGeoCoordinate()
{
}
void QGCQGeoCoordinate::setCoordinate(const QGeoCoordinate& coordinate)
{
_coordinate = coordinate;
emit coordinateChanged(_coordinate);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
#ifndef QGCQGeoCoordinate_H
#define QGCQGeoCoordinate_H
#include <QObject>
#include <QGeoCoordinate>
/// This class wraps a QGeoCoordinate in a QObject so that it can be used from within a
/// QmlObjectListModel.
class QGCQGeoCoordinate : public QObject
{
Q_OBJECT
public:
QGCQGeoCoordinate(QObject* parent = NULL);
QGCQGeoCoordinate(const QGeoCoordinate& coordinate, QObject* parent = NULL);
~QGCQGeoCoordinate();
Q_PROPERTY(QGeoCoordinate coordinate MEMBER _coordinate NOTIFY coordinateChanged)
void setCoordinate(const QGeoCoordinate& coordinate);
signals:
void coordinateChanged(QGeoCoordinate coordinate);
private:
QGeoCoordinate _coordinate;
};
#endif
......@@ -31,6 +31,7 @@
#include "UAS.h"
#include "JoystickManager.h"
#include "MissionManager.h"
#include "CoordinateVector.h"
QGC_LOGGING_CATEGORY(VehicleLog, "VehicleLog")
......@@ -169,6 +170,9 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType,
_sendMultipleTimer.start(_sendMessageMultipleIntraMessageDelay);
connect(&_sendMultipleTimer, &QTimer::timeout, this, &Vehicle::_sendMessageMultipleNext);
_mapTrajectoryTimer.setInterval(_mapTrajectoryMsecsBetweenPoints);
connect(&_mapTrajectoryTimer, &QTimer::timeout, this, &Vehicle::_addNewMapTrajectoryPoint);
}
Vehicle::~Vehicle()
......@@ -257,6 +261,13 @@ void Vehicle::_handleHeartbeat(mavlink_message_t& message)
if (_armed != newArmed) {
_armed = newArmed;
emit armedChanged(_armed);
// We are transitioning to the armed state, begin tracking trajectory points for the map
if (_armed) {
_mapTrajectoryStart();
} else {
_mapTrajectoryStop();
}
}
if (heartbeat.base_mode != _base_mode || heartbeat.custom_mode != _custom_mode) {
......@@ -1129,3 +1140,24 @@ void Vehicle::_missionManagerError(int errorCode, const QString& errorMsg)
Q_UNUSED(errorCode);
qgcApp()->showToolBarMessage(QString("Error during Mission communication with Vehicle: %1").arg(errorMsg));
}
void Vehicle::_addNewMapTrajectoryPoint(void)
{
if (_mapTrajectoryHaveFirstCoordinate) {
_mapTrajectoryList.append(new CoordinateVector(_mapTrajectoryLastCoordinate, _geoCoordinate, this));
}
_mapTrajectoryHaveFirstCoordinate = true;
_mapTrajectoryLastCoordinate = _geoCoordinate;
}
void Vehicle::_mapTrajectoryStart(void)
{
_mapTrajectoryHaveFirstCoordinate = false;
_mapTrajectoryList.clear();
_mapTrajectoryTimer.start();
}
void Vehicle::_mapTrajectoryStop()
{
_mapTrajectoryTimer.stop();
}
......@@ -73,6 +73,8 @@ public:
Q_PROPERTY(bool missingParameters READ missingParameters NOTIFY missingParametersChanged)
Q_PROPERTY(QmlObjectListModel* trajectoryPoints READ trajectoryPoints CONSTANT)
Q_INVOKABLE QString getMavIconColor();
//-- System Messages
......@@ -185,6 +187,8 @@ public:
bool hilMode(void);
void setHilMode(bool hilMode);
QmlObjectListModel* trajectoryPoints(void) { return &_mapTrajectoryList; }
/// Requests the specified data stream from the vehicle
/// @param stream Stream which is being requested
/// @param rate Rate at which to send stream in Hz
......@@ -300,6 +304,7 @@ private slots:
void _linkDisconnected(LinkInterface* link);
void _sendMessage(mavlink_message_t message);
void _sendMessageMultipleNext(void);
void _addNewMapTrajectoryPoint(void);
void _handleTextMessage (int newCount);
/** @brief Attitude from main autopilot / system state */
......@@ -335,6 +340,8 @@ private:
void _handleHomePosition(mavlink_message_t& message);
void _handleHeartbeat(mavlink_message_t& message);
void _missionManagerError(int errorCode, const QString& errorMsg);
void _mapTrajectoryStart(void);
void _mapTrajectoryStop(void);
bool _isAirplane ();
void _addChange (int id);
......@@ -425,6 +432,12 @@ private:
QTimer _sendMultipleTimer;
int _nextSendMessageMultipleIndex;
QTimer _mapTrajectoryTimer;
QmlObjectListModel _mapTrajectoryList;
QGeoCoordinate _mapTrajectoryLastCoordinate;
bool _mapTrajectoryHaveFirstCoordinate;
static const int _mapTrajectoryMsecsBetweenPoints = 1000;
// Settings keys
static const char* _settingsGroup;
static const char* _joystickModeSettingsKey;
......
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