1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-52 Big update to GPS gadget: now supports a new mode, "Telemetry", to display the onboard GPS data, including GPS constellation.

This is not tested in Windows yet - I will do this on another machine ASAP. It might break the serial mode as well, I just lack time to test everything but I will eventually do it.



git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1498 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-09-01 18:53:02 +00:00 committed by edouard
parent 65c832da35
commit 6589e55019
19 changed files with 1171 additions and 689 deletions

View File

@ -0,0 +1,150 @@
/**
******************************************************************************
*
* @file gpsconstellationwidget.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A widget which displays the GPS constellation
*****************************************************************************/
/*
* 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 "gpsconstellationwidget.h"
#include <QtGui>
#include <QDebug>
/*
* Initialize the widget
*/
GpsConstellationWidget::GpsConstellationWidget(QWidget *parent) : QGraphicsView(parent)
{
// Create a layout, add a QGraphicsView and put the SVG inside.
// The constellation widget looks like this:
// |--------------------|
// | |
// | |
// | Constellation |
// | |
// | |
// | |
// |--------------------|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QGraphicsScene *scene = new QGraphicsScene(this);
QSvgRenderer *renderer = new QSvgRenderer();
world = new QGraphicsSvgItem();
renderer->load(QString(":/gpsgadget/images/gpsEarth.svg"));
world->setSharedRenderer(renderer);
world->setElementId("map");
scene->addItem(world);
scene->setSceneRect(world->boundingRect());
setScene(scene);
// Now create 16 satellite icons which we will move around on the map:
for (int i=0; i<16;i++) {
satIcons[i] = new QGraphicsSvgItem();
satIcons[i]->setSharedRenderer(renderer);
satIcons[i]->setElementId("sat-notSeen");
satIcons[i]->setParentItem(world);
}
}
GpsConstellationWidget::~GpsConstellationWidget()
{
}
void GpsConstellationWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
// Thit fitInView method should only be called now, once the
// widget is shown, otherwise it cannot compute its values and
// the result is usually a ahrsbargraph that is way too small.
fitInView(world, Qt::KeepAspectRatio);
// Scale, can't use fitInView since that doesn't work until we're shown.
// qreal factor = height()/world->boundingRect().height();
// world->setScale(factor);
// setSceneRect(world->boundingRect());
}
void GpsConstellationWidget::updateSat(int index, int prn, int elevation, int azimuth, int snr)
{
if (index > 16)
return; // A bit of error checking never hurts.
// TODO: add range checking
satellites[index][0] = prn;
satellites[index][1] = elevation;
satellites[index][2] = azimuth;
satellites[index][3] = snr;
if (prn) {
QPointF opd = polarToCoord(elevation,azimuth);
opd += QPointF(-satIcons[index]->boundingRect().center().x(),
-satIcons[index]->boundingRect().center().y());
satIcons[index]->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), false);
if (snr)
satIcons[index]->setElementId("satellite");
else
satIcons[index]->setElementId("sat-notSeen");
satIcons[index]->show();
} else {
satIcons[index]->hide();
}
}
/**
Converts the elevation/azimuth to X/Y coordinates on the map
*/
QPointF GpsConstellationWidget::polarToCoord(int elevation, int azimuth)
{
double x;
double y;
double rad_elevation;
double rad_azimuth;
rad_elevation = M_PI*elevation/180;
rad_azimuth = M_PI*azimuth/180;
x = cos(rad_elevation)*sin(rad_azimuth);
y = -cos(rad_elevation)*cos(rad_azimuth);
x = world->boundingRect().width()/2 * x;
y = world->boundingRect().height()/2 * y;
x = (world->boundingRect().width() / 2) + x;
y = (world->boundingRect().height() / 2) + y;
return QPointF(x,y);
}

View File

