1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

Merged in corvusvcorax/librepilot/debug_pathdesired_in_map (pull request #408)

LP-498 Display currently active PathDesired end coordinate in opmap

Approved-by: Eric Price <corvuscorax@cybertrench.com>
Approved-by: Fredrik Arvidsson <fredrik@arvidssons.org>
Approved-by: Lalanne Laurent <f5soh@free.fr>
Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
Approved-by: Alessio Morale <alessiomorale@gmail.com>
This commit is contained in:
Eric Price 2017-03-30 18:01:58 +00:00 committed by Philippe Renon
commit 49cea31566
11 changed files with 434 additions and 46 deletions

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1063.415"
height="1063.415"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.48.4 r9939"
version="1.0"
sodipodi:docname="nav.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="289.96988"
inkscape:cy="445.6703"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
showborder="false"
inkscape:window-width="1355"
inkscape:window-height="722"
inkscape:window-x="2059"
inkscape:window-y="89"
inkscape:window-maximized="0"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0">
<inkscape:grid
type="xygrid"
id="grid2991"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
units="cm"
spacingx="1cm"
spacingy="1cm"
originx="-0.022532911cm"
originy="-0.0014897994cm" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(2200.7315,1976.8204)">
<g
id="g3810"
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,532.71884,-1603.6253)">
<path
transform="matrix(1.0033755,0,0,1.0033755,-2220.019,-2101.7843)"
d="m 1062.9921,654.79199 a 513.77954,513.77954 0 1 1 -1027.559056,0 513.77954,513.77954 0 1 1 1027.559056,0 z"
sodipodi:ry="513.77954"
sodipodi:rx="513.77954"
sodipodi:cy="654.79199"
sodipodi:cx="549.21259"
id="path2993"
style="fill:none;stroke:#ff00ff;stroke-width:32.27850723;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
sodipodi:type="arc" />
<path
inkscape:connector-curvature="0"
id="path3763"
d="m -2166.0969,-1515.7143 425.1968,70.8661 -425.1968,70.8662 -35.4331,-70.8662 z"
style="fill:#ff00ff;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3763-3"
d="m -1173.8338,-1515.6795 -425.1968,70.8661 425.1968,70.8662 35.4331,-70.8662 z"
style="fill:#ff00ff;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3763-6"
d="m -1740.8619,-948.95165 70.8661,-425.19675 70.8662,425.19675 -70.8662,35.4331 z"
style="fill:#ff00ff;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3763-3-7"
d="m -1740.8271,-1941.2147 70.8661,425.1968 70.8662,-425.1968 -70.8662,-35.4331 z"
style="fill:#ff00ff;stroke:none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file mapgraphicitem.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief The main graphicsItem used on the widget, contains the map and map logic
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
@ -43,6 +44,7 @@
namespace mapcontrol {
class WayPointItem;
class OPMapWidget;
class HomeItem;
/**
* @brief The main graphicsItem used on the widget, contains the map and map logic
*
@ -105,6 +107,8 @@ public:
double ZoomDigi();
double ZoomTotal();
void setOverlayOpacity(qreal value);
HomeItem *Home;
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);

View File

@ -6,6 +6,7 @@
<file>images/airplane.svg</file>
<file>images/home.png</file>
<file>images/home.svg</file>
<file>images/nav.svg</file>
<file>images/home2.svg</file>
<file>images/airplanepip.png</file>
<file>images/EasystarBlue.png</file>

View File

@ -12,6 +12,7 @@ SOURCES += mapgraphicitem.cpp \
gpsitem.cpp \
trailitem.cpp \
homeitem.cpp \
navitem.cpp \
mapripform.cpp \
mapripper.cpp \
traillineitem.cpp \
@ -39,6 +40,7 @@ HEADERS += mapgraphicitem.h \
uavtrailtype.h \
trailitem.h \
homeitem.h \
navitem.h \
mapripform.h \
mapripper.h \
traillineitem.h \

View File

@ -0,0 +1,99 @@
/**
******************************************************************************
*
* @file navitem.cpp
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* @brief A graphicsItem representing a WayPoint
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "navitem.h"
#include <QGraphicsSceneMouseEvent>
namespace mapcontrol {
NavItem::NavItem(MapGraphicItem *map, OPMapWidget *parent) : map(map), mapwidget(parent),
toggleRefresh(true), altitude(0)
{
pic.load(QString::fromUtf8(":/markers/images/nav.svg"));
pic = pic.scaled(30, 30, Qt::IgnoreAspectRatio);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsMovable, false);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
localposition = map->FromLatLngToLocal(mapwidget->CurrentPosition());
this->setPos(localposition.X(), localposition.Y());
this->setZValue(4);
coord = internals::PointLatLng(50, 50);
RefreshToolTip();
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
}
void NavItem::RefreshToolTip()
{
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
setToolTip(QString("Waypoint: Nav\nCoordinate:%1\nAltitude:%2\n").arg(coord_str).arg(QString::number(altitude)));
}
void NavItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->drawPixmap(-pic.width() / 2, -pic.height() / 2, pic);
}
QRectF NavItem::boundingRect() const
{
return QRectF(-pic.width() / 2, -pic.height() / 2, pic.width(), pic.height());
}
int NavItem::type() const
{
return Type;
}
void NavItem::RefreshPos()
{
prepareGeometryChange();
localposition = map->FromLatLngToLocal(coord);
this->setPos(localposition.X(), localposition.Y());
RefreshToolTip();
this->update();
toggleRefresh = false;
}
void NavItem::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
// Set clickable area as smaller than the bounding rect.
QPainterPath NavItem::shape() const
{
QPainterPath path;
path.addEllipse(QRectF(-12, -25, 24, 50));
return path;
}
}

View File

@ -0,0 +1,85 @@
/**
******************************************************************************
*
* @file navitem.h
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* @brief A graphicsItem representing a WayPoint
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef NAVITEM_H
#define NAVITEM_H
#include <QGraphicsItem>
#include <QPainter>
#include <QLabel>
#include "../internals/pointlatlng.h"
#include <QObject>
#include "opmapwidget.h"
namespace mapcontrol {
class NavItem : public QObject, public QGraphicsItem {
Q_OBJECT Q_INTERFACES(QGraphicsItem)
public:
enum { Type = UserType + 4 };
NavItem(MapGraphicItem *map, OPMapWidget *parent);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QRectF boundingRect() const;
int type() const;
void SetToggleRefresh(bool const & value)
{
toggleRefresh = value;
}
void SetCoord(internals::PointLatLng const & value)
{
coord = value; emit navPositionChanged(value, Altitude());
}
internals::PointLatLng Coord() const
{
return coord;
}
void SetAltitude(float const & value)
{
altitude = value; emit navPositionChanged(Coord(), Altitude());
}
float Altitude() const
{
return altitude;
}
void RefreshToolTip();
private:
MapGraphicItem *map;
OPMapWidget *mapwidget;
QPixmap pic;
core::Point localposition;
internals::PointLatLng coord;
bool toggleRefresh;
float altitude;
protected:
QPainterPath shape() const;
public slots:
void RefreshPos();
void setOpacitySlot(qreal opacity);
signals:
void navPositionChanged(internals::PointLatLng coord, float);
};
}
#endif // NAVITEM_H

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file opmapwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief The Map Widget, this is the part exposed to the user
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
@ -33,8 +34,8 @@
#include <QOpenGLWidget>
namespace mapcontrol {
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView(parent), configuration(config), UAV(0), GPS(0), Home(0)
, followmouse(true), compass(0), showuav(false), showhome(false), diagTimer(0), diagGraphItem(0), showDiag(false), overlayOpacity(1)
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView(parent), configuration(config), UAV(0), GPS(0), Home(0), Nav(0)
, followmouse(true), compass(0), showuav(false), showhome(false), diagTimer(0), diagGraphItem(0), showDiag(false), showNav(false), overlayOpacity(1)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
core = new internals::Core;
@ -42,8 +43,12 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
mscene.addItem(map);
this->setScene(&mscene);
Home = new HomeItem(map, this);
map->Home = Home;
Home->setParentItem(map);
Home->setZValue(-1);
Nav = new NavItem(map, this);
Nav->setParentItem(map);
Nav->setZValue(-1);
setStyleSheet("QToolTip {font-size:8pt; color:blue;opacity: 223; padding:2px; border-width:2px; border-style:solid; border-color: rgb(170, 170, 127);border-radius:4px }");
this->adjustSize();
connect(map, SIGNAL(zoomChanged(double, double, double)), this, SIGNAL(zoomChanged(double, double, double)));
@ -58,6 +63,7 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
connect(map, SIGNAL(wpdoubleclicked(WayPointItem *)), this, SIGNAL(OnWayPointDoubleClicked(WayPointItem *)));
connect(&mscene, SIGNAL(selectionChanged()), this, SLOT(OnSelectionChanged()));
SetShowDiagnostics(showDiag);
SetShowNav(showNav);
this->setMouseTracking(followmouse);
SetShowCompass(true);
QPixmapCache::setCacheLimit(64 * 1024);
@ -158,6 +164,10 @@ void OPMapWidget::SetShowHome(const bool &value)
{
Home->setVisible(value);
}
void OPMapWidget::SetShowNav(const bool &value)
{
Nav->setVisible(value);
}
void OPMapWidget::resizeEvent(QResizeEvent *event)
{

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file opmapwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief The Map Widget, this is the part exposed to the user
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
@ -37,6 +38,7 @@
#include "uavitem.h"
#include "gpsitem.h"
#include "homeitem.h"
#include "navitem.h"
#include "mapripper.h"
#include "waypointline.h"
#include "waypointcircle.h"
@ -50,6 +52,7 @@ namespace mapcontrol {
class UAVItem;
class GPSItem;
class HomeItem;
class NavItem;
/**
* @brief Collection of static functions to help dealing with various enums used
* Contains functions for enumToString conversio, StringToEnum, QStringList of enum values...
@ -500,6 +503,7 @@ public:
UAVItem *UAV;
GPSItem *GPS;
HomeItem *Home;
NavItem *Nav;
void SetShowUAV(bool const & value);
bool ShowUAV() const
{
@ -510,6 +514,11 @@ public:
{
return showhome;
}
void SetShowNav(bool const & value);
bool ShowNav() const
{
return showNav;
}
void SetShowDiagnostics(bool const & value);
void SetUavPic(QString UAVPic);
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
@ -540,6 +549,7 @@ private:
QTimer *diagTimer;
QGraphicsTextItem *diagGraphItem;
bool showDiag;
bool showNav;
qreal overlayOpacity;
private slots:
void diagRefresh();

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file waypointitem.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief A graphicsItem representing a WayPoint
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
@ -43,16 +44,7 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti
SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos();
myHome = NULL;
QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
if (h) {
myHome = h;
}
}
myHome = map->Home;
if (myHome) {
map->Projection()->offSetFromLatLngs(myHome->Coord(), coord, relativeCoord.distance, relativeCoord.bearing);
relativeCoord.altitudeRelative = Altitude() - myHome->Altitude();
@ -87,16 +79,7 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint) : reached(fa
SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos();
myHome = NULL;
QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
if (h) {
myHome = h;
}
}
myHome = map->Home;
if (myHome) {
coord = map->Projection()->translate(myHome->Coord(), relativeCoord.distance, relativeCoord.bearing);
SetAltitude(myHome->Altitude() + relativeCoord.altitudeRelative);
@ -121,15 +104,7 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti
SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos();
myHome = NULL;
QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
if (h) {
myHome = h;
}
}
myHome = map->Home;
if (myHome) {
map->Projection()->offSetFromLatLngs(myHome->Coord(), coord, relativeCoord.distance, relativeCoord.bearing);
relativeCoord.altitudeRelative = Altitude() - myHome->Altitude();
@ -143,15 +118,7 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti
WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const QString &description, MapGraphicItem *map) : relativeCoord(relativeCoordenate), reached(false), description(description), shownumber(true), isDragging(false), map(map)
{
myHome = NULL;
QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
if (h) {
myHome = h;
}
}
myHome = map->Home;
if (myHome) {
connect(myHome, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(onHomePositionChanged(internals::PointLatLng, float)));
coord = map->Projection()->translate(myHome->Coord(), relativeCoord.distance, relativeCoord.bearing);

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file opmapgadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup OPMapPlugin OpenPilot Map Plugin
@ -50,6 +51,7 @@
#include "uavobject.h"
#include "positionstate.h"
#include "pathdesired.h"
#include "homelocation.h"
#include "gpspositionsensor.h"
#include "gyrostate.h"
@ -166,6 +168,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
m_map->SetShowHome(true); // display the HOME position on the map
m_map->SetShowUAV(true); // display the UAV position on the map
m_map->SetShowNav(false); // initially don't display the NAV position on the map
m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters) //SHOULDN'T THE DEFAULT BE USER DEFINED?
m_map->Home->SetShowSafeArea(true); // show the safe area //SHOULDN'T THE DEFAULT BE USER DEFINED?
@ -213,6 +216,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
connect(m_map, SIGNAL(OnWayPointDoubleClicked(WayPointItem *)), this, SLOT(wpDoubleClickEvent(WayPointItem *)));
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
m_map->Nav->SetCoord(m_home_position.coord); // set the NAV position
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
m_map->UAV->update();
if (m_map->GPS) {
@ -287,6 +291,7 @@ OPMapGadgetWidget::~OPMapGadgetWidget()
disconnect(m_map, 0, 0, 0);
m_map->SetShowHome(false); // doing this appears to stop the map lib crashing on exit
m_map->SetShowUAV(false); // " "
m_map->SetShowNav(false); // " "
}
if (m_map) {
@ -442,6 +447,8 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
contextMenu.addAction(showDiagnostics);
contextMenu.addAction(showNav);
contextMenu.addAction(showUAVInfo);
// Zoom section
@ -670,6 +677,19 @@ void OPMapGadgetWidget::updatePosition()
m_map->UAV->updateTextOverlay();
m_map->UAV->update();
// *************
// *************
// update active waypoint position at same update rate
if (m_map->Nav) {
double latitude, longitude, altitude;
getNavPosition(latitude, longitude, altitude);
m_map->Nav->SetCoord(internals::PointLatLng(latitude, longitude)); // set the maps Nav position
m_map->Nav->SetAltitude(altitude);
m_map->Nav->RefreshPos();
m_map->Nav->update();
}
m_map->UAV->updateTextOverlay();
m_map->UAV->update();
}
/**
@ -1344,6 +1364,12 @@ void OPMapGadgetWidget::createActions()
showDiagnostics->setChecked(false);
connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool)));
showNav = new QAction(tr("Show Nav"), this);
showNav->setStatusTip(tr("Show/Hide pathfollower info"));
showNav->setCheckable(true);
showNav->setChecked(false);
connect(showNav, SIGNAL(toggled(bool)), this, SLOT(onShowNav_toggled(bool)));
showUAVInfo = new QAction(tr("Show UAV Info"), this);
showUAVInfo->setStatusTip(tr("Show/Hide the UAV info"));
showUAVInfo->setCheckable(true);
@ -1647,6 +1673,15 @@ void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show)
m_map->SetShowDiagnostics(show);
}
void OPMapGadgetWidget::onShowNav_toggled(bool show)
{
if (!m_widget || !m_map) {
return;
}
m_map->SetShowNav(show);
}
void OPMapGadgetWidget::onShowUAVInfo_toggled(bool show)
{
if (!m_widget || !m_map) {
@ -2236,6 +2271,57 @@ bool OPMapGadgetWidget::getUAVPosition(double &latitude, double &longitude, doub
return true;
}
bool OPMapGadgetWidget::getNavPosition(double &latitude, double &longitude, double &altitude)
{
double NED[3];
double LLA[3];
double homeLLA[3];
Q_ASSERT(obm != NULL);
PathDesired *pathDesired = PathDesired::GetInstance(obm);
Q_ASSERT(pathDesired != NULL);
PathDesired::DataFields pathDesiredData = pathDesired->getData();
HomeLocation *homeLocation = HomeLocation::GetInstance(obm);
Q_ASSERT(homeLocation != NULL);
HomeLocation::DataFields homeLocationData = homeLocation->getData();
homeLLA[0] = homeLocationData.Latitude / 1.0e7;
homeLLA[1] = homeLocationData.Longitude / 1.0e7;
homeLLA[2] = homeLocationData.Altitude;
NED[0] = pathDesiredData.End[0];
NED[1] = pathDesiredData.End[1];
NED[2] = pathDesiredData.End[2];
Utils::CoordinateConversions().NED2LLA_HomeLLA(homeLLA, NED, LLA);
latitude = LLA[0];
longitude = LLA[1];
altitude = LLA[2];
if (latitude != latitude) {
latitude = 0; // nan detection
} else if (latitude > 90) {
latitude = 90;
} else if (latitude < -90) {
latitude = -90;
}
if (longitude != longitude) {
longitude = 0; // nan detection
} else if (longitude > 180) {
longitude = 180;
} else if (longitude < -180) {
longitude = -180;
}
if (altitude != altitude) {
altitude = 0; // nan detection
}
return true;
}
double OPMapGadgetWidget::getUAV_Yaw()
{
if (!obm) {

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file opmapgadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup OPMapPlugin OpenPilot Map Plugin
@ -174,6 +175,7 @@ private slots:
void onCopyMouseLonToClipAct_triggered();
void onShowCompassAct_toggled(bool show);
void onShowDiagnostics_toggled(bool show);
void onShowNav_toggled(bool show);
void onShowUAVInfo_toggled(bool show);
void onShowUAVAct_toggled(bool show);
void onShowHomeAct_toggled(bool show);
@ -248,6 +250,7 @@ private:
QAction *copyMouseLonToClipAct;
QAction *showCompassAct;
QAction *showDiagnostics;
QAction *showNav;
QAction *showUAVInfo;
QAction *showHomeAct;
QAction *showUAVAct;
@ -308,6 +311,7 @@ private:
internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);
bool getUAVPosition(double &latitude, double &longitude, double &altitude);
bool getNavPosition(double &latitude, double &longitude, double &altitude);
double getUAV_Yaw();
void setMapFollowingMode();