diff --git a/ground/src/plugins/antennatrack/AntennaTrack.pluginspec b/ground/src/plugins/antennatrack/AntennaTrack.pluginspec
new file mode 100644
index 000000000..99d64a973
--- /dev/null
+++ b/ground/src/plugins/antennatrack/AntennaTrack.pluginspec
@@ -0,0 +1,11 @@
+
+ The OpenPilot Project
+ (C) 2010 SK
+ The GNU Public License (GPL) Version 3
+ Plugin for antenna tracker
+ http://www.openpilot.org
+
+
+
+
+
diff --git a/ground/src/plugins/antennatrack/antennatrack.pro b/ground/src/plugins/antennatrack/antennatrack.pro
new file mode 100644
index 000000000..c2e11732c
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrack.pro
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+TARGET = AntennaTrack
+include(../../openpilotgcsplugin.pri)
+include(../../plugins/coreplugin/coreplugin.pri)
+include(antennatrack_dependencies.pri)
+include(../../libs/qwt/qwt.pri)
+HEADERS += antennatrackplugin.h
+HEADERS += gpsparser.h
+HEADERS += telemetryparser.h
+HEADERS += antennatrackgadget.h
+HEADERS += antennatrackwidget.h
+HEADERS += antennatrackgadgetfactory.h
+HEADERS += antennatrackgadgetconfiguration.h
+HEADERS += antennatrackgadgetoptionspage.h
+SOURCES += antennatrackplugin.cpp
+SOURCES += gpsparser.cpp
+SOURCES += telemetryparser.cpp
+SOURCES += antennatrackgadget.cpp
+SOURCES += antennatrackgadgetfactory.cpp
+SOURCES += antennatrackwidget.cpp
+SOURCES += antennatrackgadgetconfiguration.cpp
+SOURCES += antennatrackgadgetoptionspage.cpp
+OTHER_FILES += AntennaTrack.pluginspec
+FORMS += antennatrackgadgetoptionspage.ui
+FORMS += antennatrackwidget.ui
diff --git a/ground/src/plugins/antennatrack/antennatrack_dependencies.pri b/ground/src/plugins/antennatrack/antennatrack_dependencies.pri
new file mode 100644
index 000000000..ad54b0073
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrack_dependencies.pri
@@ -0,0 +1,3 @@
+include(../../plugins/uavobjects/uavobjects.pri)
+#include(../../plugins/coreplugin/coreplugin.pri)
+#include(../../libs/utils/utils.pri)
diff --git a/ground/src/plugins/antennatrack/antennatrackgadget.cpp b/ground/src/plugins/antennatrack/antennatrackgadget.cpp
new file mode 100644
index 000000000..36f5645b5
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadget.cpp
@@ -0,0 +1,155 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTracgadget.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 "antennatrackgadget.h"
+#include "antennatrackwidget.h"
+#include "antennatrackgadgetconfiguration.h"
+
+AntennaTrackGadget::AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent) :
+ IUAVGadget(classId, parent),
+ m_widget(widget),
+ connected(FALSE)
+{
+ connect(m_widget->connectButton, SIGNAL(clicked(bool)), this,SLOT(onConnect()));
+ connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this,SLOT(onDisconnect()));
+}
+
+AntennaTrackGadget::~AntennaTrackGadget()
+{
+}
+
+/*
+ This is called when a configuration is loaded, and updates the plugin's settings.
+ Careful: the plugin is already drawn before the loadConfiguration method is called the
+ first time, so you have to be careful not to assume all the plugin values are initialized
+ the first time you use them
+ */
+void AntennaTrackGadget::loadConfiguration(IUAVGadgetConfiguration* config)
+{
+ // Delete the (old)port, this also closes it.
+ if(port) {
+ delete port;
+ }
+
+ // Delete the (old)parser, this also disconnects all signals.
+ if(parser) {
+ delete parser;
+ }
+
+ AntennaTrackGadgetConfiguration *AntennaTrackConfig = qobject_cast< AntennaTrackGadgetConfiguration*>(config);
+
+ PortSettings portsettings;
+ portsettings.BaudRate=AntennaTrackConfig->speed();
+ portsettings.DataBits=AntennaTrackConfig->dataBits();
+ portsettings.FlowControl=AntennaTrackConfig->flow();
+ portsettings.Parity=AntennaTrackConfig->parity();
+ portsettings.StopBits=AntennaTrackConfig->stopBits();
+ portsettings.Timeout_Millisec=AntennaTrackConfig->timeOut();
+
+ // In case we find no port, buttons disabled
+ m_widget->connectButton->setEnabled(false);
+ m_widget->disconnectButton->setEnabled(false);
+
+ QList ports = QextSerialEnumerator::getPorts();
+ foreach( QextPortInfo nport, ports ) {
+ if(nport.friendName == AntennaTrackConfig->port())
+ {
+ qDebug() << "Using Serial port";
+ //parser = new NMEAParser();
+
+#ifdef Q_OS_WIN
+ port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
+#else
+ port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
+#endif
+ m_widget->setPort(port);
+ m_widget->connectButton->setEnabled(true);
+ m_widget->disconnectButton->setEnabled(false);
+ m_widget->connectButton->setHidden(false);
+ m_widget->disconnectButton->setHidden(false);
+
+ connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
+ }
+ }
+ m_widget->dataStreamGroupBox->setHidden(false);
+ qDebug() << "Using Telemetry parser";
+ parser = new TelemetryParser();
+
+ connect(parser, SIGNAL(position(double,double,double)), m_widget,SLOT(setPosition(double,double,double)));
+ connect(parser, SIGNAL(home(double,double,double)), m_widget,SLOT(setHomePosition(double,double,double)));
+ connect(parser, SIGNAL(packet(QString)), m_widget, SLOT(dumpPacket(QString)));
+}
+
+void AntennaTrackGadget::onConnect() {
+ m_widget->textBrowser->append(QString("Connecting to Tracker ...\n"));
+ // TODO: Somehow mark that we're running, and disable connect button while so?
+
+ if (port) {
+ qDebug() << "Opening: " << port->portName() << ".";
+ bool isOpen = port->open(QIODevice::ReadWrite);
+ qDebug() << "Open: " << isOpen;
+ if(isOpen) {
+ m_widget->connectButton->setEnabled(false);
+ m_widget->disconnectButton->setEnabled(true);
+ }
+ } else {
+ qDebug() << "Port undefined or invalid.";
+ }
+
+}
+
+void AntennaTrackGadget::onDisconnect() {
+ if (port) {
+ qDebug() << "Closing: " << port->portName() << ".";
+ port->close();
+ m_widget->connectButton->setEnabled(true);
+ m_widget->disconnectButton->setEnabled(false);
+ } else {
+ qDebug() << "Port undefined or invalid.";
+ }
+}
+
+void AntennaTrackGadget::onDataAvailable() {
+ int avail = port->bytesAvailable();
+ if( avail > 0 ) {
+ QByteArray serialData;
+ serialData.resize(avail);
+ int bytesRead = port->read(serialData.data(), serialData.size());
+ if( bytesRead > 0 ) {
+ processNewSerialData(serialData);
+ }
+ }
+}
+
+void AntennaTrackGadget::processNewSerialData(QByteArray serialData) {
+ int dataLength = serialData.size();
+ const char* data = serialData.constData();
+ m_widget->textBrowser->append(QString(serialData));
+ for(int pos = 0; pos < dataLength; pos++) {
+ //parser->processInputStream(data[pos]);
+ }
+}
diff --git a/ground/src/plugins/antennatrack/antennatrackgadget.h b/ground/src/plugins/antennatrack/antennatrackgadget.h
new file mode 100644
index 000000000..3e604d694
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadget.h
@@ -0,0 +1,72 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTrackgadget.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 ANTENNATRACKGADGET_H_
+#define ANTENNATRACKGADGET_H_
+
+#include
+#include
+#include
+#include "antennatrackwidget.h"
+#include "telemetryparser.h"
+
+class IUAVGadget;
+class QWidget;
+class QString;
+class AntennaTrackWidget;
+
+using namespace Core;
+
+class AntennaTrackGadget : public Core::IUAVGadget
+{
+ Q_OBJECT
+public:
+ AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent = 0);
+ ~AntennaTrackGadget();
+
+ QWidget *widget() { return m_widget; }
+
+ // void setMode(QString mode); // Either UAVTalk or serial port
+
+ void loadConfiguration(IUAVGadgetConfiguration* config);
+public slots:
+ void onConnect();
+ void onDisconnect();
+
+private slots:
+ void onDataAvailable();
+
+private:
+ QPointer m_widget;
+ QPointer port;
+ QPointer parser;
+ bool connected;
+ void processNewSerialData(QByteArray serialData);
+};
+
+
+#endif // ANTENNATRACKGADGET_H_
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.cpp b/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.cpp
new file mode 100644
index 000000000..1e4a44f05
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.cpp
@@ -0,0 +1,109 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTracgadgetconfiguration.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 "antennatrackgadgetconfiguration.h"
+#include
+
+/**
+ * Loads a saved configuration or defaults if non exist.
+ *
+ */
+AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
+ IUAVGadgetConfiguration(classId, parent),
+ m_connectionMode("Serial"),
+ m_defaultPort("Unknown"),
+ m_defaultSpeed(BAUD4800),
+ m_defaultDataBits(DATA_8),
+ m_defaultFlow(FLOW_OFF),
+ m_defaultParity(PAR_NONE),
+ m_defaultStopBits(STOP_1),
+ m_defaultTimeOut(5000)
+{
+ //if a saved configuration exists load it
+ if(qSettings != 0) {
+ BaudRateType speed;
+ DataBitsType databits;
+ FlowType flow;
+ ParityType parity;
+ StopBitsType stopbits;
+
+ int ispeed = qSettings->value("defaultSpeed").toInt();
+ int idatabits = qSettings->value("defaultDataBits").toInt();
+ int iflow = qSettings->value("defaultFlow").toInt();
+ int iparity = qSettings->value("defaultParity").toInt();
+ int istopbits = qSettings->value("defaultStopBits").toInt();
+ QString port = qSettings->value("defaultPort").toString();
+ QString conMode = qSettings->value("connectionMode").toString();
+
+ 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;
+ }
+
+}
+
+/**
+ * Clones a configuration.
+ *
+ */
+IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone()
+{
+ AntennaTrackGadgetConfiguration *m = new AntennaTrackGadgetConfiguration(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_connectionMode = m_connectionMode;
+ return m;
+}
+
+/**
+ * Saves a configuration.
+ *
+ */
+void AntennaTrackGadgetConfiguration::saveConfig(QSettings* settings) const {
+ settings->setValue("defaultSpeed", m_defaultSpeed);
+ settings->setValue("defaultDataBits", m_defaultDataBits);
+ settings->setValue("defaultFlow", m_defaultFlow);
+ settings->setValue("defaultParity", m_defaultParity);
+ settings->setValue("defaultStopBits", m_defaultStopBits);
+ settings->setValue("defaultPort", m_defaultPort);
+ settings->setValue("connectionMode", m_connectionMode);
+
+}
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.h b/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.h
new file mode 100644
index 000000000..56e11e2cf
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetconfiguration.h
@@ -0,0 +1,78 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTracgadgetconfiguration.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 ANTENNATRACKGADGETCONFIGURATION_H
+#define ANTENNATRACKGADGETCONFIGURATION_H
+
+#include
+#include
+
+using namespace Core;
+
+class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration
+{
+ Q_OBJECT
+ public:
+ explicit AntennaTrackGadgetConfiguration(QString classId, QSettings* qSettings = 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;}
+ void setFlow(FlowType flow) {m_defaultFlow=flow;}
+ void setParity(ParityType parity) {m_defaultParity=parity;}
+ void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
+ void setPort(QString port){m_defaultPort=port;}
+ void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
+
+ //get port configuration functions
+ QString port(){return m_defaultPort;}
+ BaudRateType speed() {return m_defaultSpeed;}
+ FlowType flow() {return m_defaultFlow;}
+ DataBitsType dataBits() {return m_defaultDataBits;}
+ StopBitsType stopBits() {return m_defaultStopBits;}
+ ParityType parity() {return m_defaultParity;}
+ long timeOut(){return m_defaultTimeOut;}
+
+ void saveConfig(QSettings* settings) const;
+ IUAVGadgetConfiguration *clone();
+
+ private:
+ QString m_connectionMode;
+ QString m_defaultPort;
+ BaudRateType m_defaultSpeed;
+ DataBitsType m_defaultDataBits;
+ FlowType m_defaultFlow;
+ ParityType m_defaultParity;
+ StopBitsType m_defaultStopBits;
+ long m_defaultTimeOut;
+
+};
+
+#endif // ANTENNATRACKGADGETCONFIGURATION_H
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetfactory.cpp b/ground/src/plugins/antennatrack/antennatrackgadgetfactory.cpp
new file mode 100644
index 000000000..ca8c099bb
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetfactory.cpp
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTracgadgetfactory.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 "antennatrackgadgetfactory.h"
+#include "antennatrackwidget.h"
+#include "antennatrackgadget.h"
+#include "antennatrackgadgetconfiguration.h"
+#include "antennatrackgadgetoptionspage.h"
+#include
+
+AntennaTrackGadgetFactory::AntennaTrackGadgetFactory(QObject *parent) :
+ IUAVGadgetFactory(QString("AntennaTrackGadget"),
+ tr("Antenna Track Gadget"),
+ parent)
+{
+}
+
+AntennaTrackGadgetFactory::~AntennaTrackGadgetFactory()
+{
+}
+
+Core::IUAVGadget* AntennaTrackGadgetFactory::createGadget(QWidget *parent)
+{
+ AntennaTrackWidget* gadgetWidget = new AntennaTrackWidget(parent);
+ return new AntennaTrackGadget(QString("AntennaTrackGadget"), gadgetWidget, parent);
+}
+
+IUAVGadgetConfiguration *AntennaTrackGadgetFactory::createConfiguration(QSettings* qSettings)
+{
+ return new AntennaTrackGadgetConfiguration(QString("AntennaTrackGadget"), qSettings);
+}
+
+IOptionsPage *AntennaTrackGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
+{
+ return new AntennaTrackGadgetOptionsPage(qobject_cast(config));
+}
+
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetfactory.h b/ground/src/plugins/antennatrack/antennatrackgadgetfactory.h
new file mode 100644
index 000000000..4a0ca9c9c
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetfactory.h
@@ -0,0 +1,52 @@
+/**
+ ******************************************************************************
+ *
+ * @file antennatracgadgetfactory.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 ANTENNATRACKGADGETFACTORY_H_
+#define ANTENNATRACKGADGETFACTORY_H_
+
+#include
+
+namespace Core {
+class IUAVGadget;
+class IUAVGadgetFactory;
+}
+
+using namespace Core;
+
+class AntennaTrackGadgetFactory : public IUAVGadgetFactory
+{
+ Q_OBJECT
+public:
+ AntennaTrackGadgetFactory(QObject *parent = 0);
+ ~AntennaTrackGadgetFactory();
+
+ Core::IUAVGadget *createGadget(QWidget *parent);
+ IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
+ IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
+};
+
+#endif // ANTENNATRACKGADGETFACTORY_H_
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.cpp b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.cpp
new file mode 100644
index 000000000..51b624b96
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.cpp
@@ -0,0 +1,266 @@
+/**
+ ******************************************************************************
+ *
+ * @file AntennaTracgadgetoptionspage.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 "antennatrackgadgetoptionspage.h"
+#include "antennatrackgadgetconfiguration.h"
+#include "ui_antennatrackgadgetoptionspage.h"
+
+#include
+#include
+#include
+
+AntennaTrackGadgetOptionsPage::AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent) :
+ IOptionsPage(parent),
+ m_config(config)
+{
+// Taken from the uploader gadget, since we also can use a serial port for this
+// Gadget
+
+ //the begining of some ugly code
+//diferent OS's have diferent serial port capabilities
+#ifdef Q_OS_WIN
+//load windows port capabilities
+BaudRateTypeString
+ <<"BAUD110"
+ <<"BAUD300"
+ <<"BAUD600"
+ <<"BAUD1200"
+ <<"BAUD2400"
+ <<"BAUD4800"
+ <<"BAUD9600"
+ <<"BAUD14400"
+ <<"BAUD19200"
+ <<"BAUD38400"
+ <<"BAUD56000"
+ <<"BAUD57600"
+ <<"BAUD115200"
+ <<"BAUD128000"
+ <<"BAUD256000";
+DataBitsTypeString
+ <<"DATA_5"
+ <<"DATA_6"
+ <<"DATA_7"
+ <<"DATA_8";
+ParityTypeString
+ <<"PAR_NONE"
+ <<"PAR_ODD"
+ <<"PAR_EVEN"
+ <<"PAR_MARK" //WINDOWS ONLY
+ <<"PAR_SPACE";
+StopBitsTypeString
+ <<"STOP_1"
+ <<"STOP_1_5" //WINDOWS ONLY
+ <<"STOP_2";
+#else
+//load POSIX port capabilities
+BaudRateTypeString
+
+ <<"BAUD50" //POSIX ONLY
+ <<"BAUD75" //POSIX ONLY
+ <<"BAUD110"
+ <<"BAUD134" //POSIX ONLY
+ <<"BAUD150" //POSIX ONLY
+ <<"BAUD200" //POSIX ONLY
+ <<"BAUD300"
+ <<"BAUD600"
+ <<"BAUD1200"
+ <<"BAUD1800" //POSIX ONLY
+ <<"BAUD2400"
+ <<"BAUD4800"
+ <<"BAUD9600"
+ <<"BAUD19200"
+ <<"BAUD38400"
+ <<"BAUD57600"
+ <<"BAUD76800" //POSIX ONLY
+ <<"BAUD115200";
+DataBitsTypeString
+ <<"DATA_5"
+ <<"DATA_6"
+ <<"DATA_7"
+ <<"DATA_8";
+ParityTypeString
+ <<"PAR_NONE"
+ <<"PAR_ODD"
+ <<"PAR_EVEN"
+ <<"PAR_SPACE";
+StopBitsTypeString
+ <<"STOP_1"
+ <<"STOP_2";
+#endif
+//load all OS's capabilities
+BaudRateTypeStringALL
+ <<"BAUD50" //POSIX ONLY
+ <<"BAUD75" //POSIX ONLY
+ <<"BAUD110"
+ <<"BAUD134" //POSIX ONLY
+ <<"BAUD150" //POSIX ONLY
+ <<"BAUD200" //POSIX ONLY
+ <<"BAUD300"
+ <<"BAUD600"
+ <<"BAUD1200"
+ <<"BAUD1800" //POSIX ONLY
+ <<"BAUD2400"
+ <<"BAUD4800"
+ <<"BAUD9600"
+ <<"BAUD14400"
+ <<"BAUD19200"
+ <<"BAUD38400"
+ <<"BAUD56000"
+ <<"BAUD57600"
+ <<"BAUD76800" //POSIX ONLY
+ <<"BAUD115200"
+ <<"BAUD128000"
+ <<"BAUD256000";
+DataBitsTypeStringALL
+ <<"DATA_5"
+ <<"DATA_6"
+ <<"DATA_7"
+ <<"DATA_8";
+ParityTypeStringALL
+ <<"PAR_NONE"
+ <<"PAR_ODD"
+ <<"PAR_EVEN"
+ <<"PAR_MARK" //WINDOWS ONLY
+ <<"PAR_SPACE";
+StopBitsTypeStringALL
+ <<"STOP_1"
+ <<"STOP_1_5" //WINDOWS ONLY
+ <<"STOP_2";
+
+FlowTypeString
+ <<"FLOW_OFF"
+ <<"FLOW_HARDWARE"
+ <<"FLOW_XONXOFF";
+}
+bool sortPorts(QextPortInfo const& s1,QextPortInfo const& s2)
+{
+return s1.portNamesetupUi(optionsPageWidget);
+
+
+ // PORTS
+ QList ports = QextSerialEnumerator::getPorts();
+ qSort(ports.begin(), ports.end(),sortPorts);
+ foreach( QextPortInfo port, ports ) {
+ qDebug() << "Adding port: " << port.friendName << " (" << port.portName << ")";
+ options_page->portComboBox->addItem(port.friendName, port.friendName);
+ }
+
+ int portIndex = options_page->portComboBox->findData(m_config->port());
+ if(portIndex!=-1){
+ qDebug() << "createPage(): port is " << m_config->port();
+ options_page->portComboBox->setCurrentIndex(portIndex);
+ }
+
+ // BAUDRATES
+ options_page->portSpeedComboBox->addItems(BaudRateTypeString);
+
+ int portSpeedIndex = options_page->portSpeedComboBox->findText(BaudRateTypeStringALL.at((int)m_config->speed()));
+ if(portSpeedIndex != -1){
+ options_page->portSpeedComboBox->setCurrentIndex(portSpeedIndex);
+ }
+
+ // FLOW CONTROL
+ options_page->flowControlComboBox->addItems(FlowTypeString);
+
+ int flowControlIndex = options_page->flowControlComboBox->findText(FlowTypeString.at((int)m_config->flow()));
+ if(flowControlIndex != -1){
+ options_page->flowControlComboBox->setCurrentIndex(flowControlIndex);
+ }
+
+ // DATABITS
+ options_page->dataBitsComboBox->addItems(DataBitsTypeString);
+
+ int dataBitsIndex = options_page->dataBitsComboBox->findText(DataBitsTypeStringALL.at((int)m_config->dataBits()));
+ if(dataBitsIndex != -1){
+ options_page->dataBitsComboBox->setCurrentIndex(dataBitsIndex);
+ }
+
+ // STOPBITS
+ options_page->stopBitsComboBox->addItems(StopBitsTypeString);
+
+ int stopBitsIndex = options_page->stopBitsComboBox->findText(StopBitsTypeStringALL.at((int)m_config->stopBits()));
+ if(stopBitsIndex != -1){
+ options_page->stopBitsComboBox->setCurrentIndex(stopBitsIndex);
+ }
+
+ // PARITY
+ options_page->parityComboBox->addItems(ParityTypeString);
+
+ int parityIndex = options_page->parityComboBox->findText(ParityTypeStringALL.at((int)m_config->parity()));
+ if(parityIndex != -1){
+ options_page->parityComboBox->setCurrentIndex(parityIndex);
+ }
+
+ // TIMEOUT
+ options_page->timeoutSpinBox->setValue(m_config->timeOut());
+
+ QStringList connectionModes;
+ connectionModes << "Serial";
+ options_page->connectionMode->addItems(connectionModes);
+ int conMode = options_page->connectionMode->findText(m_config->connectionMode());
+ if (conMode != -1)
+ options_page->connectionMode->setCurrentIndex(conMode);
+
+
+ return optionsPageWidget;
+}
+
+/**
+ * Called when the user presses apply or OK.
+ *
+ * Saves the current values
+ *
+ */
+void AntennaTrackGadgetOptionsPage::apply()
+{
+ int portIndex = options_page->portComboBox->currentIndex();
+ m_config->setPort(options_page->portComboBox->itemData(portIndex).toString());
+ qDebug() << "apply(): port is " << m_config->port();
+
+ m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(options_page->portSpeedComboBox->currentText()));
+ m_config->setFlow((FlowType)FlowTypeString.indexOf(options_page->flowControlComboBox->currentText()));
+ m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(options_page->dataBitsComboBox->currentText()));
+ 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 AntennaTrackGadgetOptionsPage::finish()
+{
+ delete options_page;
+}
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.h b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.h
new file mode 100644
index 000000000..406fee05d
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.h
@@ -0,0 +1,76 @@
+/**
+ ******************************************************************************
+ *
+ * @file antennatrackgadgetoptionspage.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 ANTENNATRACKGADGETOPTIONSPAGE_H
+#define ANTENNATRACKGADGETOPTIONSPAGE_H
+
+#include
+#include "coreplugin/dialogs/ioptionspage.h"
+#include "QString"
+#include
+#include
+
+namespace Core {
+class IUAVGadgetConfiguration;
+}
+
+class AntennaTrackGadgetConfiguration;
+
+namespace Ui {
+ class AntennaTrackGadgetOptionsPage;
+}
+
+using namespace Core;
+
+class AntennaTrackGadgetOptionsPage : public IOptionsPage
+{
+Q_OBJECT
+public:
+ explicit AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent = 0);
+
+ QWidget *createPage(QWidget *parent);
+ void apply();
+ void finish();
+
+private:
+ Ui::AntennaTrackGadgetOptionsPage *options_page;
+ AntennaTrackGadgetConfiguration *m_config;
+
+ QStringList BaudRateTypeString;
+ QStringList BaudRateTypeStringALL;
+ QStringList DataBitsTypeStringALL;
+ QStringList ParityTypeStringALL;
+ QStringList StopBitsTypeStringALL;
+ QStringList DataBitsTypeString;
+ QStringList ParityTypeString;
+ QStringList StopBitsTypeString;
+ QStringList FlowTypeString;
+
+private slots:
+};
+
+#endif // ANTENNATRACKGADGETOPTIONSPAGE_H
diff --git a/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.ui b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.ui
new file mode 100644
index 000000000..34f6f3bc9
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.ui
@@ -0,0 +1,186 @@
+
+
+ AntennaTrackGadgetOptionsPage
+
+
+
+ 0
+ 0
+ 587
+ 359
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+ 0
+
+ -
+
+
+
-
+
+
-
+
+
+ Mode:
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ 0
+
+
+
+
+ 0
+
+
-
+
+
+ Serial Connection
+
+
+
+ -
+
+
-
+
+
+ -
+
+
+ -
+
+
+ Data Bits:
+
+
+
+ -
+
+
+ Stop Bits:
+
+
+
+ -
+
+
+ Parity:
+
+
+
+ -
+
+
+ Timeout(ms):
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ Port:
+
+
+
+ -
+
+
+ Port Speed:
+
+
+
+ -
+
+
+ -
+
+
+ Flow Control:
+
+
+
+ -
+
+
+ 100000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ connectionMode
+ currentIndexChanged(int)
+ stackedWidget
+ setCurrentIndex(int)
+
+
+ 77
+ 16
+
+
+ 293
+ 194
+
+
+
+
+
diff --git a/ground/src/plugins/antennatrack/antennatrackplugin.cpp b/ground/src/plugins/antennatrack/antennatrackplugin.cpp
new file mode 100644
index 000000000..bf1aa1187
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackplugin.cpp
@@ -0,0 +1,34 @@
+#include "antennatrackplugin.h"
+#include "antennatrackgadgetfactory.h"
+#include
+#include
+#include
+#include
+
+AntennaTrackPlugin::AntennaTrackPlugin() {
+ // Do nothing
+ }
+
+AntennaTrackPlugin::~AntennaTrackPlugin() {
+ // Do nothing
+}
+
+bool AntennaTrackPlugin::initialize(const QStringList& args, QString *errMsg) {
+ Q_UNUSED(args);
+ Q_UNUSED(errMsg);
+
+ mf = new AntennaTrackGadgetFactory(this);
+ addAutoReleasedObject(mf);
+
+ return true;
+}
+
+void AntennaTrackPlugin::extensionsInitialized() {
+ // Do nothing
+}
+
+void AntennaTrackPlugin::shutdown() {
+ // Do nothing
+}
+
+Q_EXPORT_PLUGIN(AntennaTrackPlugin)
diff --git a/ground/src/plugins/antennatrack/antennatrackplugin.h b/ground/src/plugins/antennatrack/antennatrackplugin.h
new file mode 100644
index 000000000..295f0e61e
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackplugin.h
@@ -0,0 +1,21 @@
+#ifndef ANTENNATRACKPLUGIN_H
+#define ANTENNATRACKPLUGIN_H
+
+#include
+
+class AntennaTrackGadgetFactory;
+
+class AntennaTrackPlugin : public ExtensionSystem::IPlugin
+{
+public:
+ AntennaTrackPlugin();
+ ~AntennaTrackPlugin();
+
+ void extensionsInitialized();
+ bool initialize(const QStringList & arguments, QString * errorString);
+ void shutdown();
+private:
+ AntennaTrackGadgetFactory *mf;
+};
+
+#endif // ANTENNATRACKPLUGIN_H
diff --git a/ground/src/plugins/antennatrack/antennatrackwidget.cpp b/ground/src/plugins/antennatrack/antennatrackwidget.cpp
new file mode 100644
index 000000000..86a2eb4d3
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackwidget.cpp
@@ -0,0 +1,206 @@
+/**
+ ******************************************************************************
+ *
+ * @file Antennatrackwidget.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 "antennatrackwidget.h"
+#include "extensionsystem/pluginmanager.h"
+#include "uavobjects/uavobjectmanager.h"
+
+
+#include
+#include
+#include
+
+/*
+ * Initialize the widget
+ */
+AntennaTrackWidget::AntennaTrackWidget(QWidget *parent) : QWidget(parent)
+{
+ setupUi(this);
+
+ azimuth_old=0;
+ elevation_old=0;
+}
+
+AntennaTrackWidget::~AntennaTrackWidget()
+{
+}
+void AntennaTrackWidget::setPort(QPointer portx)
+{
+ port=portx;
+}
+
+void AntennaTrackWidget::dumpPacket(const QString &packet)
+{
+ textBrowser->append(packet);
+ if(textBrowser->document()->lineCount() > 200) {
+ QTextCursor tc = textBrowser->textCursor();
+ tc.movePosition(QTextCursor::Start);
+ tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
+ tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
+ tc.removeSelectedText();
+ }
+}
+
+void AntennaTrackWidget::setPosition(double lat, double lon, double alt)
+{
+ //lat *= 1E-7;
+ //lon *= 1E-7;
+ double deg = floor(fabs(lat));
+ double min = (fabs(lat)-deg)*60;
+ QString str1;
+ str1.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
+ if (lat>0)
+ str1.append("N");
+ else
+ str1.append("S");
+ coord_value->setText(str1);
+ deg = floor(fabs(lon));
+ min = (fabs(lon)-deg)*60;
+ QString str2;
+ str2.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
+ if (lon>0)
+ str2.append("E");
+ else
+ str2.append("W");
+ coord_value_2->setText(str2);
+ QString str3;
+ str3.sprintf("%.2f m", alt);
+ coord_value_3->setText(str3);
+ TrackData.Latitude=lat;
+ TrackData.Longitude=lon;
+ TrackData.Altitude=alt;
+ calcAntennaPosition();
+}
+
+void AntennaTrackWidget::setHomePosition(double lat, double lon, double alt)
+{
+ //lat *= 1E-7;
+ //lon *= 1E-7;
+ double deg = floor(fabs(lat));
+ double min = (fabs(lat)-deg)*60;
+ QString str1;
+ str1.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
+ if (lat>0)
+ str1.append("N");
+ else
+ str1.append("S");
+ speed_value->setText(str1);
+ deg = floor(fabs(lon));
+ min = (fabs(lon)-deg)*60;
+ QString str2;
+ str2.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
+ if (lon>0)
+ str2.append("E");
+ else
+ str2.append("W");
+ bear_label->setText(str2);
+ QString str3;
+ str3.sprintf("%.2f m", alt);
+ bear_value->setText(str3);
+ TrackData.HomeLatitude=lat;
+ TrackData.HomeLongitude=lon;
+ TrackData.HomeAltitude=alt;
+ calcAntennaPosition();
+}
+
+void AntennaTrackWidget::calcAntennaPosition(void)
+{
+ /** http://www.movable-type.co.uk/scripts/latlong.html **/
+ double lat1, lat2, lon1, lon2, a, c, d, x, y, brng;
+ double azimuth, elevation;
+ double gcsAlt=TrackData.HomeAltitude; // Home MSL altitude
+ double uavAlt=TrackData.Altitude; // UAV MSL altitude
+ double dAlt=uavAlt-gcsAlt; // Altitude difference
+
+ // Convert to radians
+ lat1 = TrackData.HomeLatitude*(M_PI/180); // Home lat
+ lon1 = TrackData.HomeLongitude*(M_PI/180); // Home lon
+ lat2 = TrackData.Latitude*(M_PI/180); // UAV lat
+ lon2 = TrackData.Longitude*(M_PI/180); // UAV lon
+
+ // Bearing
+ /**
+ var y = Math.sin(dLon) * Math.cos(lat2);
+ var x = Math.cos(lat1)*Math.sin(lat2) -
+ Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
+ var brng = Math.atan2(y, x).toDeg();
+ **/
+ y = sin(lon2-lon1) * cos(lat2);
+ x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon2-lon1);
+ brng = atan2((sin(lon2-lon1)*cos(lat2)),(cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1)))*(180/M_PI);
+ if(brng<0)
+ brng+=360;
+
+ // bearing to stepper
+ azimuth = brng;
+
+ // Haversine formula for distance
+ /**
+ var R = 6371; // km
+ var dLat = (lat2-lat1).toRad();
+ var dLon = (lon2-lon1).toRad();
+ var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
+ Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
+ Math.sin(dLon/2) * Math.sin(dLon/2);
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+ var d = R * c;
+ **/
+ a = sin((lat2-lat1)/2) * sin((lat2-lat1)/2) +
+ cos(lat1) * cos(lat2) *
+ sin((lon2-lon1)/2) * sin((lon2-lon1)/2);
+ c = 2 * atan2(sqrt(a), sqrt(1-a));
+ d = 6371 * 1000 * c;
+
+ // Elevation v depends servo direction
+ if(d!=0)
+ elevation = 90-(atan(dAlt/d)*(180/M_PI));
+ else
+ elevation = 0;
+ //! TODO: sanity check
+
+ QString str3;
+ str3.sprintf("%.0f deg", azimuth);
+ azimuth_value->setText(str3);
+
+ str3.sprintf("%.0f deg", elevation);
+ elevation_value->setText(str3);
+
+ //servo value 2000-4000
+ int servo = (int)(2000.0/180*elevation+2000);
+ int stepper = (int)(400.0/360*(azimuth-azimuth_old));
+
+ // send azimuth and elevation to tracker hardware
+ str3.sprintf("move %d 2000 2000 2000 %d\r", stepper,servo);
+ if(port->isOpen())
+ {
+ if(azimuth_old!=azimuth || elevation!=elevation_old)
+ port->write(str3.toAscii());
+ azimuth_old = azimuth;
+ elevation_old = elevation;
+ }
+
+}
diff --git a/ground/src/plugins/antennatrack/antennatrackwidget.h b/ground/src/plugins/antennatrack/antennatrackwidget.h
new file mode 100644
index 000000000..c5c380084
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackwidget.h
@@ -0,0 +1,75 @@
+/**
+ ******************************************************************************
+ *
+ * @file antennatrackwidget.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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 ANTENNATRACKWIDGET_H_
+#define ANTENNATRACKWIDGET_H_
+
+#include "ui_antennatrackwidget.h"
+#include "antennatrackgadgetconfiguration.h"
+#include "uavobjects/uavobject.h"
+#include
+#include
+#include
+#include
+#include
+
+class Ui_AntennaTrackWidget;
+
+typedef struct struct_TrackData
+{
+ double Latitude;
+ double Longitude;
+ double Altitude;
+ double HomeLatitude;
+ double HomeLongitude;
+ double HomeAltitude;
+
+}TrackData_t;
+
+class AntennaTrackWidget : public QWidget, public Ui_AntennaTrackWidget
+{
+ Q_OBJECT
+
+public:
+ AntennaTrackWidget(QWidget *parent = 0);
+ ~AntennaTrackWidget();
+ TrackData_t TrackData;
+ void setPort(QPointer portx);
+
+private slots:
+ void setPosition(double, double, double);
+ void setHomePosition(double, double, double);
+ void dumpPacket(const QString &packet);
+
+private:
+ void calcAntennaPosition(void);
+ QGraphicsSvgItem * marker;
+ QPointer port;
+ double azimuth_old;
+ double elevation_old;
+};
+#endif /* ANTENNATRACKWIDGET_H_ */
diff --git a/ground/src/plugins/antennatrack/antennatrackwidget.ui b/ground/src/plugins/antennatrack/antennatrackwidget.ui
new file mode 100644
index 000000000..8ffd42f0f
--- /dev/null
+++ b/ground/src/plugins/antennatrack/antennatrackwidget.ui
@@ -0,0 +1,479 @@
+
+
+ AntennaTrackWidget
+
+
+
+ 0
+ 0
+ 560
+ 376
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+
+
+ 6
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Vertical
+
+
+ true
+
+
+
+
-
+
+
+ 0
+
+
-
+
+
+ 0
+
+
-
+
+
+ true
+
+
+ Coord:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Preferred
+
+
+
+ 20
+ 6
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ HomeCoord:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+ false
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Preferred
+
+
+
+ 20
+ 4
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Preferred
+
+
+
+ 20
+ 4
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ Azimuth
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Preferred
+
+
+
+ 20
+ 6
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ Elevation
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 6
+ 0
+
+
+
+
+ -
+
+
+ Unknown
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Ignored
+
+
+
+ 20
+ 6
+
+
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Preferred
+
+
+
+ 9
+ 20
+
+
+
+
+ -
+
+
-
+
+
+ Connect
+
+
+
+ -
+
+
+ Disconnect
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 20
+
+
+
+
+
+
+
+
+
+
+ Output
+
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 50
+
+
+
+ Qt::ScrollBarAlwaysOn
+
+
+ QTextEdit::WidgetWidth
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ground/src/plugins/antennatrack/gpsparser.cpp b/ground/src/plugins/antennatrack/gpsparser.cpp
new file mode 100644
index 000000000..feb33b3b6
--- /dev/null
+++ b/ground/src/plugins/antennatrack/gpsparser.cpp
@@ -0,0 +1,43 @@
+/**
+ ******************************************************************************
+ *
+ * @file gpsparser.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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"
+
+GPSParser::GPSParser(QObject *parent) : QObject(parent)
+{
+ qRegisterMetaType >("QList");
+}
+
+GPSParser::~GPSParser()
+{
+
+}
+
+void GPSParser::processInputStream(char c) {
+{
+ Q_UNUSED(c)}
+}
diff --git a/ground/src/plugins/antennatrack/gpsparser.h b/ground/src/plugins/antennatrack/gpsparser.h
new file mode 100644
index 000000000..3dd319c64
--- /dev/null
+++ b/ground/src/plugins/antennatrack/gpsparser.h
@@ -0,0 +1,59 @@
+/**
+ ******************************************************************************
+ *
+ * @file gpsparser.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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
+#include
+#include
+
+class GPSParser: public QObject
+{
+ Q_OBJECT
+public:
+ ~GPSParser();
+ virtual void processInputStream(char c);
+
+protected:
+ GPSParser(QObject *parent = 0);
+
+signals:
+ void sv(int); // Satellites in view
+ void position(double,double,double); // Lat, Lon, Alt
+ void home(double,double,double); // Lat, Lon, Alt
+ void datetime(double,double); // Date then time
+ void speedheading(double,double);
+ void packet(QString); // Raw NMEA Packet (or just info)
+ void satellite(int,int,int,int,int); // Index, PRN, Elevation, Azimuth, SNR
+ void fixmode(QString); // Mode of fix: "Auto", "Manual".
+ void fixtype(QString); // Type of fix: "NoGPS", "NoFix", "Fix2D", "Fix3D".
+ void dop(double, double, double); // HDOP, VDOP, PDOP
+ void fixSVs(QList); // SV's used for fix.
+};
+
+#endif // GPSPARSER_H
diff --git a/ground/src/plugins/antennatrack/telemetryparser.cpp b/ground/src/plugins/antennatrack/telemetryparser.cpp
new file mode 100644
index 000000000..8ec868ea5
--- /dev/null
+++ b/ground/src/plugins/antennatrack/telemetryparser.cpp
@@ -0,0 +1,81 @@
+/**
+ ******************************************************************************
+ *
+ * @file telemetryparser.cpp
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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
+#include
+#include
+
+
+/**
+ * Initialize the parser
+ */
+TelemetryParser::TelemetryParser(QObject *parent) : GPSParser(parent)
+{
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ UAVObjectManager *objManager = pm->getObject();
+ UAVDataObject *gpsObj = dynamic_cast(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(objManager->getObject("HomeLocation"));
+ if (gpsObj != NULL) {
+ connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateHome(UAVObject*)));
+ } else {
+ qDebug() << "Error: Object is unknown (HomeLocation).";
+ }
+
+}
+
+TelemetryParser::~TelemetryParser()
+{
+
+}
+
+void TelemetryParser::updateHome( UAVObject* object1) {
+ double lat = object1->getField(QString("Latitude"))->getDouble();
+ double lon = object1->getField(QString("Longitude"))->getDouble();
+ double alt = object1->getField(QString("Altitude"))->getDouble();
+ lat *= 1E-7;
+ lon *= 1E-7;
+ emit home(lat,lon,alt);
+}
+
+
+void TelemetryParser::updateGPS( UAVObject* object1) {
+ double lat = object1->getField(QString("Latitude"))->getDouble();
+ double lon = object1->getField(QString("Longitude"))->getDouble();
+ double alt = object1->getField(QString("Altitude"))->getDouble();
+ lat *= 1E-7;
+ lon *= 1E-7;
+ emit position(lat,lon,alt);
+}
+
diff --git a/ground/src/plugins/antennatrack/telemetryparser.h b/ground/src/plugins/antennatrack/telemetryparser.h
new file mode 100644
index 000000000..09108836c
--- /dev/null
+++ b/ground/src/plugins/antennatrack/telemetryparser.h
@@ -0,0 +1,52 @@
+/**
+ ******************************************************************************
+ *
+ * @file telemetryparser.h
+ * @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
+ * @{
+ * @brief A gadget that communicates with antenna tracker 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
+#include
+#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 updateHome(UAVObject* object1);
+};
+
+#endif // TELEMETRYPARSER_H
diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro
index be3c256b2..e28ecc6e0 100644
--- a/ground/src/plugins/plugins.pro
+++ b/ground/src/plugins/plugins.pro
@@ -151,6 +151,12 @@ plugin_gcscontrol.depends += plugin_uavobjects
plugin_gcscontrol.depends += plugin_uavtalk
SUBDIRS += plugin_gcscontrol
+# Antenna tracker
+#plugin_antennatrack.subdir = antennatrack
+#plugin_antennatrack.depends = plugin_coreplugin
+#plugin_antennatrack.depends = plugin_uavtalk
+#SUBDIRS += plugin_antennatrack
+
# Empty UAVGadget - Default for new splits
plugin_magicwaypoint.subdir = magicwaypoint
plugin_magicwaypoint.depends = plugin_coreplugin