@ -0,0 +1,62 @@
/**
******************************************************************************
*
* @file gpsconstellationwidget.h
* @author Edouard Lafargue Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A widget which displays the GPS constellation
*****************************************************************************/
/*
* 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 GPSCONSTELLATIONWIDGET_H_
#define GPSCONSTELLATIONWIDGET_H_
#include <QGraphicsView>
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QGraphicsSvgItem>
class GpsConstellationWidget : public QGraphicsView
{
Q_OBJECT
public:
GpsConstellationWidget(QWidget *parent = 0);
~GpsConstellationWidget();
public slots:
void updateSat(int index, int prn, int elevation, int azimuth, int snr);
private slots:
private:
int satellites[16][4];
QGraphicsSvgItem* satIcons[16];
QGraphicsSvgItem *world;
QGraphicsView *gpsConstellation;
QPointF polarToCoord(int elevation, int azimuth);
protected:
void showEvent(QShowEvent *event);
};
#endif /* GPSCONSTELLATIONWIDGET_H_ */

View File

@ -1,27 +1,33 @@
TEMPLATE = lib
TARGET = GpsDisplayGadget
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(gpsdisplay_dependencies.pri)
include(../../libs/qwt/qwt.pri)
HEADERS += gpsdisplayplugin.h
HEADERS += buffer.h
HEADERS += nmeaparser.h
HEADERS += gpsdisplaygadget.h
HEADERS += gpsdisplaywidget.h
HEADERS += gpsdisplaygadgetfactory.h
HEADERS += gpsdisplaygadgetconfiguration.h
HEADERS += gpsdisplaygadgetoptionspage.h
SOURCES += gpsdisplayplugin.cpp
SOURCES += buffer.cpp
SOURCES += nmeaparser.cpp
SOURCES += gpsdisplaygadget.cpp
SOURCES += gpsdisplaygadgetfactory.cpp
SOURCES += gpsdisplaywidget.cpp
SOURCES += gpsdisplaygadgetconfiguration.cpp
SOURCES += gpsdisplaygadgetoptionspage.cpp
OTHER_FILES += GpsDisplayGadget.pluginspec
FORMS += gpsdisplaygadgetoptionspage.ui
FORMS += gpsdisplaywidget.ui
RESOURCES += widgetresources.qrc
TEMPLATE = lib
TARGET = GpsDisplayGadget
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(gpsdisplay_dependencies.pri)
include(../../libs/qwt/qwt.pri)
HEADERS += gpsdisplayplugin.h \
gpsconstellationwidget.h \
gpsparser.h \
telemetryparser.h
HEADERS += buffer.h
HEADERS += nmeaparser.h
HEADERS += gpsdisplaygadget.h
HEADERS += gpsdisplaywidget.h
HEADERS += gpsdisplaygadgetfactory.h
HEADERS += gpsdisplaygadgetconfiguration.h
HEADERS += gpsdisplaygadgetoptionspage.h
SOURCES += gpsdisplayplugin.cpp \
gpsconstellationwidget.cpp \
gpsparser.cpp \
telemetryparser.cpp
SOURCES += buffer.cpp
SOURCES += nmeaparser.cpp
SOURCES += gpsdisplaygadget.cpp
SOURCES += gpsdisplaygadgetfactory.cpp
SOURCES += gpsdisplaywidget.cpp
SOURCES += gpsdisplaygadgetconfiguration.cpp
SOURCES += gpsdisplaygadgetoptionspage.cpp
OTHER_FILES += GpsDisplayGadget.pluginspec
FORMS += gpsdisplaygadgetoptionspage.ui
FORMS += gpsdisplaywidget.ui
RESOURCES += widgetresources.qrc

View File

