From 94ee367d2193c2dd4116b6b9c8a28b6c3bf8b421 Mon Sep 17 00:00:00 2001 From: dgodin Date: Tue, 31 Aug 2010 10:11:32 +0000 Subject: [PATCH] Remove old HITLs, and replace with new HITL plugin git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1479 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/hitl/HITL.pluginspec | 12 - ground/src/plugins/hitl/flightgearbridge.cpp | 311 ------------- ground/src/plugins/hitl/flightgearbridge.h | 98 ----- ground/src/plugins/hitl/hitl.cpp | 49 --- ground/src/plugins/hitl/hitl.h | 56 --- ground/src/plugins/hitl/hitl.pro | 23 - ground/src/plugins/hitl/hitl_dependencies.pri | 4 - ground/src/plugins/hitl/hitlconfiguration.cpp | 67 --- ground/src/plugins/hitl/hitlconfiguration.h | 68 --- ground/src/plugins/hitl/hitlfactory.cpp | 58 --- ground/src/plugins/hitl/hitlfactory.h | 52 --- ground/src/plugins/hitl/hitloptionspage.cpp | 73 ---- ground/src/plugins/hitl/hitloptionspage.h | 65 --- ground/src/plugins/hitl/hitloptionspage.ui | 106 ----- ground/src/plugins/hitl/hitlplugin.cpp | 63 --- ground/src/plugins/hitl/hitlplugin.h | 47 -- ground/src/plugins/hitl/hitlresources.qrc | 5 - ground/src/plugins/hitl/hitlwidget.cpp | 209 --------- ground/src/plugins/hitl/hitlwidget.h | 70 --- ground/src/plugins/hitl/hitlwidget.ui | 210 --------- ground/src/plugins/hitl/opfgprotocol.xml | 201 --------- ground/src/plugins/hitlil2/HITLIL2.pluginspec | 12 - ground/src/plugins/hitlil2/hitlil2.cpp | 51 --- ground/src/plugins/hitlil2/hitlil2.h | 56 --- ground/src/plugins/hitlil2/hitlil2.pro | 22 - .../plugins/hitlil2/hitlil2_dependencies.pri | 4 - .../plugins/hitlil2/hitlil2configuration.cpp | 77 ---- .../plugins/hitlil2/hitlil2configuration.h | 76 ---- ground/src/plugins/hitlil2/hitlil2factory.cpp | 58 --- ground/src/plugins/hitlil2/hitlil2factory.h | 52 --- .../plugins/hitlil2/hitlil2optionspage.cpp | 70 --- .../src/plugins/hitlil2/hitlil2optionspage.h | 65 --- .../src/plugins/hitlil2/hitlil2optionspage.ui | 100 ----- ground/src/plugins/hitlil2/hitlil2plugin.cpp | 63 --- ground/src/plugins/hitlil2/hitlil2plugin.h | 47 -- ground/src/plugins/hitlil2/hitlil2widget.cpp | 161 ------- ground/src/plugins/hitlil2/hitlil2widget.h | 70 --- ground/src/plugins/hitlil2/hitlil2widget.ui | 210 --------- ground/src/plugins/hitlil2/il2bridge.cpp | 412 ------------------ ground/src/plugins/hitlil2/il2bridge.h | 150 ------- 40 files changed, 3603 deletions(-) delete mode 100644 ground/src/plugins/hitl/HITL.pluginspec delete mode 100644 ground/src/plugins/hitl/flightgearbridge.cpp delete mode 100644 ground/src/plugins/hitl/flightgearbridge.h delete mode 100644 ground/src/plugins/hitl/hitl.cpp delete mode 100644 ground/src/plugins/hitl/hitl.h delete mode 100644 ground/src/plugins/hitl/hitl.pro delete mode 100644 ground/src/plugins/hitl/hitl_dependencies.pri delete mode 100644 ground/src/plugins/hitl/hitlconfiguration.cpp delete mode 100644 ground/src/plugins/hitl/hitlconfiguration.h delete mode 100644 ground/src/plugins/hitl/hitlfactory.cpp delete mode 100644 ground/src/plugins/hitl/hitlfactory.h delete mode 100644 ground/src/plugins/hitl/hitloptionspage.cpp delete mode 100644 ground/src/plugins/hitl/hitloptionspage.h delete mode 100644 ground/src/plugins/hitl/hitloptionspage.ui delete mode 100644 ground/src/plugins/hitl/hitlplugin.cpp delete mode 100644 ground/src/plugins/hitl/hitlplugin.h delete mode 100644 ground/src/plugins/hitl/hitlresources.qrc delete mode 100644 ground/src/plugins/hitl/hitlwidget.cpp delete mode 100644 ground/src/plugins/hitl/hitlwidget.h delete mode 100644 ground/src/plugins/hitl/hitlwidget.ui delete mode 100644 ground/src/plugins/hitl/opfgprotocol.xml delete mode 100644 ground/src/plugins/hitlil2/HITLIL2.pluginspec delete mode 100644 ground/src/plugins/hitlil2/hitlil2.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2.pro delete mode 100644 ground/src/plugins/hitlil2/hitlil2_dependencies.pri delete mode 100644 ground/src/plugins/hitlil2/hitlil2configuration.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2configuration.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2factory.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2factory.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2optionspage.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2optionspage.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2optionspage.ui delete mode 100644 ground/src/plugins/hitlil2/hitlil2plugin.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2plugin.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2widget.cpp delete mode 100644 ground/src/plugins/hitlil2/hitlil2widget.h delete mode 100644 ground/src/plugins/hitlil2/hitlil2widget.ui delete mode 100644 ground/src/plugins/hitlil2/il2bridge.cpp delete mode 100644 ground/src/plugins/hitlil2/il2bridge.h diff --git a/ground/src/plugins/hitl/HITL.pluginspec b/ground/src/plugins/hitl/HITL.pluginspec deleted file mode 100644 index 573d8094e..000000000 --- a/ground/src/plugins/hitl/HITL.pluginspec +++ /dev/null @@ -1,12 +0,0 @@ - - The OpenPilot Project - (C) 2010 OpenPilot Project - The GNU Public License (GPL) Version 3 - Hardware In The Loop Simulation - http://www.openpilot.org - - - - - - diff --git a/ground/src/plugins/hitl/flightgearbridge.cpp b/ground/src/plugins/hitl/flightgearbridge.cpp deleted file mode 100644 index 2a0c5ea59..000000000 --- a/ground/src/plugins/hitl/flightgearbridge.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/** - ****************************************************************************** - * - * @file flightgearbridge.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "flightgearbridge.h" -#include "extensionsystem/pluginmanager.h" -#include "coreplugin/icore.h" -#include "coreplugin/threadmanager.h" - -const float FlightGearBridge::FT2M = 0.3048; -const float FlightGearBridge::KT2MPS = 0.514444444; -const float FlightGearBridge::INHG2KPA = 3.386; - -FlightGearBridge::FlightGearBridge() -{ - // move to thread - moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread()); - - connect(this, SIGNAL(myStart()), this, SLOT(onStart()),Qt::QueuedConnection); - emit myStart(); - -} - -void FlightGearBridge::onStart() -{ - - // Init fields - fgHost = QHostAddress("127.0.0.1"); - inPort = 5500; - outPort = 5501; - updatePeriod = 50; - fgTimeout = 2000; - autopilotConnectionStatus = false; - fgConnectionStatus = false; - - // Get required UAVObjects - ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager* objManager = pm->getObject(); - actDesired = ActuatorDesired::GetInstance(objManager); - baroAltitude = BaroAltitude::GetInstance(objManager); - attActual = AttitudeActual::GetInstance(objManager); - posActual = PositionActual::GetInstance(objManager); - telStats = GCSTelemetryStats::GetInstance(objManager); - - // Listen to autopilot connection events - TelemetryManager* telMngr = pm->getObject(); - connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); - connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); - //connect(telStats, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(telStatsUpdated(UAVObject*))); - - // If already connect setup autopilot - GCSTelemetryStats::DataFields stats = telStats->getData(); - if ( stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotConnect(); - } - - // Setup local ports - inSocket = new QUdpSocket(); - outSocket = new QUdpSocket(); - inSocket->bind(QHostAddress::Any, inPort); - connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection); - - // Setup transmit timer - txTimer = new QTimer(); - connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection); - txTimer->setInterval(updatePeriod); - txTimer->start(); - - // Setup FG connection timer - fgTimer = new QTimer(); - connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()),Qt::DirectConnection); - fgTimer->setInterval(fgTimeout); - fgTimer->start(); - -} - -FlightGearBridge::~FlightGearBridge() -{ - delete inSocket; - delete outSocket; - delete txTimer; - delete fgTimer; -} - -bool FlightGearBridge::isAutopilotConnected() -{ - return autopilotConnectionStatus; -} - -bool FlightGearBridge::isFGConnected() -{ - return fgConnectionStatus; -} - -void FlightGearBridge::transmitUpdate() -{ - // Read ActuatorDesired from autopilot - ActuatorDesired::DataFields actData = actDesired->getData(); - float ailerons = actData.Roll; - float elevator = -actData.Pitch; - float rudder = actData.Yaw; - float throttle = actData.Throttle; - - // Send update to FlightGear - QString cmd; - cmd = QString("%1,%2,%3,%4\n") - .arg(ailerons) - .arg(elevator) - .arg(rudder) - .arg(throttle); - QByteArray data = cmd.toAscii(); - outSocket->writeDatagram(data, fgHost, outPort); -} - -void FlightGearBridge::receiveUpdate() -{ - // Update connection timer and status - fgTimer->setInterval(fgTimeout); - fgTimer->stop(); - fgTimer->start(); - if ( !fgConnectionStatus ) - { - fgConnectionStatus = true; - emit fgConnected(); - } - - // Process data - while ( inSocket->bytesAvailable() > 0 ) - { - // Receive datagram - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - QHostAddress sender; - quint16 senderPort; - inSocket->readDatagram(datagram.data(), datagram.size(), - &sender, &senderPort); - QString datastr(datagram); - // Process incomming data - processUpdate(datastr); - } -} - -void FlightGearBridge::setupObjects() -{ - setupInputObject(actDesired, 75); - setupOutputObject(baroAltitude, 250); - setupOutputObject(attActual, 75); - setupOutputObject(posActual, 250); -} - -void FlightGearBridge::setupInputObject(UAVObject* obj, int updatePeriod) -{ - UAVObject::Metadata mdata; - mdata = obj->getDefaultMetadata(); - mdata.flightAccess = UAVObject::ACCESS_READWRITE; - mdata.gcsAccess = UAVObject::ACCESS_READWRITE; - mdata.flightTelemetryAcked = false; - mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; - mdata.flightTelemetryUpdatePeriod = updatePeriod; - mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL; - obj->setMetadata(mdata); -} - -void FlightGearBridge::setupOutputObject(UAVObject* obj, int updatePeriod) -{ - UAVObject::Metadata mdata; - mdata = obj->getDefaultMetadata(); - mdata.flightAccess = UAVObject::ACCESS_READONLY; - mdata.gcsAccess = UAVObject::ACCESS_READWRITE; - mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER; - mdata.gcsTelemetryAcked = false; - mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; - mdata.gcsTelemetryUpdatePeriod = updatePeriod; - obj->setMetadata(mdata); -} - -void FlightGearBridge::onAutopilotConnect() -{ - autopilotConnectionStatus = true; - setupObjects(); - emit autopilotConnected(); -} - -void FlightGearBridge::onAutopilotDisconnect() -{ - autopilotConnectionStatus = false; - emit autopilotDisconnected(); -} - -void FlightGearBridge::onFGConnectionTimeout() -{ - if ( fgConnectionStatus ) - { - fgConnectionStatus = false; - emit fgDisconnected(); - } -} - -void FlightGearBridge::processUpdate(QString& data) -{ - // Split - QStringList fields = data.split(","); - // Get xRate (deg/s) - float xRate = fields[0].toFloat() * 180.0/M_PI; - // Get yRate (deg/s) - float yRate = fields[1].toFloat() * 180.0/M_PI; - // Get zRate (deg/s) - float zRate = fields[2].toFloat() * 180.0/M_PI; - // Get xAccel (m/s^2) - float xAccel = fields[3].toFloat() * FT2M; - // Get yAccel (m/s^2) - float yAccel = fields[4].toFloat() * FT2M; - // Get xAccel (m/s^2) - float zAccel = fields[5].toFloat() * FT2M; - // Get pitch (deg) - float pitch = fields[6].toFloat(); - // Get pitchRate (deg/s) - float pitchRate = fields[7].toFloat(); - // Get roll (deg) - float roll = fields[8].toFloat(); - // Get rollRate (deg/s) - float rollRate = fields[9].toFloat(); - // Get yaw (deg) - float yaw = fields[10].toFloat(); - // Get yawRate (deg/s) - float yawRate = fields[11].toFloat(); - // Get latitude (deg) - float latitude = fields[12].toFloat(); - // Get longitude (deg) - float longitude = fields[13].toFloat(); - // Get heading (deg) - float heading = fields[14].toFloat(); - // Get altitude (m) - float altitude = fields[15].toFloat() * FT2M; - // Get altitudeAGL (m) - float altitudeAGL = fields[16].toFloat() * FT2M; - // Get groundspeed (m/s) - float groundspeed = fields[17].toFloat() * KT2MPS; - // Get airspeed (m/s) - float airspeed = fields[18].toFloat() * KT2MPS; - // Get temperature (degC) - float temperature = fields[19].toFloat(); - // Get pressure (kpa) - float pressure = fields[20].toFloat() * INHG2KPA; - - // Update BaroAltitude object - BaroAltitude::DataFields baroAltitudeData; - baroAltitudeData.Altitude = altitudeAGL; - baroAltitudeData.Temperature = temperature; - baroAltitudeData.Pressure = pressure; - baroAltitude->setData(baroAltitudeData); - - // Update attActual object - AttitudeActual::DataFields attActualData; - attActualData.Roll = roll; - attActualData.Pitch = pitch; - attActualData.Yaw = yaw; - attActualData.q1 = 0; - attActualData.q2 = 0; - attActualData.q3 = 0; - attActualData.q4 = 0; - attActual->setData(attActualData); - - // Update gps objects - PositionActual::DataFields gpsData; - gpsData.Altitude = altitude; - gpsData.Heading = heading; - gpsData.Groundspeed = groundspeed; - gpsData.Latitude = latitude; - gpsData.Longitude = longitude; - gpsData.Satellites = 10; - gpsData.Status = PositionActual::STATUS_FIX3D; - posActual->setData(gpsData); -} - -void FlightGearBridge::telStatsUpdated(UAVObject* obj) -{ - GCSTelemetryStats::DataFields stats = telStats->getData(); - if ( !autopilotConnectionStatus && stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotConnect(); - } - else if ( autopilotConnectionStatus && stats.Status != GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotDisconnect(); - } -} diff --git a/ground/src/plugins/hitl/flightgearbridge.h b/ground/src/plugins/hitl/flightgearbridge.h deleted file mode 100644 index f54cf9e67..000000000 --- a/ground/src/plugins/hitl/flightgearbridge.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - ****************************************************************************** - * - * @file flightgearbridge.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 FLIGHTGEARBRIDGE_H -#define FLIGHTGEARBRIDGE_H - -#include -#include -#include -#include -#include "uavtalk/telemetrymanager.h" -#include "uavobjects/uavobjectmanager.h" -#include "uavobjects/actuatordesired.h" -#include "uavobjects/baroaltitude.h" -#include "uavobjects/attitudeactual.h" -#include "uavobjects/positionactual.h" -#include "uavobjects/gcstelemetrystats.h" - -class FlightGearBridge: public QObject -{ - Q_OBJECT - -public: - FlightGearBridge(); - ~FlightGearBridge(); - - bool isAutopilotConnected(); - bool isFGConnected(); - -signals: - void myStart(); - void autopilotConnected(); - void autopilotDisconnected(); - void fgConnected(); - void fgDisconnected(); - -private slots: - void onStart(); - void transmitUpdate(); - void receiveUpdate(); - void onAutopilotConnect(); - void onAutopilotDisconnect(); - void onFGConnectionTimeout(); - void telStatsUpdated(UAVObject* obj); - -private: - static const float FT2M; - static const float KT2MPS; - static const float INHG2KPA; - - QUdpSocket* inSocket; - QUdpSocket* outSocket; - ActuatorDesired* actDesired; - BaroAltitude* baroAltitude; - AttitudeActual* attActual; - PositionActual* posActual; - GCSTelemetryStats* telStats; - QHostAddress fgHost; - int inPort; - int outPort; - int updatePeriod; - QTimer* txTimer; - QTimer* fgTimer; - bool autopilotConnectionStatus; - bool fgConnectionStatus; - int fgTimeout; - - void processUpdate(QString& data); - void setupOutputObject(UAVObject* obj, int updatePeriod); - void setupInputObject(UAVObject* obj, int updatePeriod); - void setupObjects(); -}; - -#endif // FLIGHTGEARBRIDGE_H diff --git a/ground/src/plugins/hitl/hitl.cpp b/ground/src/plugins/hitl/hitl.cpp deleted file mode 100644 index b33555db9..000000000 --- a/ground/src/plugins/hitl/hitl.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitl.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitl.h" -#include "hitlwidget.h" -#include "hitlconfiguration.h" - -HITL::HITL(QString classId, HITLWidget *widget, QWidget *parent) : - IUAVGadget(classId, parent), - m_widget(widget) -{ -} - -HITL::~HITL() -{ - -} - -void HITL::loadConfiguration(IUAVGadgetConfiguration* config) -{ - HITLConfiguration *m = qobject_cast(config); - m_widget->setFGPathBin( m->fgPathBin() ); - m_widget->setFGPathData( m->fgPathData() ); - m_widget->setFGManualControl( m->fgManualControl() ); -} - diff --git a/ground/src/plugins/hitl/hitl.h b/ground/src/plugins/hitl/hitl.h deleted file mode 100644 index c6210f98e..000000000 --- a/ground/src/plugins/hitl/hitl.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitl.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITL_H -#define HITL_H - -#include -#include "hitlwidget.h" - -class IUAVGadget; -class QWidget; -class QString; -class HITLWidget; - -using namespace Core; - -class HITL : public Core::IUAVGadget -{ - Q_OBJECT -public: - HITL(QString classId, HITLWidget *widget, QWidget *parent = 0); - ~HITL(); - - QWidget *widget() { return m_widget; } - void loadConfiguration(IUAVGadgetConfiguration* config); - -private: - HITLWidget *m_widget; -}; - - -#endif // HITL_H diff --git a/ground/src/plugins/hitl/hitl.pro b/ground/src/plugins/hitl/hitl.pro deleted file mode 100644 index a68691895..000000000 --- a/ground/src/plugins/hitl/hitl.pro +++ /dev/null @@ -1,23 +0,0 @@ -TEMPLATE = lib -TARGET = HITL -QT += network -include(../../openpilotgcsplugin.pri) -include(hitl_dependencies.pri) -HEADERS += hitlplugin.h \ - hitlwidget.h \ - hitloptionspage.h \ - hitlfactory.h \ - hitlconfiguration.h \ - hitl.h \ - flightgearbridge.h -SOURCES += hitlplugin.cpp \ - hitlwidget.cpp \ - hitloptionspage.cpp \ - hitlfactory.cpp \ - hitlconfiguration.cpp \ - hitl.cpp \ - flightgearbridge.cpp -OTHER_FILES += HITL.pluginspec -FORMS += hitloptionspage.ui \ - hitlwidget.ui -RESOURCES += hitlresources.qrc diff --git a/ground/src/plugins/hitl/hitl_dependencies.pri b/ground/src/plugins/hitl/hitl_dependencies.pri deleted file mode 100644 index 303773902..000000000 --- a/ground/src/plugins/hitl/hitl_dependencies.pri +++ /dev/null @@ -1,4 +0,0 @@ -include(../../plugins/uavobjects/uavobjects.pri) -include(../../plugins/uavtalk/uavtalk.pri) -include(../../plugins/coreplugin/coreplugin.pri) -include(../../libs/utils/utils.pri) diff --git a/ground/src/plugins/hitl/hitlconfiguration.cpp b/ground/src/plugins/hitl/hitlconfiguration.cpp deleted file mode 100644 index a97c1e84d..000000000 --- a/ground/src/plugins/hitl/hitlconfiguration.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlconfiguration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitlconfiguration.h" -#include - -HITLConfiguration::HITLConfiguration(QString classId, const QByteArray &state, QObject *parent) : - IUAVGadgetConfiguration(classId, parent), - m_fgPathBin(""), m_fgPathData(""), m_fgManualControl(false) -{ - if (state.count() > 0) { - QDataStream stream(state); - QString fgPathBin; - QString fgPathData; - bool fgManualControl; - stream >> fgPathBin; - m_fgPathBin = fgPathBin; - stream >> fgPathData; - m_fgPathData = fgPathData; - stream >> fgManualControl; - m_fgManualControl = fgManualControl; - } -} - -IUAVGadgetConfiguration *HITLConfiguration::clone() -{ - HITLConfiguration *m = new HITLConfiguration(this->classId()); - m->m_fgPathBin = m_fgPathBin; - m->m_fgPathData = m_fgPathData; - m->m_fgManualControl = m_fgManualControl; - return m; -} - -QByteArray HITLConfiguration::saveState() const -{ - QByteArray bytes; - QDataStream stream(&bytes, QIODevice::WriteOnly); - stream << m_fgPathBin; - stream << m_fgPathData; - stream << m_fgManualControl; - return bytes; -} - diff --git a/ground/src/plugins/hitl/hitlconfiguration.h b/ground/src/plugins/hitl/hitlconfiguration.h deleted file mode 100644 index b024dd022..000000000 --- a/ground/src/plugins/hitl/hitlconfiguration.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlconfiguration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITLCONFIGURATION_H -#define HITLCONFIGURATION_H - -#include -#include -#include - -using namespace Core; - -class HITLConfiguration : public IUAVGadgetConfiguration -{ - -Q_OBJECT -Q_PROPERTY(QString m_fgPathBin READ fgPathBin WRITE setFGPathBin) -Q_PROPERTY(QString m_fgPathData READ fgPathData WRITE setFGPathData) -Q_PROPERTY(bool m_fgManualControl READ fgManualControl WRITE setFGManualControl) - -public: - explicit HITLConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); - QByteArray saveState() const; - IUAVGadgetConfiguration *clone(); - - QString fgPathBin() const { return m_fgPathBin; } - QString fgPathData() const { return m_fgPathData; } - bool fgManualControl() const { return m_fgManualControl; } - -signals: - -public slots: - void setFGPathBin(QString fgPath) { m_fgPathBin = fgPath; } - void setFGPathData(QString fgPath) { m_fgPathData = fgPath; } - void setFGManualControl(bool val) { m_fgManualControl = val; } - -private: - QString m_fgPathBin; - QString m_fgPathData; - bool m_fgManualControl; - -}; - -#endif // HITLCONFIGURATION_H diff --git a/ground/src/plugins/hitl/hitlfactory.cpp b/ground/src/plugins/hitl/hitlfactory.cpp deleted file mode 100644 index 12ed33ed2..000000000 --- a/ground/src/plugins/hitl/hitlfactory.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlfactory.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitlfactory.h" -#include "hitlwidget.h" -#include "hitl.h" -#include "hitlconfiguration.h" -#include "hitloptionspage.h" -#include - -HITLFactory::HITLFactory(QObject *parent) : - IUAVGadgetFactory(QString("HITL"), tr("HITL Simulation"), parent) -{ -} - -HITLFactory::~HITLFactory() -{ -} - -Core::IUAVGadget* HITLFactory::createGadget(QWidget *parent) -{ - HITLWidget* gadgetWidget = new HITLWidget(parent); - return new HITL(QString("HITL"), gadgetWidget, parent); -} - -IUAVGadgetConfiguration *HITLFactory::createConfiguration(const QByteArray &state) -{ - return new HITLConfiguration(QString("HITL"), state); -} - -IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config) -{ - return new HITLOptionsPage(qobject_cast(config)); -} - diff --git a/ground/src/plugins/hitl/hitlfactory.h b/ground/src/plugins/hitl/hitlfactory.h deleted file mode 100644 index 2b7ba780e..000000000 --- a/ground/src/plugins/hitl/hitlfactory.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlfactory.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITLFACTORY_H -#define HITLFACTORY_H - -#include - -namespace Core { -class IUAVGadget; -class IUAVGadgetFactory; -} - -using namespace Core; - -class HITLFactory : public Core::IUAVGadgetFactory -{ - Q_OBJECT -public: - HITLFactory(QObject *parent = 0); - ~HITLFactory(); - - Core::IUAVGadget *createGadget(QWidget *parent); - IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); - IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); -}; - -#endif // HITLFACTORY_H diff --git a/ground/src/plugins/hitl/hitloptionspage.cpp b/ground/src/plugins/hitl/hitloptionspage.cpp deleted file mode 100644 index f63db9889..000000000 --- a/ground/src/plugins/hitl/hitloptionspage.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitloptionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitloptionspage.h" -#include "hitlconfiguration.h" -#include "ui_hitloptionspage.h" - -#include -#include -#include - -HITLOptionsPage::HITLOptionsPage(HITLConfiguration *config, QObject *parent) : - IOptionsPage(parent), - m_config(config) -{ -} - -QWidget *HITLOptionsPage::createPage(QWidget *parent) -{ - // Create page - m_optionsPage = new Ui::HITLOptionsPage(); - QWidget* optionsPageWidget = new QWidget; - m_optionsPage->setupUi(optionsPageWidget); - - m_optionsPage->executablePathChooser->setExpectedKind(Utils::PathChooser::File); - m_optionsPage->executablePathChooser->setPromptDialogTitle(tr("Choose FlightGear executable")); - m_optionsPage->dataDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory); - m_optionsPage->dataDirectoryPathChooser->setPromptDialogTitle(tr("Choose FlightGear data directory")); - - // Restore the contents from the settings: - m_optionsPage->executablePathChooser->setPath(m_config->fgPathBin()); - m_optionsPage->dataDirectoryPathChooser->setPath(m_config->fgPathData()); - m_optionsPage->fgManualControl->setChecked(m_config->fgManualControl()); - - - return optionsPageWidget; -} - -void HITLOptionsPage::apply() -{ - m_config->setFGPathBin( m_optionsPage->executablePathChooser->path()); - m_config->setFGPathData( m_optionsPage->dataDirectoryPathChooser->path()); - m_config->setFGManualControl( m_optionsPage->fgManualControl->isChecked()); -} - -void HITLOptionsPage::finish() -{ - delete m_optionsPage; -} diff --git a/ground/src/plugins/hitl/hitloptionspage.h b/ground/src/plugins/hitl/hitloptionspage.h deleted file mode 100644 index a4ab2bb27..000000000 --- a/ground/src/plugins/hitl/hitloptionspage.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitloptionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITLOPTIONSPAGE_H -#define HITLOPTIONSPAGE_H - -#include "coreplugin/dialogs/ioptionspage.h" - -namespace Core { -class IUAVGadgetConfiguration; -} - -class HITLConfiguration; - -using namespace Core; - -namespace Ui { - class HITLOptionsPage; -} - -class HITLOptionsPage : public IOptionsPage -{ -Q_OBJECT -public: - explicit HITLOptionsPage(HITLConfiguration *config, QObject *parent = 0); - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -signals: - -private slots: - -private: - HITLConfiguration* m_config; - Ui::HITLOptionsPage* m_optionsPage; - -}; - -#endif // HITLOPTIONSPAGE_H diff --git a/ground/src/plugins/hitl/hitloptionspage.ui b/ground/src/plugins/hitl/hitloptionspage.ui deleted file mode 100644 index 52382e435..000000000 --- a/ground/src/plugins/hitl/hitloptionspage.ui +++ /dev/null @@ -1,106 +0,0 @@ - - - HITLOptionsPage - - - - 0 - 0 - 400 - 320 - - - - - 0 - 0 - - - - Form - - - - 0 - - - - - - 0 - 0 - - - - FlightGear executable: - - - - - - - - 0 - 0 - - - - FlightGear data directory: - - - - - - - - 1 - 0 - - - - - - - - - - - - 0 - 0 - - - - Manual aircraft control (can be used when hardware is not available) - - - Manual aircraft control (can be used when hardware is not available) - - - - - - - Qt::Vertical - - - - 20 - 182 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 -
-
- - -
diff --git a/ground/src/plugins/hitl/hitlplugin.cpp b/ground/src/plugins/hitl/hitlplugin.cpp deleted file mode 100644 index cd144c7e0..000000000 --- a/ground/src/plugins/hitl/hitlplugin.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/** - ****************************************************************************** - * - * @file mapplugin.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitlplugin.h" -#include "hitlfactory.h" -#include -#include -#include - -HITLPlugin::HITLPlugin() -{ - // Do nothing -} - -HITLPlugin::~HITLPlugin() -{ - // Do nothing -} - -bool HITLPlugin::initialize(const QStringList& args, QString *errMsg) -{ - Q_UNUSED(args); - Q_UNUSED(errMsg); - mf = new HITLFactory(this); - addAutoReleasedObject(mf); - - return true; -} - -void HITLPlugin::extensionsInitialized() -{ - // Do nothing -} - -void HITLPlugin::shutdown() -{ - // Do nothing -} -Q_EXPORT_PLUGIN(HITLPlugin) - diff --git a/ground/src/plugins/hitl/hitlplugin.h b/ground/src/plugins/hitl/hitlplugin.h deleted file mode 100644 index 4fcafb677..000000000 --- a/ground/src/plugins/hitl/hitlplugin.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - ****************************************************************************** - * - * @file browserplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITLPLUGIN_H -#define HITLPLUGIN_H - -#include - -class HITLFactory; - -class HITLPlugin : public ExtensionSystem::IPlugin -{ -public: - HITLPlugin(); - ~HITLPlugin(); - - void extensionsInitialized(); - bool initialize(const QStringList & arguments, QString * errorString); - void shutdown(); -private: - HITLFactory *mf; -}; -#endif /* HITLPLUGIN_H */ diff --git a/ground/src/plugins/hitl/hitlresources.qrc b/ground/src/plugins/hitl/hitlresources.qrc deleted file mode 100644 index 756c0d8ce..000000000 --- a/ground/src/plugins/hitl/hitlresources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - opfgprotocol.xml - - diff --git a/ground/src/plugins/hitl/hitlwidget.cpp b/ground/src/plugins/hitl/hitlwidget.cpp deleted file mode 100644 index 56c8d4d8b..000000000 --- a/ground/src/plugins/hitl/hitlwidget.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlwidget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 "hitlwidget.h" -#include "ui_hitlwidget.h" -#include "qxtlogger.h" -#include -#include "uavobjects/uavobjectmanager.h" -#include -#include - -HITLWidget::HITLWidget(QWidget *parent) : QWidget(parent) -{ - // Note: Only tested on windows 7 -#if defined(Q_WS_WIN) - cmdShell = QString("c:/windows/system32/cmd.exe"); -#else - cmdShell = QString("bash"); -#endif - fgProcess = NULL; - widget = new Ui_HITLWidget(); - widget->setupUi(this); - connect(widget->startButton, SIGNAL(clicked()), this, SLOT(startButtonClicked())); - connect(widget->stopButton, SIGNAL(clicked()), this, SLOT(stopButtonClicked())); -} - -HITLWidget::~HITLWidget() -{ - delete widget; -} - -void HITLWidget::startButtonClicked() -{ - // Stop running process if one is active - if (fgProcess != NULL) - { - stopButtonClicked(); - } - - // Copy FlightGear generic protocol configuration file to the FG protocol directory - // NOTE: Not working on Windows 7, if FG is installed in the "Program Files", - // likelly due to permissions. The file should be manually copied to data/Protocol/opfgprotocol.xml - QFile xmlFile(":/flightgear/genericprotocol/opfgprotocol.xml"); - xmlFile.open(QIODevice::ReadOnly | QIODevice::Text); - QString xml = xmlFile.readAll(); - xmlFile.close(); - QFile xmlFileOut(fgPathData + "/Protocol/opfgprotocol.xml"); - xmlFileOut.open(QIODevice::WriteOnly | QIODevice::Text); - xmlFileOut.write(xml.toAscii()); - xmlFileOut.close(); - - // Setup process - widget->textBrowser->append(QString("Starting FlightGear ...\n")); - qxtLog->info("HITL: Starting FlightGear"); - fgProcess = new QProcess(); - fgProcess->setReadChannelMode(QProcess::MergedChannels); - connect(fgProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyRead())); - - // Start shell (Note: Could not start FG directly on Windows, only through terminal!) - fgProcess->start(cmdShell); - if (fgProcess->waitForStarted() == false) - { - widget->textBrowser->append("Error:" + fgProcess->errorString()); - } - - // Setup arguments - // Note: The input generic protocol is set to update at a much higher rate than the actual updates are sent by the GCS. - // If this is not done then a lag will be introduced by FlightGear, likelly because the receive socket buffer builds up during startup. - QString args("--fg-root=\"" + fgPathData + "\" --timeofday=dusk --httpd=5400 --enable-hud --in-air --altitude=2000 --vc=100 --generic=socket,out,50,localhost,5500,udp,opfgprotocol"); - if ( !fgManualControl ) - { - args.append(" --generic=socket,in,400,localhost,5501,udp,opfgprotocol"); - } - - // Start FlightGear - QString cmd; - cmd = "\"" + fgPathBin + "\" " + args + "\n"; - fgProcess->write(cmd.toAscii()); - - // Start bridge - qxtLog->info("HITL: Starting bridge, initializing FlighGear and Autopilot connections"); - fgBridge = new FlightGearBridge(); - connect(fgBridge, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect())); - connect(fgBridge, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); - connect(fgBridge, SIGNAL(fgConnected()), this, SLOT(onFGConnect())); - connect(fgBridge, SIGNAL(fgDisconnected()), this, SLOT(onFGDisconnect())); - - // Initialize connection status - if ( fgBridge->isAutopilotConnected() ) - { - onAutopilotConnect(); - } - else - { - onAutopilotDisconnect(); - } - if ( fgBridge->isFGConnected() ) - { - onFGConnect(); - } - else - { - onFGDisconnect(); - } -} - -void HITLWidget::stopButtonClicked() -{ - // NOTE: Does not currently work, may need to send control+c to through the terminal - if (fgProcess != NULL) - { - fgProcess->disconnect(this); - fgProcess->kill(); - delete fgProcess; - fgBridge->disconnect(this); - delete fgBridge; - fgProcess = NULL; - } -} - -void HITLWidget::setFGPathBin(QString fgPath) -{ - this->fgPathBin = fgPath; -} - -void HITLWidget::setFGPathData(QString fgPath) -{ - this->fgPathData = fgPath; -} - -void HITLWidget::setFGManualControl(bool val) -{ - this->fgManualControl = val; -} - -void HITLWidget::processReadyRead() -{ - QByteArray bytes = fgProcess->readAllStandardOutput(); - QString str(bytes); - if ( !str.contains("Error reading data") ) // ignore error - { - widget->textBrowser->append(str); - } -} - -void HITLWidget::onAutopilotConnect() -{ - QPalette pal(widget->apLabel->palette()); - pal.setColor(QPalette::Window, Qt::green); - widget->apLabel->setPalette(pal); - widget->apLabel->setAutoFillBackground(true); - widget->apLabel->setText("AutoPilot Connected"); - qxtLog->info("HITL: Autopilot connected, initializing for HITL simulation"); -} - -void HITLWidget::onAutopilotDisconnect() -{ - QPalette pal(widget->apLabel->palette()); - pal.setColor(QPalette::Window, Qt::red); - widget->apLabel->setPalette(pal); - widget->apLabel->setAutoFillBackground(true); - widget->apLabel->setText("AutoPilot Disconnected"); - qxtLog->info("HITL: Autopilot disconnected"); -} - -void HITLWidget::onFGConnect() -{ - QPalette pal(widget->fgLabel->palette()); - pal.setColor(QPalette::Window, Qt::green); - widget->fgLabel->setPalette(pal); - widget->fgLabel->setAutoFillBackground(true); - widget->fgLabel->setText("FlightGear Connected"); - qxtLog->info("HITL: FlighGear connected"); -} - -void HITLWidget::onFGDisconnect() -{ - QPalette pal(widget->fgLabel->palette()); - pal.setColor(QPalette::Window, Qt::red); - widget->fgLabel->setPalette(pal); - widget->fgLabel->setAutoFillBackground(true); - widget->fgLabel->setText("FlightGear Disconnected"); - qxtLog->info("HITL: FlighGear disconnected"); -} - - diff --git a/ground/src/plugins/hitl/hitlwidget.h b/ground/src/plugins/hitl/hitlwidget.h deleted file mode 100644 index 0f7c7364f..000000000 --- a/ground/src/plugins/hitl/hitlwidget.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlwidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup HITLPlugin HITL Plugin - * @{ - * @brief The Hardware In The Loop plugin - *****************************************************************************/ -/* - * 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 HITLWIDGET_H -#define HITLWIDGET_H - -#include -#include -#include "flightgearbridge.h" - -class Ui_HITLWidget; - -class HITLWidget : public QWidget -{ - Q_OBJECT - -public: - HITLWidget(QWidget *parent = 0); - ~HITLWidget(); - - void setFGPathBin(QString fgPath); - void setFGPathData(QString fgPath); - void setFGManualControl(bool val); - -public slots: - -private slots: - void startButtonClicked(); - void stopButtonClicked(); - void processReadyRead(); - void onAutopilotConnect(); - void onAutopilotDisconnect(); - void onFGConnect(); - void onFGDisconnect(); - -private: - Ui_HITLWidget* widget; - FlightGearBridge* fgBridge; - QProcess* fgProcess; - QString fgPathBin; - QString fgPathData; - bool fgManualControl; - QString cmdShell; -}; - -#endif /* HITLWIDGET_H */ diff --git a/ground/src/plugins/hitl/hitlwidget.ui b/ground/src/plugins/hitl/hitlwidget.ui deleted file mode 100644 index 6576e5852..000000000 --- a/ground/src/plugins/hitl/hitlwidget.ui +++ /dev/null @@ -1,210 +0,0 @@ - - - HITLWidget - - - - 0 - 0 - 786 - 300 - - - - Form - - - - - - - - Request update - - - Start - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - Send update - - - Stop - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Vertical - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - - 50 - false - - - - false - - - AutoPilot Disconnected - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - FlighGear Disconnected - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Vertical - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - diff --git a/ground/src/plugins/hitl/opfgprotocol.xml b/ground/src/plugins/hitl/opfgprotocol.xml deleted file mode 100644 index 994c1091a..000000000 --- a/ground/src/plugins/hitl/opfgprotocol.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - \n - , - - - aileron - /controls/flight/aileron - float - %f - - - - elevator - /controls/flight/elevator - float - %f - - - - rudder - /controls/flight/rudder - float - %f - - - - throttle - /controls/engines/engine/throttle - float - %f - - - - - - \n - , - - - xRate - /fdm/jsbsim/velocities/p-rad_sec - float - %f - - - - yRate - /fdm/jsbsim/velocities/q-rad_sec - float - %f - - - - zRate - /fdm/jsbsim/velocities/r-rad_sec - float - %f - - - - xAccel - - /accelerations/pilot/x-accel-fps_sec - float - %f - - - - yAccel - /accelerations/pilot/y-accel-fps_sec - float - %f - - - - zAccel - /accelerations/pilot/z-accel-fps_sec - float - %f - - - - Pitch - /orientation/pitch-deg - float - %f - - - - PitchRate - /orientation/pitch-rate-degps - float - %f - - - - Roll - /orientation/roll-deg - float - %f - - - - RollRate - /orientation/roll-rate-degps - float - %f - - - - Yaw - /orientation/heading-magnetic-deg - float - %f - - - - YawRate - /orientation/yaw-rate-degps - float - %f - - - - Latitude - /position/latitude-deg - float - %f - - - - Longitude - /position/longitude-deg - float - %f - - - - Heading - /orientation/heading-deg - float - %f - - - - Altitude - /position/altitude-ft - float - %f - - - - AltitudeAGL - /position/altitude-agl-ft - float - %f - - - - Groundspeed - /velocities/groundspeed-kt - float - %f - - - - Airspeed - /velocities/airspeed-kt - float - %f - - - - Temperature - /environment/temperature-degc - float - %f - - - - Temperature - /environment/temperature-degc - float - %f - - - - Pressure - /environment/pressure-inhg - float - %f - - - - - - diff --git a/ground/src/plugins/hitlil2/HITLIL2.pluginspec b/ground/src/plugins/hitlil2/HITLIL2.pluginspec deleted file mode 100644 index ea54de0a2..000000000 --- a/ground/src/plugins/hitlil2/HITLIL2.pluginspec +++ /dev/null @@ -1,12 +0,0 @@ - - The OpenPilot Project - (C) 2010 OpenPilot Project - The GNU Public License (GPL) Version 3 - Hardware In The Loop Simulation with IL2 - http://www.openpilot.org - - - - - - diff --git a/ground/src/plugins/hitlil2/hitlil2.cpp b/ground/src/plugins/hitlil2/hitlil2.cpp deleted file mode 100644 index c185ae8ab..000000000 --- a/ground/src/plugins/hitlil2/hitlil2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2.h" -#include "hitlil2widget.h" -#include "hitlil2configuration.h" - -HITLIL2::HITLIL2(QString classId, HITLIL2Widget *widget, QWidget *parent) : - IUAVGadget(classId, parent), - m_widget(widget) -{ -} - -HITLIL2::~HITLIL2() -{ - -} - -void HITLIL2::loadConfiguration(IUAVGadgetConfiguration* config) -{ - HITLIL2Configuration *m = qobject_cast(config); - m_widget->setIl2HostName( m->il2HostName() ); - m_widget->setIl2Latitude( m->il2Latitude() ); - m_widget->setIl2Longitude( m->il2Longitude() ); - m_widget->setIl2Port( m->il2Port() ); - m_widget->setIl2ManualControl( m->il2ManualControl() ); -} - diff --git a/ground/src/plugins/hitlil2/hitlil2.h b/ground/src/plugins/hitlil2/hitlil2.h deleted file mode 100644 index dc9b1ca78..000000000 --- a/ground/src/plugins/hitlil2/hitlil2.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2_H -#define HITLIL2_H - -#include -#include "hitlil2widget.h" - -class IUAVGadget; -class QWidget; -class QString; -class HITLIL2Widget; - -using namespace Core; - -class HITLIL2 : public Core::IUAVGadget -{ - Q_OBJECT -public: - HITLIL2(QString classId, HITLIL2Widget *widget, QWidget *parent = 0); - ~HITLIL2(); - - QWidget *widget() { return m_widget; } - void loadConfiguration(IUAVGadgetConfiguration* config); - -private: - HITLIL2Widget *m_widget; -}; - - -#endif // HITLIL2_H diff --git a/ground/src/plugins/hitlil2/hitlil2.pro b/ground/src/plugins/hitlil2/hitlil2.pro deleted file mode 100644 index 15a47606e..000000000 --- a/ground/src/plugins/hitlil2/hitlil2.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = lib -TARGET = HITLIL2 -QT += network -include(../../openpilotgcsplugin.pri) -include(hitlil2_dependencies.pri) -HEADERS += hitlil2plugin.h \ - hitlil2widget.h \ - hitlil2optionspage.h \ - hitlil2factory.h \ - hitlil2configuration.h \ - hitlil2.h \ - il2bridge.h -SOURCES += hitlil2plugin.cpp \ - hitlil2widget.cpp \ - hitlil2optionspage.cpp \ - hitlil2factory.cpp \ - hitlil2configuration.cpp \ - hitlil2.cpp \ - il2bridge.cpp -OTHER_FILES += HITLIL2.pluginspec -FORMS += hitlil2optionspage.ui \ - hitlil2widget.ui diff --git a/ground/src/plugins/hitlil2/hitlil2_dependencies.pri b/ground/src/plugins/hitlil2/hitlil2_dependencies.pri deleted file mode 100644 index 303773902..000000000 --- a/ground/src/plugins/hitlil2/hitlil2_dependencies.pri +++ /dev/null @@ -1,4 +0,0 @@ -include(../../plugins/uavobjects/uavobjects.pri) -include(../../plugins/uavtalk/uavtalk.pri) -include(../../plugins/coreplugin/coreplugin.pri) -include(../../libs/utils/utils.pri) diff --git a/ground/src/plugins/hitlil2/hitlil2configuration.cpp b/ground/src/plugins/hitlil2/hitlil2configuration.cpp deleted file mode 100644 index 4a7b025cf..000000000 --- a/ground/src/plugins/hitlil2/hitlil2configuration.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2configuration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2configuration.h" -#include - -HITLIL2Configuration::HITLIL2Configuration(QString classId, const QByteArray &state, QObject *parent) : - IUAVGadgetConfiguration(classId, parent), - m_il2HostName(""), m_il2Latitude(""), m_il2Longitude(""), m_il2Port(0), m_il2ManualControl(false) -{ - if (state.count() > 0) { - QDataStream stream(state); - QString il2HostName; - QString il2Latitude; - QString il2Longitude; - int il2Port; - bool il2ManualControl; - stream >> il2HostName; - m_il2HostName = il2HostName; - stream >> il2Latitude; - m_il2Latitude = il2Latitude; - stream >> il2Longitude; - m_il2Longitude = il2Longitude; - stream >> il2Port; - m_il2Port = il2Port; - stream >> il2ManualControl; - m_il2ManualControl = il2ManualControl; - } -} - -IUAVGadgetConfiguration *HITLIL2Configuration::clone() -{ - HITLIL2Configuration *m = new HITLIL2Configuration(this->classId()); - m->m_il2HostName = m_il2HostName; - m->m_il2Latitude = m_il2Latitude; - m->m_il2Longitude = m_il2Longitude; - m->m_il2Port = m_il2Port; - m->m_il2ManualControl = m_il2ManualControl; - return m; -} - -QByteArray HITLIL2Configuration::saveState() const -{ - QByteArray bytes; - QDataStream stream(&bytes, QIODevice::WriteOnly); - stream << m_il2HostName; - stream << m_il2Latitude; - stream << m_il2Longitude; - stream << m_il2Port; - stream << m_il2ManualControl; - return bytes; -} - diff --git a/ground/src/plugins/hitlil2/hitlil2configuration.h b/ground/src/plugins/hitlil2/hitlil2configuration.h deleted file mode 100644 index d70e7a098..000000000 --- a/ground/src/plugins/hitlil2/hitlil2configuration.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2configuration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2CONFIGURATION_H -#define HITLIL2CONFIGURATION_H - -#include -#include -#include - -using namespace Core; - -class HITLIL2Configuration : public IUAVGadgetConfiguration -{ - -Q_OBJECT -Q_PROPERTY(QString m_il2HostName READ il2HostName WRITE setIl2HostName) -Q_PROPERTY(QString m_il2Latitude READ il2Latitude WRITE setIl2Latitude) -Q_PROPERTY(QString m_il2Longitude READ il2Longitude WRITE setIl2Longitude) -Q_PROPERTY(int m_il2Port READ il2Port WRITE setIl2Port) -Q_PROPERTY(bool m_il2ManualControl READ il2ManualControl WRITE setIl2ManualControl) - -public: - explicit HITLIL2Configuration(QString classId, const QByteArray &state = 0, QObject *parent = 0); - QByteArray saveState() const; - IUAVGadgetConfiguration *clone(); - - QString il2HostName() const { return m_il2HostName; } - QString il2Latitude() const { return m_il2Latitude; } - QString il2Longitude() const { return m_il2Longitude; } - int il2Port() const { return m_il2Port; } - bool il2ManualControl() const { return m_il2ManualControl; } - -signals: - -public slots: - void setIl2HostName(QString HostName) { m_il2HostName = HostName; } - void setIl2Latitude(QString Latitude) { m_il2Latitude = Latitude; } - void setIl2Longitude(QString Longitude) { m_il2Longitude = Longitude; } - void setIl2Port(int Port) { m_il2Port = Port; } - void setIl2ManualControl(bool val) { m_il2ManualControl = val; } - -private: - QString m_il2HostName; - QString m_il2Latitude; - QString m_il2Longitude; - int m_il2Port; - bool m_il2ManualControl; - -}; - -#endif // HITLIL2CONFIGURATION_H diff --git a/ground/src/plugins/hitlil2/hitlil2factory.cpp b/ground/src/plugins/hitlil2/hitlil2factory.cpp deleted file mode 100644 index 66c0d4a24..000000000 --- a/ground/src/plugins/hitlil2/hitlil2factory.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2factory.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2factory.h" -#include "hitlil2widget.h" -#include "hitlil2.h" -#include "hitlil2configuration.h" -#include "hitlil2optionspage.h" -#include - -HITLIL2Factory::HITLIL2Factory(QObject *parent) : - IUAVGadgetFactory(QString("HITLIL2"), tr("HITL Simulation with IL2"), parent) -{ -} - -HITLIL2Factory::~HITLIL2Factory() -{ -} - -Core::IUAVGadget* HITLIL2Factory::createGadget(QWidget *parent) -{ - HITLIL2Widget* gadgetWidget = new HITLIL2Widget(parent); - return new HITLIL2(QString("HITLIL2"), gadgetWidget, parent); -} - -IUAVGadgetConfiguration *HITLIL2Factory::createConfiguration(const QByteArray &state) -{ - return new HITLIL2Configuration(QString("HITLIL2"), state); -} - -IOptionsPage *HITLIL2Factory::createOptionsPage(IUAVGadgetConfiguration *config) -{ - return new HITLIL2OptionsPage(qobject_cast(config)); -} - diff --git a/ground/src/plugins/hitlil2/hitlil2factory.h b/ground/src/plugins/hitlil2/hitlil2factory.h deleted file mode 100644 index dd513d35e..000000000 --- a/ground/src/plugins/hitlil2/hitlil2factory.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2factory.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2FACTORY_H -#define HITLIL2FACTORY_H - -#include - -namespace Core { -class IUAVGadget; -class IUAVGadgetFactory; -} - -using namespace Core; - -class HITLIL2Factory : public Core::IUAVGadgetFactory -{ - Q_OBJECT -public: - HITLIL2Factory(QObject *parent = 0); - ~HITLIL2Factory(); - - Core::IUAVGadget *createGadget(QWidget *parent); - IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); - IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); -}; - -#endif // HITLIL2FACTORY_H diff --git a/ground/src/plugins/hitlil2/hitlil2optionspage.cpp b/ground/src/plugins/hitlil2/hitlil2optionspage.cpp deleted file mode 100644 index 88b141d1d..000000000 --- a/ground/src/plugins/hitlil2/hitlil2optionspage.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2optionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2optionspage.h" -#include "hitlil2configuration.h" -#include "ui_hitlil2optionspage.h" - - -HITLIL2OptionsPage::HITLIL2OptionsPage(HITLIL2Configuration *config, QObject *parent) : - IOptionsPage(parent), - m_config(config) -{ -} - -QWidget *HITLIL2OptionsPage::createPage(QWidget *parent) -{ - // Create page - m_optionsPage = new Ui::HITLIL2OptionsPage(); - QWidget* optionsPageWidget = new QWidget; - m_optionsPage->setupUi(optionsPageWidget); - - - // Restore the contents from the settings: - m_optionsPage->Il2HostName->setText(m_config->il2HostName()); - m_optionsPage->Il2Latitude->setText(m_config->il2Latitude()); - m_optionsPage->Il2Longitude->setText(m_config->il2Longitude()); - m_optionsPage->Il2Port->setValue(m_config->il2Port()); - m_optionsPage->il2ManualControl->setChecked(m_config->il2ManualControl()); - - - return optionsPageWidget; -} - -void HITLIL2OptionsPage::apply() -{ - m_config->setIl2HostName( m_optionsPage->Il2HostName->text()); - m_config->setIl2Latitude( m_optionsPage->Il2Latitude->text()); - m_config->setIl2Longitude( m_optionsPage->Il2Longitude->text()); - m_config->setIl2Port( m_optionsPage->Il2Port->value()); - m_config->setIl2ManualControl( m_optionsPage->il2ManualControl->isChecked()); -} - -void HITLIL2OptionsPage::finish() -{ - delete m_optionsPage; -} diff --git a/ground/src/plugins/hitlil2/hitlil2optionspage.h b/ground/src/plugins/hitlil2/hitlil2optionspage.h deleted file mode 100644 index fab548c6c..000000000 --- a/ground/src/plugins/hitlil2/hitlil2optionspage.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2optionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2OPTIONSPAGE_H -#define HITLIL2OPTIONSPAGE_H - -#include "coreplugin/dialogs/ioptionspage.h" - -namespace Core { -class IUAVGadgetConfiguration; -} - -class HITLIL2Configuration; - -using namespace Core; - -namespace Ui { - class HITLIL2OptionsPage; -} - -class HITLIL2OptionsPage : public IOptionsPage -{ -Q_OBJECT -public: - explicit HITLIL2OptionsPage(HITLIL2Configuration *config, QObject *parent = 0); - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -signals: - -private slots: - -private: - HITLIL2Configuration* m_config; - Ui::HITLIL2OptionsPage* m_optionsPage; - -}; - -#endif // HITLIL2OPTIONSPAGE_H diff --git a/ground/src/plugins/hitlil2/hitlil2optionspage.ui b/ground/src/plugins/hitlil2/hitlil2optionspage.ui deleted file mode 100644 index 45d52ed68..000000000 --- a/ground/src/plugins/hitlil2/hitlil2optionspage.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - HITLIL2OptionsPage - - - - 0 - 0 - 388 - 300 - - - - Form - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Manual aircraft control (can be used when hardware is not available) - - - Manual aircraft control (can be used when hardware is not available) - - - - - - - 1 - - - 999999 - - - - - - - IL2 DeviceLink Port - - - - - - - - - - IL2 Host Name/Number - - - - - - - - - - Longitude offset (in degrees) - - - - - - - - - - Latitude offset (in degrees) - - - - - - - - diff --git a/ground/src/plugins/hitlil2/hitlil2plugin.cpp b/ground/src/plugins/hitlil2/hitlil2plugin.cpp deleted file mode 100644 index 9a42f0777..000000000 --- a/ground/src/plugins/hitlil2/hitlil2plugin.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2plugin.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2plugin.h" -#include "hitlil2factory.h" -#include -#include -#include - -HITLIL2Plugin::HITLIL2Plugin() -{ - // Do nothing -} - -HITLIL2Plugin::~HITLIL2Plugin() -{ - // Do nothing -} - -bool HITLIL2Plugin::initialize(const QStringList& args, QString *errMsg) -{ - Q_UNUSED(args); - Q_UNUSED(errMsg); - mf = new HITLIL2Factory(this); - addAutoReleasedObject(mf); - - return true; -} - -void HITLIL2Plugin::extensionsInitialized() -{ - // Do nothing -} - -void HITLIL2Plugin::shutdown() -{ - // Do nothing -} -Q_EXPORT_PLUGIN(HITLIL2Plugin) - diff --git a/ground/src/plugins/hitlil2/hitlil2plugin.h b/ground/src/plugins/hitlil2/hitlil2plugin.h deleted file mode 100644 index 450c7645a..000000000 --- a/ground/src/plugins/hitlil2/hitlil2plugin.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2plugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2PLUGIN_H -#define HITLIL2PLUGIN_H - -#include - -class HITLIL2Factory; - -class HITLIL2Plugin : public ExtensionSystem::IPlugin -{ -public: - HITLIL2Plugin(); - ~HITLIL2Plugin(); - - void extensionsInitialized(); - bool initialize(const QStringList & arguments, QString * errorString); - void shutdown(); -private: - HITLIL2Factory *mf; -}; -#endif /* HITLIL2PLUGIN_H */ diff --git a/ground/src/plugins/hitlil2/hitlil2widget.cpp b/ground/src/plugins/hitlil2/hitlil2widget.cpp deleted file mode 100644 index 6cb659250..000000000 --- a/ground/src/plugins/hitlil2/hitlil2widget.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlil2widget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 "hitlil2widget.h" -#include "ui_hitlil2widget.h" -#include "qxtlogger.h" -#include -#include "uavobjects/uavobjectmanager.h" - -HITLIL2Widget::HITLIL2Widget(QWidget *parent) : QWidget(parent) -{ - widget = new Ui_HITLIL2Widget(); - widget->setupUi(this); - connect(widget->startButton, SIGNAL(clicked()), this, SLOT(startButtonClicked())); - connect(widget->stopButton, SIGNAL(clicked()), this, SLOT(stopButtonClicked())); - /* Note to myself: failure to initialize pointers can cause segfaults */ - il2Bridge=NULL; -} - -HITLIL2Widget::~HITLIL2Widget() -{ - delete widget; -} - -void HITLIL2Widget::startButtonClicked() -{ - // Stop running process if one is active - if (il2Bridge != NULL) - { - stopButtonClicked(); - } - - // Setup process - widget->textBrowser->append(QString("Connecting to IL2 ...\n")); - - // Start bridge - qxtLog->info("HITLIL2: Starting bridge, initializing IL2 and Autopilot connections"); - il2Bridge = new Il2Bridge(il2HostName,il2Port,il2Latitude,il2Longitude); - connect(il2Bridge, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect())); - connect(il2Bridge, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); - connect(il2Bridge, SIGNAL(il2Connected()), this, SLOT(onIl2Connect())); - connect(il2Bridge, SIGNAL(il2Disconnected()), this, SLOT(onIl2Disconnect())); - - // Initialize connection status - if ( il2Bridge->isAutopilotConnected() ) - { - onAutopilotConnect(); - } - else - { - onAutopilotDisconnect(); - } - if ( il2Bridge->isIl2Connected() ) - { - onIl2Connect(); - } - else - { - onIl2Disconnect(); - } -} - -void HITLIL2Widget::stopButtonClicked() -{ - if (il2Bridge != NULL) - { - il2Bridge->disconnect(this); - delete il2Bridge; - il2Bridge = NULL; - } -} - -void HITLIL2Widget::setIl2HostName(QString il2HostName) -{ - this->il2HostName = il2HostName; -} - -void HITLIL2Widget::setIl2Latitude(QString il2Latitude) -{ - this->il2Latitude = il2Latitude; -} - -void HITLIL2Widget::setIl2Longitude(QString il2Longitude) -{ - this->il2Longitude = il2Longitude; -} - -void HITLIL2Widget::setIl2Port(int il2Port) -{ - this->il2Port = il2Port; -} - -void HITLIL2Widget::setIl2ManualControl(bool val) -{ - this->il2ManualControl = val; -} - -void HITLIL2Widget::onAutopilotConnect() -{ - QPalette pal(widget->apLabel->palette()); - pal.setColor(QPalette::Window, Qt::green); - widget->apLabel->setPalette(pal); - widget->apLabel->setAutoFillBackground(true); - widget->apLabel->setText("AutoPilot Connected"); - qxtLog->info("HITL-IL2: Autopilot connected, initializing for HITL simulation"); -} - -void HITLIL2Widget::onAutopilotDisconnect() -{ - QPalette pal(widget->apLabel->palette()); - pal.setColor(QPalette::Window, Qt::red); - widget->apLabel->setPalette(pal); - widget->apLabel->setAutoFillBackground(true); - widget->apLabel->setText("AutoPilot Disconnected"); - qxtLog->info("HITL-IL2: Autopilot disconnected"); -} - -void HITLIL2Widget::onIl2Connect() -{ - QPalette pal(widget->il2Label->palette()); - pal.setColor(QPalette::Window, Qt::green); - widget->il2Label->setPalette(pal); - widget->il2Label->setAutoFillBackground(true); - widget->il2Label->setText("IL2 Connected"); - qxtLog->info("HITL-IL2: IL2 connected"); -} - -void HITLIL2Widget::onIl2Disconnect() -{ - QPalette pal(widget->il2Label->palette()); - pal.setColor(QPalette::Window, Qt::red); - widget->il2Label->setPalette(pal); - widget->il2Label->setAutoFillBackground(true); - widget->il2Label->setText("IL2 Disconnected"); - qxtLog->info("HITL-IL2: IL2 disconnected"); -} - - diff --git a/ground/src/plugins/hitlil2/hitlil2widget.h b/ground/src/plugins/hitlil2/hitlil2widget.h deleted file mode 100644 index 8c0d75a46..000000000 --- a/ground/src/plugins/hitlil2/hitlil2widget.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - ****************************************************************************** - * - * @file hitlwidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 HITLIL2WIDGET_H -#define HITLIL2WIDGET_H - -#include -#include "il2bridge.h" - -class Ui_HITLIL2Widget; - -class HITLIL2Widget : public QWidget -{ - Q_OBJECT - -public: - HITLIL2Widget(QWidget *parent = 0); - ~HITLIL2Widget(); - - void setIl2HostName(QString il2HostName); - void setIl2Latitude(QString il2Latitude); - void setIl2Longitude(QString il2Longitude); - void setIl2Port(int il2Port); - void setIl2ManualControl(bool val); - -public slots: - -private slots: - void startButtonClicked(); - void stopButtonClicked(); - void onAutopilotConnect(); - void onAutopilotDisconnect(); - void onIl2Connect(); - void onIl2Disconnect(); - -private: - Ui_HITLIL2Widget* widget; - Il2Bridge* il2Bridge; - QString il2HostName; - QString il2Latitude; - QString il2Longitude; - int il2Port; - bool il2ManualControl; -}; - -#endif /* HITLIL2WIDGET_H */ diff --git a/ground/src/plugins/hitlil2/hitlil2widget.ui b/ground/src/plugins/hitlil2/hitlil2widget.ui deleted file mode 100644 index 7ad30f3b8..000000000 --- a/ground/src/plugins/hitlil2/hitlil2widget.ui +++ /dev/null @@ -1,210 +0,0 @@ - - - HITLIL2Widget - - - - 0 - 0 - 786 - 300 - - - - Form - - - - - - - - Request update - - - Start - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - Send update - - - Stop - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Vertical - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - - 50 - false - - - - false - - - AutoPilot Disconnected - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - IL2 Disconnected - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 10 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Vertical - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - diff --git a/ground/src/plugins/hitlil2/il2bridge.cpp b/ground/src/plugins/hitlil2/il2bridge.cpp deleted file mode 100644 index 92a4ec253..000000000 --- a/ground/src/plugins/hitlil2/il2bridge.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/** - ****************************************************************************** - * - * @file il2bridge.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 - */ - -/* - * Description of DeviceLink Protocol: - * A Request is initiated with R/ followed by id's of to be requested settings - * even id's indicate read only values, odd are write only - * (usually id =get value id+1= set - for same setting) - * id's are separated by / - * requests can contain values to set, or to select a subsystem - * values are separated by \ - * example: R/30/48/64\0/64\1/ - * request read only settings 30,48 and 64 with parameters 0 and 1 - * the answer consists of an A followed by id value pairs in the same format - * example: A/30\0/48\0/64\0\22/64\1\102/ - * - * A full protocol description as well as a list of ID's and their meanings - * can be found shipped with IL2 in the file DeviceLink.txt - * - * id's used in this file: - * 30: IAS in km/h (float) - * 32: vario in m/s (float) - * 38: angular speed °/s (float) (which direction? azimuth?) - * 40: barometric alt in m (float) - * 42: flight course in ° (0-360) (float) - * 46: roll angle in ° (-180 - 180) (floatniguration) - * 48: pitch angle in ° (-90 - 90) (float) - * 80/81: engine power (-1.0 (0%) - 1.0 (100%)) (float) - * 84/85: aileron servo (-1.0 - 1.0) (float) - * 86/87: elevator servo (-1.0 - 1.0) (float) - * 88/89: rudder servo (-1.0 - 1.0) (float) - * - * IL2 currently offers no useful way of providing GPS data - * therefore fake GPS data will be calculated using IMS - * - * unfortunately angular acceleration provided is very limited, too - */ -#include "il2bridge.h" -#include "extensionsystem/pluginmanager.h" -#include -#include -#include - -const float Il2Bridge::FT2M = 0.3048; -const float Il2Bridge::KT2MPS = 0.514444444; -const float Il2Bridge::MPS2KMH = 3.6; -const float Il2Bridge::KMH2MPS = (1.0/3.6); -const float Il2Bridge::INHG2KPA = 3.386; -const float Il2Bridge::RAD2DEG = (180.0/M_PI); -const float Il2Bridge::DEG2RAD = (M_PI/180.0); -const float Il2Bridge::M2DEG = 60.*1852.; // 60 miles per degree times 1852 meters per mile -const float Il2Bridge::DEG2M = (1.0/(60.*1852.)); -const float Il2Bridge::AIR_CONST = 287.058; // J/(kg*K) -const float Il2Bridge::GROUNDDENSITY = 1.225; // kg/m³ ;) -const float Il2Bridge::TEMP_GROUND = (15.0 + 273.0); // 15°C in Kelvin -const float Il2Bridge::TEMP_LAPSE_RATE = -0.0065; //degrees per meter -const float Il2Bridge::AIR_CONST_FACTOR = -0.0341631947363104; //several nature constants calculated into one - -Il2Bridge::Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QString il2Longitude) -{ - // Init fields - il2Host = QHostAddress(il2HostName); - outPort = il2Port; - updatePeriod = 50; - il2Timeout = 2000; - autopilotConnectionStatus = false; - il2ConnectionStatus = false; - latitude=il2Latitude.toFloat(); - longitude=il2Longitude.toFloat(); - - - - // move to thread - moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread()); - - connect(this, SIGNAL(myStart()), this, SLOT(onStart()),Qt::QueuedConnection); - emit myStart(); -} - -void Il2Bridge::onStart() -{ - - // Get required UAVObjects - ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager* objManager = pm->getObject(); - actDesired = ActuatorDesired::GetInstance(objManager); - baroAltitude = BaroAltitude::GetInstance(objManager); - attActual = AttitudeActual::GetInstance(objManager); - posActual = PositionActual::GetInstance(objManager); - telStats = GCSTelemetryStats::GetInstance(objManager); - - // Listen to autopilot connection events - TelemetryManager* telMngr = pm->getObject(); - connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); - connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); - //connect(telStats, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(telStatsUpdated(UAVObject*))); - - // If already connect setup autopilot - GCSTelemetryStats::DataFields stats = telStats->getData(); - if ( stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotConnect(); - } - - // Setup local ports - outSocket = new QUdpSocket(); - outSocket->connectToHost(il2Host,outPort); - connect(outSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection); - - // Setup transmit timer - txTimer = new QTimer(); - connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection); - txTimer->setInterval(updatePeriod); - txTimer->start(); - - // Setup FG connection timer - il2Timer = new QTimer(); - connect(il2Timer, SIGNAL(timeout()), this, SLOT(onIl2ConnectionTimeout()),Qt::DirectConnection); - il2Timer->setInterval(il2Timeout); - il2Timer->start(); - - // setup time - time = new QTime(); - time->start(); - - current.T=0; - -} - -Il2Bridge::~Il2Bridge() -{ - delete outSocket; - delete txTimer; - delete il2Timer; -} - -bool Il2Bridge::isAutopilotConnected() -{ - return autopilotConnectionStatus; -} - -bool Il2Bridge::isIl2Connected() -{ - return il2ConnectionStatus; -} - -void Il2Bridge::transmitUpdate() -{ - // Read ActuatorDesired from autopilot - ActuatorDesired::DataFields actData = actDesired->getData(); - float ailerons = actData.Roll; - float elevator = actData.Pitch; - float rudder = actData.Yaw; - float throttle = actData.Throttle*2-1.0; - - // Send update to Il2 - QString cmd; - cmd=QString("R/30/32/40/42/46/48/81\\%1/85\\%2/87\\%3/89\\%4/") - .arg(throttle) - .arg(ailerons) - .arg(elevator) - .arg(rudder); - QByteArray data = cmd.toAscii(); - outSocket->write(data); -} - -void Il2Bridge::receiveUpdate() -{ - // Update connection timer and status - il2Timer->setInterval(il2Timeout); - il2Timer->stop(); - il2Timer->start(); - if ( !il2ConnectionStatus ) - { - il2ConnectionStatus = true; - emit il2Connected(); - } - // Process data - while ( outSocket->bytesAvailable() > 0 ) - { - // Receive datagram - QByteArray datagram; - datagram.resize(outSocket->pendingDatagramSize()); - QHostAddress sender; - quint16 senderPort; - outSocket->readDatagram(datagram.data(), datagram.size(), - &sender, &senderPort); - QString datastr(datagram); - // Process incomming data - processUpdate(datastr); - } -} - -void Il2Bridge::setupObjects() -{ - setupInputObject(actDesired, 75); - setupOutputObject(baroAltitude, 250); - setupOutputObject(attActual, 75); - setupOutputObject(posActual, 250); -} - -void Il2Bridge::setupInputObject(UAVObject* obj, int updatePeriod) -{ - UAVObject::Metadata mdata; - mdata = obj->getDefaultMetadata(); - mdata.flightAccess = UAVObject::ACCESS_READWRITE; - mdata.gcsAccess = UAVObject::ACCESS_READWRITE; - mdata.flightTelemetryAcked = false; - mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; - mdata.flightTelemetryUpdatePeriod = updatePeriod; - mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL; - obj->setMetadata(mdata); -} - -void Il2Bridge::setupOutputObject(UAVObject* obj, int updatePeriod) -{ - UAVObject::Metadata mdata; - mdata = obj->getDefaultMetadata(); - mdata.flightAccess = UAVObject::ACCESS_READONLY; - mdata.gcsAccess = UAVObject::ACCESS_READWRITE; - mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER; - mdata.gcsTelemetryAcked = false; - mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; - mdata.gcsTelemetryUpdatePeriod = updatePeriod; - obj->setMetadata(mdata); -} - -void Il2Bridge::onAutopilotConnect() -{ - autopilotConnectionStatus = true; - setupObjects(); - emit autopilotConnected(); -} - -void Il2Bridge::onAutopilotDisconnect() -{ - autopilotConnectionStatus = false; - emit autopilotDisconnected(); -} - -void Il2Bridge::onIl2ConnectionTimeout() -{ - if ( il2ConnectionStatus ) - { - il2ConnectionStatus = false; - emit il2Disconnected(); - } -} - -/** - * calculate air density from altitude - */ -float Il2Bridge::DENSITY(float alt) { - return (GROUNDDENSITY * pow( - ((TEMP_GROUND+(TEMP_LAPSE_RATE*alt))/TEMP_GROUND), - ((AIR_CONST_FACTOR/TEMP_LAPSE_RATE)-1) ) - ); -} - -/** - * calculate air pressure from altitude - */ -float Il2Bridge::PRESSURE(float alt) { - return DENSITY(alt)*(TEMP_GROUND+(alt*TEMP_LAPSE_RATE))*AIR_CONST; - -} - -/** - * calculate TAS from IAS and altitude - */ -float Il2Bridge::TAS(float IAS, float alt) { - return (IAS*sqrt(GROUNDDENSITY/DENSITY(alt))); -} - -/** - * process data string from flight simulator - */ -void Il2Bridge::processUpdate(QString& data) -{ - // save old flight data to calculate delta's later - old=current; - - // Split - QStringList fields = data.split("/"); - - // split up response string - int t; - for (t=0; t=2) { - int id = values[0].toInt(); - float value = values[1].toFloat(); - switch (id) { - case 30: - current.ias=value * KMH2MPS; - break; - case 32: - current.dZ=value; - break; - case 40: - current.Z=value; - break; - case 42: - current.azimuth=value; - break; - case 46: - current.roll=-value; - break; - case 48: - current.pitch=value; - break; - } - } - } - - // measure time - current.dT = ((float)time->restart()) / 1000.0; - current.T = old.T+current.dT; - - // calculate TAS from alt and IAS - current.tas = TAS(current.ias,current.Z); - - // assume the plane actually flies straight and no wind - // groundspeed is horizontal vector of TAS - current.groundspeed = current.tas*cos(current.pitch*DEG2RAD); - // x and y vector components - current.dX = current.groundspeed*sin(current.azimuth*DEG2RAD); - current.dY = current.groundspeed*cos(current.azimuth*DEG2RAD); - - // simple IMS - integration over time the easy way... - current.X = old.X + (current.dX*current.dT); - current.Y = old.Y + (current.dY*current.dT); - - // Update BaroAltitude object - BaroAltitude::DataFields baroAltitudeData; - baroAltitudeData.Altitude = current.Z; - baroAltitudeData.Temperature = TEMP_GROUND + (current.Z * TEMP_LAPSE_RATE) - 273.0; - baroAltitudeData.Pressure = PRESSURE(current.Z)/1000.0; // kpa - baroAltitude->setData(baroAltitudeData); - - // Update attActual object - AttitudeActual::DataFields attActualData; - attActualData.Roll = current.roll; - attActualData.Pitch = current.pitch; - attActualData.Yaw = current.azimuth; - attActualData.q1 = 0; - attActualData.q2 = 0; - attActualData.q3 = 0; - attActualData.q4 = 0; - attActual->setData(attActualData); - - // Update gps objects - PositionActual::DataFields gpsData; - gpsData.Altitude = current.Z; - gpsData.Heading = current.azimuth; - gpsData.Groundspeed = current.groundspeed; - gpsData.Latitude = latitude + current.Y * DEG2M; - if (gpsData.Latitude<-89.0 or gpsData.Latitude>89.0) { - // oops - this is rare enough to just prevent overflow here... - // IL2 has no north pole map anyway - gpsData.Latitude=0.0; - } - gpsData.Longitude = longitude + current.X * (1.0/cos(gpsData.Latitude*DEG2RAD)) * DEG2M; - while (gpsData.Longitude<-180.0) gpsData.Longitude+=360.0; - while (gpsData.Longitude>180.0) gpsData.Longitude-=360.0; - gpsData.Satellites = 7; - gpsData.Status = PositionActual::STATUS_FIX3D; - posActual->setData(gpsData); - - // issue manual update - attActual->updated(); - baroAltitude->updated(); - posActual->updated(); -} - -void Il2Bridge::telStatsUpdated(UAVObject* obj) -{ - GCSTelemetryStats::DataFields stats = telStats->getData(); - if ( !autopilotConnectionStatus && stats.Status == GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotConnect(); - } - else if ( autopilotConnectionStatus && stats.Status != GCSTelemetryStats::STATUS_CONNECTED ) - { - onAutopilotDisconnect(); - } -} diff --git a/ground/src/plugins/hitlil2/il2bridge.h b/ground/src/plugins/hitlil2/il2bridge.h deleted file mode 100644 index 95ad783fe..000000000 --- a/ground/src/plugins/hitlil2/il2bridge.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - ****************************************************************************** - * - * @file il2bridge.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlil2plugin - * @{ - * - *****************************************************************************/ -/* - * 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 IL2BRIDGE_H -#define IL2BRIDGE_H - -#include -#include -#include -#include -#include -#include -#include "uavtalk/telemetrymanager.h" -#include "uavobjects/uavobjectmanager.h" -#include "uavobjects/actuatordesired.h" -#include "uavobjects/baroaltitude.h" -#include "uavobjects/attitudeactual.h" -#include "uavobjects/positionactual.h" -#include "uavobjects/gcstelemetrystats.h" - - -/** - * just imagine this was a class without methods and all public properties - */ -struct flightParams { - - // time - float T; - float dT; - - // speed (relative) - float ias; - float tas; - float groundspeed; - - // position (absolute) - float X; - float Y; - float Z; - - // speed (absolute) - float dX; - float dY; - float dZ; - - //angle - float azimuth; - float pitch; - float roll; - -}; - - -class Il2Bridge: public QObject -{ - Q_OBJECT - -public: - Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QString il2Longitude); - ~Il2Bridge(); - - bool isAutopilotConnected(); - bool isIl2Connected(); - -signals: - void myStart(); - void autopilotConnected(); - void autopilotDisconnected(); - void il2Connected(); - void il2Disconnected(); - -private slots: - void onStart(); - void transmitUpdate(); - void receiveUpdate(); - void onAutopilotConnect(); - void onAutopilotDisconnect(); - void onIl2ConnectionTimeout(); - void telStatsUpdated(UAVObject* obj); - -private: - static const float FT2M; - static const float KT2MPS; - static const float MPS2KMH; - static const float KMH2MPS; - static const float INHG2KPA; - static const float RAD2DEG; - static const float DEG2RAD; - static const float M2DEG; - static const float DEG2M; - static const float AIR_CONST; - static const float GROUNDDENSITY; - static const float TEMP_GROUND; - static const float TEMP_LAPSE_RATE; - static const float AIR_CONST_FACTOR; - - struct flightParams current; - struct flightParams old; - QUdpSocket* outSocket; - ActuatorDesired* actDesired; - BaroAltitude* baroAltitude; - AttitudeActual* attActual; - PositionActual* posActual; - GCSTelemetryStats* telStats; - QHostAddress il2Host; - float latitude; - float longitude; - int outPort; - int updatePeriod; - QTimer* txTimer; - QTimer* il2Timer; - QTime* time; - bool autopilotConnectionStatus; - bool il2ConnectionStatus; - int il2Timeout; - - float DENSITY(float pressure); - float PRESSURE(float alt); - float TAS(float ias,float alt); - void processUpdate(QString& data); - void setupOutputObject(UAVObject* obj, int updatePeriod); - void setupInputObject(UAVObject* obj, int updatePeriod); - void setupObjects(); -}; - -#endif // IL2BRIDGE_H