@ -48,25 +48,34 @@ GpsDisplayGadget::~GpsDisplayGadget()
void GpsDisplayGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
GpsDisplayGadgetConfiguration *m = qobject_cast< GpsDisplayGadgetConfiguration*>(config);
PortSettings portsettings;
portsettings.BaudRate=m->speed();
portsettings.DataBits=m->dataBits();
portsettings.FlowControl=m->flow();
portsettings.Parity=m->parity();
portsettings.StopBits=m->stopBits();
portsettings.Timeout_Millisec=m->timeOut();
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo nport, ports ) {
if(nport.friendName == m->port())
if (m->connectionMode() == "Serial") {
PortSettings portsettings;
portsettings.BaudRate=m->speed();
portsettings.DataBits=m->dataBits();
portsettings.FlowControl=m->flow();
portsettings.Parity=m->parity();
portsettings.StopBits=m->stopBits();
portsettings.Timeout_Millisec=m->timeOut();
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo nport, ports ) {
if(nport.friendName == m->port())
{
#ifdef Q_OS_WIN
QextSerialPort *port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
QextSerialPort *port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
#else
QextSerialPort *port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
QextSerialPort *port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
#endif
//Creates new serial port with the user configuration and passes it to the widget
m_widget->setPort(port);
//Creates new serial port with the user configuration and passes it to the widget
m_widget->setParser(QString("Serial"));
m_widget->setPort(port);
}
}
}
} else if (m->connectionMode() == "Telemetry") {
m_widget->setParser(QString("Telemetry"));
} else if (m->connectionMode() == "Network") {
// Not implemented for now...
}
}

View File

@ -35,6 +35,7 @@
*/
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_connectionMode("Serial"),
m_defaultPort("Unknown"),
m_defaultSpeed(BAUD4800),
m_defaultDataBits(DATA_8),
@ -42,7 +43,6 @@ GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, co
m_defaultParity(PAR_NONE),
m_defaultStopBits(STOP_1),
m_defaultTimeOut(5000)
{
//if a saved configuration exists load it
if (state.count() > 0) {
@ -58,24 +58,27 @@ GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, co
int iparity;
int istopbits;
QString port;
QString conMode;
stream >> ispeed;
stream >> idatabits;
stream >>iflow;
stream >>iparity;
stream >> istopbits;
stream >> port;
stream >> conMode;
databits=(DataBitsType) idatabits;
flow=(FlowType)iflow;
parity=(ParityType)iparity;
stopbits=(StopBitsType)istopbits;
speed=(BaudRateType)ispeed;
m_defaultPort=port;
m_defaultSpeed=speed;
m_defaultDataBits=databits;
m_defaultFlow=flow;
m_defaultParity=parity;
m_defaultStopBits=stopbits;
databits = (DataBitsType) idatabits;
flow = (FlowType)iflow;
parity = (ParityType)iparity;
stopbits = (StopBitsType)istopbits;
speed = (BaudRateType)ispeed;
m_defaultPort = port;
m_defaultSpeed = speed;
m_defaultDataBits = databits;
m_defaultFlow = flow;
m_defaultParity = parity;
m_defaultStopBits = stopbits;
m_connectionMode = conMode;
}
@ -89,12 +92,13 @@ IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone()
{
GpsDisplayGadgetConfiguration *m = new GpsDisplayGadgetConfiguration(this->classId());
m->m_defaultSpeed=m_defaultSpeed;
m->m_defaultDataBits=m_defaultDataBits;
m->m_defaultFlow=m_defaultFlow;
m->m_defaultParity=m_defaultParity;
m->m_defaultStopBits=m_defaultStopBits;
m->m_defaultPort=m_defaultPort;
m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
m->m_connectionMode = m_connectionMode;
return m;
}
@ -112,5 +116,6 @@ QByteArray GpsDisplayGadgetConfiguration::saveState() const
stream << (int)m_defaultParity;
stream << (int)m_defaultStopBits;
stream << m_defaultPort;
stream << m_connectionMode;
return bytes;
}

View File

@ -39,6 +39,9 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
public:
explicit GpsDisplayGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
void setConnectionMode(QString mode) { m_connectionMode = mode; }
QString connectionMode() { return m_connectionMode; }
//set port configuration functions
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
@ -61,6 +64,7 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
IUAVGadgetConfiguration *clone();
private:
QString m_connectionMode;
QString m_defaultPort;
BaudRateType m_defaultSpeed;
DataBitsType m_defaultDataBits;

View File

@ -227,6 +227,13 @@ QWidget *GpsDisplayGadgetOptionsPage::createPage(QWidget *parent)
// TIMEOUT
options_page->timeoutSpinBox->setValue(m_config->timeOut());
QStringList connectionModes;
connectionModes << "Serial" << "Network" << "Telemetry";
options_page->connectionMode->addItems(connectionModes);
int conMode = options_page->connectionMode->findText(m_config->connectionMode());
if (conMode != -1)
options_page->connectionMode->setCurrentIndex(conMode);
return optionsPageWidget;
}
@ -249,6 +256,8 @@ void GpsDisplayGadgetOptionsPage::apply()
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(options_page->stopBitsComboBox->currentText()));
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(options_page->parityComboBox->currentText()));
m_config->setTimeOut( options_page->timeoutSpinBox->value());
m_config->setConnectionMode(options_page->connectionMode->currentText());
}
void GpsDisplayGadgetOptionsPage::finish()

View File

@ -1,159 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GpsDisplayGadgetOptionsPage</class>
<widget class="QWidget" name="GpsDisplayGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>46</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Mode:</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>50</x>
<y>10</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>160</x>
<y>40</y>
<width>118</width>
<height>3</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>421</width>
<height>201</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="portComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="portSpeedLabel">
<property name="text">
<string>Port Speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="portSpeedComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="flowControlLabel">
<property name="text">
<string>Flow Control:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="flowControlComboBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="dataBitsLabel">
<property name="text">
<string>Data Bits:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="dataBitsComboBox"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="stopBitsLabel">
<property name="text">
<string>Stop Bits:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="stopBitsComboBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="parityLabel">
<property name="text">
<string>Parity:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="parityComboBox"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Timeout(ms):</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="timeoutSpinBox">
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GpsDisplayGadgetOptionsPage</class>
<widget class="QWidget" name="GpsDisplayGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>359</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>46</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Mode:</string>
</property>
</widget>
<widget class="QComboBox" name="connectionMode">
<property name="geometry">
<rect>
<x>50</x>
<y>1</y>
<width>101</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>160</x>
<y>40</y>
<width>118</width>
<height>3</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>73</y>
<width>221</width>
<height>261</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="portComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="portSpeedLabel">
<property name="text">
<string>Port Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="portSpeedComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="flowControlLabel">
<property name="text">
<string>Flow Control:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="flowControlComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="dataBitsLabel">
<property name="text">
<string>Data Bits:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="dataBitsComboBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="stopBitsLabel">
<property name="text">
<string>Stop Bits:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="stopBitsComboBox"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="parityLabel">
<property name="text">
<string>Parity:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="parityComboBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Timeout(ms):</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="timeoutSpinBox">
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>280</x>
<y>50</y>
<width>111</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>IP Connection</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>60</x>
<y>50</y>
<width>125</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Serial Connection</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -34,6 +34,7 @@
#include <QtGui>
#include <QDebug>
#include "nmeaparser.h"
#include "telemetryparser.h"
@ -45,20 +46,6 @@ GpsDisplayWidget::GpsDisplayWidget(QWidget *parent) : QWidget(parent)
widget = new Ui_GpsDisplayWidget();
widget->setupUi(this);
QGraphicsScene *scene = new QGraphicsScene(this);
QSvgRenderer *renderer = new QSvgRenderer();
QGraphicsSvgItem *world = new QGraphicsSvgItem();
renderer->load(QString(":/gpsgadget/images/gpsEarth.svg"));
world->setSharedRenderer(renderer);
world->setElementId("map");
scene->addItem(world);
scene->setSceneRect(world->boundingRect());
widget->gpsWorld->setScene(scene);
// Scale, can't use fitInView since that doesn't work until we're shown.
qreal factor = widget->gpsWorld->size().height()/world->boundingRect().height();
world->setScale(factor);
//Not elegant, just load the image for now
QGraphicsScene *fescene = new QGraphicsScene(this);
QPixmap earthpix( ":/gpsgadget/images/flatEarth.png" );
@ -69,14 +56,6 @@ GpsDisplayWidget::GpsDisplayWidget(QWidget *parent) : QWidget(parent)
this,SLOT(connectButtonClicked()));
connect(widget->disconnectButton, SIGNAL(clicked(bool)),
this,SLOT(disconnectButtonClicked()));
parser=new NMEAParser();
connect(parser,SIGNAL(sv(int)),this,SLOT(setSVs(int)));
connect(parser,SIGNAL(position(double,double,double)),this,SLOT(setPosition(double,double,double)));
connect(parser,SIGNAL(speedheading(double,double)),this,SLOT(setSpeedHeading(double,double)));
connect(parser,SIGNAL(datetime(double,double)),this,SLOT(setDateTime(double,double)));
connect(parser,SIGNAL(packet(char*)), this, SLOT(dumpPacket(char*)));
port = NULL;
}
GpsDisplayWidget::~GpsDisplayWidget()
@ -143,16 +122,38 @@ void GpsDisplayWidget::setPosition(double lat, double lon, double alt)
//widget->textBrowser->append(temp);
}
void GpsDisplayWidget::setPort(QextSerialPort* port)
{
this->port=port;
}
void GpsDisplayWidget::setParser(NMEAParser* parser)
void GpsDisplayWidget::setParser(QString connectionMode)
{
this->parser=parser;
if (connectionMode == "Serial") {
parser = new NMEAParser();
widget->connectButton->setEnabled(true);
widget->disconnectButton->setEnabled(false);
} else if (connectionMode == "Telemetry") {
parser = new TelemetryParser();
widget->connectButton->setEnabled(false);
widget->disconnectButton->setEnabled(false);
} else {
parser = new NMEAParser(); // for the time being...
}
connect(parser,SIGNAL(sv(int)),this,SLOT(setSVs(int)));
connect(parser,SIGNAL(position(double,double,double)),this,SLOT(setPosition(double,double,double)));
connect(parser,SIGNAL(speedheading(double,double)),this,SLOT(setSpeedHeading(double,double)));
connect(parser,SIGNAL(datetime(double,double)),this,SLOT(setDateTime(double,double)));
connect(parser,SIGNAL(packet(char*)), this, SLOT(dumpPacket(char*)));
connect(parser, SIGNAL(satellite(int,int,int,int,int)), widget->gpsSky, SLOT(updateSat(int,int,int,int,int)))
;
port = NULL;
}
void GpsDisplayWidget::connectButtonClicked() {

View File

@ -29,6 +29,7 @@
#define GPSDISPLAYWIDGET_H_
#include "gpsdisplaygadgetconfiguration.h"
#include "gpsconstellationwidget.h"
#include "uavobjects/uavobject.h"
#include <QGraphicsView>
#include <QtSvg/QSvgRenderer>
@ -50,7 +51,7 @@ public:
// void setMode(QString mode); // Either UAVTalk or serial port
void setPort(QextSerialPort* port);
void setParser(NMEAParser *parser);
void setParser(QString connectionMode);
private slots:
void connectButtonClicked();
@ -65,8 +66,9 @@ private slots:
private:
void processNewSerialData(QByteArray serialData);
Ui_GpsDisplayWidget* widget;
GpsConstellationWidget * gpsConstellation;
QextSerialPort *port;
NMEAParser *parser;
GPSParser *parser;
bool connected;
};

View File

@ -1,412 +1,347 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GpsDisplayWidget</class>
<widget class="QWidget" name="GpsDisplayWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>570</width>
<height>319</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="statusGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>GPS Status</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="status_label">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="status_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lat_label">
<property name="text">
<string>Latitude:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lat_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="long_label">
<property name="text">
<string>Longitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="long_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="bear_label">
<property name="text">
<string>Bearing:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="bear_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="speed_label">
<property name="text">
<string>Speed:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="speed_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fix_label">
<property name="text">
<string>Fix Type:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="fix_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="gtime_label">
<property name="text">
<string>GPS Time:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="gtime_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="gdate_label">
<property name="text">
<string>GPS Date:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="gdate_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="imagesWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>368</width>
<height>171</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>368</width>
<height>171</height>
</size>
</property>
<widget class="QGraphicsView" name="gpsWorld">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>171</width>
<height>171</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>171</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>171</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip">
<string extracomment="Shows locations of satellites"/>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sceneRect">
<rectf>
<x>0.000000000000000</x>
<y>0.000000000000000</y>
<width>169.000000000000000</width>
<height>169.000000000000000</height>
</rectf>
</property>
</widget>
<widget class="QGraphicsView" name="flatEarth">
<property name="geometry">
<rect>
<x>177</x>
<y>0</y>
<width>191</width>
<height>95</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>191</width>
<height>95</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>191</width>
<height>95</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip">
<string extracomment="Location of GCS on the Earth"/>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="optimizationFlags">
<set>QGraphicsView::DontAdjustForAntialiasing</set>
</property>
</widget>
<widget class="QGraphicsView" name="gpsGraph">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>177</x>
<y>104</y>
<width>191</width>
<height>67</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>191</width>
<height>67</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>191</width>
<height>67</height>
</size>
</property>
<property name="toolTip">
<string extracomment="Individual satellite information"/>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="dataStreamGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>GPS Data Stream</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,0">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0">
<property name="leftMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Ignored</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectButton">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier New</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::WidgetWidth</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GpsDisplayWidget</class>
<widget class="QWidget" name="GpsDisplayWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>570</width>
<height>319</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="statusGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>GPS Status</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="status_label">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="status_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lat_label">
<property name="text">
<string>Latitude:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lat_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="long_label">
<property name="text">
<string>Longitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="long_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="bear_label">
<property name="text">
<string>Bearing:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="bear_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="speed_label">
<property name="text">
<string>Speed:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="speed_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fix_label">
<property name="text">
<string>Fix Type:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="fix_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="gtime_label">
<property name="text">
<string>GPS Time:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="gtime_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="gdate_label">
<property name="text">
<string>GPS Date:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="gdate_value">
<property name="text">
<string>Unknown</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="imagesWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>368</width>
<height>171</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>368</width>
<height>171</height>
</size>
</property>
<widget class="QGraphicsView" name="flatEarth">
<property name="geometry">
<rect>
<x>177</x>
<y>0</y>
<width>191</width>
<height>95</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>191</width>
<height>95</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>191</width>
<height>95</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip">
<string extracomment="Location of GCS on the Earth"/>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="optimizationFlags">
<set>QGraphicsView::DontAdjustForAntialiasing</set>
</property>
</widget>
<widget class="GpsConstellationWidget" name="gpsSky">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>171</width>
<height>151</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="dataStreamGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>GPS Data Stream</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,0">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0">
<property name="leftMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Ignored</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectButton">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier New</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::WidgetWidth</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GpsConstellationWidget</class>
<extends>QGraphicsView</extends>
<header>gpsconstellationwidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,28 @@
/**
******************************************************************************
*
* @file gpsparser.cpp
* @author Sami Korhonen Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 "gpsparser.h"

View File

@ -0,0 +1,51 @@
/**
******************************************************************************
*
* @file gpsparser.h
* @author Sami Korhonen Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 GPSPARSER_H
#define GPSPARSER_H
#include <QObject>
#include <QtCore>
#include <stdint.h>
class GPSParser: public QObject
{
Q_OBJECT
public:
void processInputStream(char c) { Q_UNUSED(c)};
signals:
void sv(int); // Satellites in view
void position(double,double,double); // Lat, Lon, Alt
void datetime(double,double); // Date then time
void speedheading(double,double);
void packet(char*); // Raw NMEA Packet (or just info)
void satellite(int,int,int,int,int); // Index, PRN, Elevation, Azimuth, SNR
};
#endif // GPSPARSER_H

View File

@ -109,16 +109,16 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="187.01425"
inkscape:cy="254.52868"
inkscape:zoom="0.7"
inkscape:cx="84.9969"
inkscape:cy="256.33672"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:current-layer="map"
showgrid="false"
inkscape:window-width="1280"
inkscape:window-height="744"
inkscape:window-x="-4"
inkscape:window-y="1020"
inkscape:window-width="1366"
inkscape:window-height="693"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
@ -185,7 +185,7 @@
d="m 451.12161,342.96352 c 37.2498,32.4066 41.17599,88.87427 8.76939,126.12407 -32.4066,37.2498 -88.87426,41.17599 -126.12407,8.76939 -37.2498,-32.4066 -41.17598,-88.87427 -8.76938,-126.12407 29.53979,-33.95454 79.71538,-40.65585 117.1306,-15.64362"
transform="matrix(1.9716104,0,0,1.9716104,-399.86707,-407.46887)" />
<g
transform="translate(2.1015148,0)"
transform="translate(2.1015148,18)"
id="g3618">
<rect
style="fill:#acbbf0;fill-opacity:1;stroke:#909196;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
@ -208,7 +208,7 @@
y="182.85712">N</tspan></text>
</g>
<g
transform="translate(0,-0.53294563)"
transform="translate(-12,-0.53294563)"
id="g3695">
<rect
style="fill:#acbbf0;fill-opacity:1;stroke:#909196;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
@ -231,7 +231,7 @@
y="414.77591">E</tspan></text>
</g>
<g
transform="translate(-0.40098763,0)"
transform="translate(-0.40098763,-18)"
id="g3707">
<rect
style="fill:#acbbf0;fill-opacity:1;stroke:#909196;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
@ -254,7 +254,7 @@
y="640.0907">S</tspan></text>
</g>
<g
transform="translate(2.502516,459.47727)"
transform="translate(22.502516,459.47727)"
id="g3687">
<rect
ry="3.3283663"
@ -311,7 +311,7 @@
</g>
<g
id="satellite"
transform="matrix(0.73446976,0,0,0.73446976,137.3895,45.89308)"
transform="matrix(0.93879118,0,0,0.93879118,26.496058,0.9451615)"
inkscape:label="#g3722">
<path
transform="translate(0.08444214,0)"
@ -321,7 +321,7 @@
sodipodi:cy="195.93361"
sodipodi:cx="569.28571"
id="path3712"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="arc" />
<rect
ry="2.2728431"
@ -330,9 +330,9 @@
height="45.456863"
width="4.5456862"
id="rect3718"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
<rect
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3720"
width="4.5456862"
height="45.456863"
@ -340,5 +340,37 @@
y="173.52946"
ry="2.2728431" />
</g>
<g
inkscape:label="#g3722"
transform="matrix(0.93879118,0,0,0.93879118,-357.05733,0.9451615)"
id="sat-notSeen"
style="opacity:0.4">
<path
sodipodi:type="arc"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path3069"
sodipodi:cx="569.28571"
sodipodi:cy="195.93361"
sodipodi:rx="20.714285"
sodipodi:ry="20.714285"
d="m 589.99999,195.93361 c 0,11.44018 -9.2741,20.71428 -20.71428,20.71428 -11.44019,0 -20.71429,-9.2741 -20.71429,-20.71428 0,-11.44018 9.2741,-20.71429 20.71429,-20.71429 11.44018,0 20.71428,9.27411 20.71428,20.71429 z"
transform="translate(0.08444214,0)" />
<rect
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384000000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3071"
width="4.5456862"
height="45.456863"
x="590.45447"
y="173.52946"
ry="2.2728431" />
<rect
ry="2.2728431"
y="173.52946"
x="543.74017"
height="45.456863"
width="4.5456862"
id="rect3073"
style="fill:#fff954;fill-opacity:1;stroke:#fcaa21;stroke-width:1.56471384000000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -63,7 +63,7 @@
/**
* Initialize the parser
*/
NMEAParser::NMEAParser(QObject *parent):QObject(parent)
NMEAParser::NMEAParser(QObject *parent):GPSParser()
{
bufferInit(&gpsRxBuffer, (unsigned char *)gpsRxData, 512);
gpsRxOverflow=0;

View File

@ -32,6 +32,7 @@
#include <QtCore>
#include <stdint.h>
#include "buffer.h"
#include "gpsparser.h"
// constants/macros/typdefs
#define NMEA_BUFFERSIZE 128
@ -54,9 +55,9 @@ typedef struct struct_GpsData
}GpsData_t;
class NMEAParser: public QObject
class NMEAParser: public GPSParser
{
Q_OBJECT
public:
NMEAParser(QObject *parent = 0);
~NMEAParser();
@ -76,13 +77,7 @@ public:
uint32_t numUpdates;
uint32_t numErrors;
int32_t gpsRxOverflow;
signals:
void sv(int);
void position(double,double,double);
void datetime(double,double);
void speedheading(double,double);
void packet(char*);
private slots:
};
#endif // NMEAPARSER_H

View File

@ -0,0 +1,112 @@
/**
******************************************************************************
*
* @file telemetryparser.cpp
* @author Edouard Lafargue & the OpenPilot team Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 "telemetryparser.h"
#include <math.h>
#include <QDebug>
#include <QStringList>
/**
* Initialize the parser
*/
TelemetryParser::TelemetryParser(QObject *parent) : GPSParser()
{
Q_UNUSED(parent)
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject *gpsObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GPSPosition"));
if (gpsObj != NULL) {
connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateGPS(UAVObject*)));
} else {
qDebug() << "Error: Object is unknown (GPSPosition).";
}
gpsObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GPSTime"));
if (gpsObj != NULL) {
connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateTime(UAVObject*)));
} else {
qDebug() << "Error: Object is unknown (GPSTime).";
}
gpsObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GPSSatellites"));
if (gpsObj != NULL) {
connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateSats(UAVObject*)));
}
}
TelemetryParser::~TelemetryParser()
{
}
void TelemetryParser::updateGPS( UAVObject* object1) {
UAVObjectField* field = object1->getField(QString("Satellites"));
emit sv(field->getValue().toInt());
double lat = object1->getField(QString("Latitude"))->getDouble();
double lon = object1->getField(QString("Longitude"))->getDouble();
double alt = object1->getField(QString("Altitude"))->getDouble();
emit position(lat,lon,alt);
}
void TelemetryParser::updateTime( UAVObject* object1) {
double hour = object1->getField(QString("Hour"))->getDouble();
double minute = object1->getField(QString("Minute"))->getDouble();
double second = object1->getField(QString("Second"))->getDouble();
double time = second + minute*100 + hour*10000;
double year = object1->getField(QString("Year"))->getDouble();
double month = object1->getField(QString("Month"))->getDouble();
double day = object1->getField(QString("Day"))->getDouble();
double date = day + month * 100 + year * 10000;
emit datetime(date,time);
}
/**
Updates the satellite constellation.
Not really optimized for now, we should only send updates for the stas
which have changed instead of updating everything... That said, Qt is supposed
to be able to optimize redraws anyway.
*/
void TelemetryParser::updateSats( UAVObject* object1) {
UAVObjectField* prn = object1->getField(QString("PRN"));
UAVObjectField* elevation = object1->getField(QString("Elevation"));
UAVObjectField* azimuth = object1->getField(QString("Azimuth"));
UAVObjectField* snr = object1->getField(QString("SNR"));
for (int i=0;i< prn->getNumElements();i++) {
emit satellite(i,prn->getValue(i).toInt(),elevation->getValue(i).toInt(),
azimuth->getValue(i).toInt(), snr->getValue(i).toInt());
}
}

View File

@ -0,0 +1,55 @@
/**
******************************************************************************
*
* @file nmeaparser.h
* @author Edouard Lafargue & the OpenPilot team Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 TELEMETRYPARSER_H
#define TELEMETRYPARSER_H
#include <QObject>
#include <QtCore>
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include "gpsparser.h"
class TelemetryParser: public GPSParser
{
Q_OBJECT
public:
TelemetryParser(QObject *parent = 0);
~TelemetryParser();
public slots:
void updateGPS(UAVObject* object1);
void updateTime(UAVObject* object1);
void updateSats(UAVObject* object1);
};
#endif // TELEMETRYPARSER_H

View File

@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/gpsgadget">
<file>images/gpsEarth.svg</file>
<file>images/flatEarth.png</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/gpsgadget">
<file>images/gpsEarth.svg</file>
<file>images/flatEarth.png</file>
</qresource>
</RCC>