diff --git a/ground/src/plugins/hitl/HITL.pluginspec b/ground/src/plugins/hitl/HITL.pluginspec
new file mode 100644
index 000000000..953a510cf
--- /dev/null
+++ b/ground/src/plugins/hitl/HITL.pluginspec
@@ -0,0 +1,12 @@
+
+ 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
new file mode 100644
index 000000000..33b927f10
--- /dev/null
+++ b/ground/src/plugins/hitl/flightgearbridge.cpp
@@ -0,0 +1,295 @@
+/**
+ ******************************************************************************
+ *
+ * @file flightgearbridge.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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"
+
+FlightGearBridge::FlightGearBridge()
+{
+ // 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);
+ altActual = AltitudeActual::GetInstance(objManager);
+ attActual = AttitudeActual::GetInstance(objManager);
+ gps = GpsObject::GetInstance(objManager);
+ telStats = GCSTelemetryStats::GetInstance(objManager);
+
+ // Listen to autopilot connection events
+ // NOTE: Disabled due to linker errors, when fixed uncomment next three lines and comment out fourth
+ 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(this);
+ outSocket = new QUdpSocket(this);
+ inSocket->bind(QHostAddress::Any, inPort);
+ connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()));
+
+ // Setup transmit timer
+ txTimer = new QTimer(this);
+ connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()));
+ txTimer->setInterval(updatePeriod);
+ txTimer->start();
+
+ // Setup FG connection timer
+ fgTimer = new QTimer(this);
+ connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()));
+ 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, 50);
+ setupOutputObject(altActual, 250);
+ setupOutputObject(attActual, 50);
+ setupOutputObject(gps, 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 AltitudeActual object
+ AltitudeActual::DataFields altActualData;
+ altActualData.Altitude = altitudeAGL;
+ altActualData.Temperature = temperature;
+ altActualData.Pressure = pressure;
+ altActual->setData(altActualData);
+
+ // 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;
+ attActualData.seq = 0;
+ attActual->setData(attActualData);
+
+ // Update gps objects
+ GpsObject::DataFields gpsData;
+ gpsData.Altitude = altitude;
+ gpsData.Heading = heading;
+ gpsData.GroundSpeed = groundspeed;
+ gpsData.Latitude = latitude;
+ gpsData.Longitude = longitude;
+ gpsData.Satellites = 10;
+ gpsData.Updates = 0;
+ gps->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
new file mode 100644
index 000000000..58eb01089
--- /dev/null
+++ b/ground/src/plugins/hitl/flightgearbridge.h
@@ -0,0 +1,96 @@
+/**
+ ******************************************************************************
+ *
+ * @file flightgearbridge.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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/altitudeactual.h"
+#include "uavobjects/attitudeactual.h"
+#include "uavobjects/gpsobject.h"
+#include "uavobjects/gcstelemetrystats.h"
+
+class FlightGearBridge: public QObject
+{
+ Q_OBJECT
+
+public:
+ FlightGearBridge();
+ ~FlightGearBridge();
+
+ bool isAutopilotConnected();
+ bool isFGConnected();
+
+signals:
+ void autopilotConnected();
+ void autopilotDisconnected();
+ void fgConnected();
+ void fgDisconnected();
+
+private slots:
+ void transmitUpdate();
+ void receiveUpdate();
+ void onAutopilotConnect();
+ void onAutopilotDisconnect();
+ void onFGConnectionTimeout();
+ void telStatsUpdated(UAVObject* obj);
+
+private:
+ static const float FT2M = 0.3048;
+ static const float KT2MPS = 0.514444444;
+ static const float INHG2KPA = 3.386;
+
+ QUdpSocket* inSocket;
+ QUdpSocket* outSocket;
+ ActuatorDesired* actDesired;
+ AltitudeActual* altActual;
+ AttitudeActual* attActual;
+ GpsObject* gps;
+ 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
new file mode 100644
index 000000000..acfd78d3e
--- /dev/null
+++ b/ground/src/plugins/hitl/hitl.cpp
@@ -0,0 +1,49 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitl.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..7cb312957
--- /dev/null
+++ b/ground/src/plugins/hitl/hitl.h
@@ -0,0 +1,56 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitl.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..a68691895
--- /dev/null
+++ b/ground/src/plugins/hitl/hitl.pro
@@ -0,0 +1,23 @@
+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
new file mode 100644
index 000000000..303773902
--- /dev/null
+++ b/ground/src/plugins/hitl/hitl_dependencies.pri
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 000000000..47138428d
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlconfiguration.cpp
@@ -0,0 +1,67 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlconfiguration.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..982acd0da
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlconfiguration.h
@@ -0,0 +1,68 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlconfiguration.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..4b0b36956
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlfactory.cpp
@@ -0,0 +1,58 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlfactory.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..fb5577251
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlfactory.h
@@ -0,0 +1,52 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlfactory.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..c54dd8321
--- /dev/null
+++ b/ground/src/plugins/hitl/hitloptionspage.cpp
@@ -0,0 +1,96 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitloptionspage.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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);
+ connect(m_optionsPage->loadFileBin, SIGNAL(clicked()), this, SLOT(onLoadFileBinClicked()));
+ connect(m_optionsPage->loadFileData, SIGNAL(clicked()), this, SLOT(onLoadFileDataClicked()));
+
+ // Restore the contents from the settings:
+ m_optionsPage->fgPathBin->setText(m_config->fgPathBin());
+ m_optionsPage->fgPathData->setText(m_config->fgPathData());
+ m_optionsPage->fgManualControl->setChecked(m_config->fgManualControl());
+
+ return optionsPageWidget;
+}
+
+void HITLOptionsPage::apply()
+{
+ m_config->setFGPathBin( m_optionsPage->fgPathBin->text());
+ m_config->setFGPathData( m_optionsPage->fgPathData->text());
+ m_config->setFGManualControl( m_optionsPage->fgManualControl->isChecked());
+}
+
+void HITLOptionsPage::finish()
+{
+ disconnect(this);
+ delete m_optionsPage;
+}
+
+void HITLOptionsPage::onLoadFileBinClicked()
+{
+ QFileDialog::Options options;
+ QString selectedFilter;
+ QString fileName = QFileDialog::getOpenFileName(qobject_cast(this),
+ tr("QFileDialog::getOpenFileName()"),
+ m_optionsPage->fgPathBin->text(),
+ tr("All Files (*)"),
+ &selectedFilter,
+ options);
+ if (!fileName.isEmpty()) m_optionsPage->fgPathBin->setText(fileName);
+}
+
+void HITLOptionsPage::onLoadFileDataClicked()
+{
+ QFileDialog::Options options;
+ QString selectedFilter;
+ QString fileName = QFileDialog::getExistingDirectory(qobject_cast(this),
+ tr("Open Directory"),
+ m_optionsPage->fgPathData->text(),
+ QFileDialog::ShowDirsOnly
+ | QFileDialog::DontResolveSymlinks);
+ if (!fileName.isEmpty()) m_optionsPage->fgPathData->setText(fileName);
+}
+
diff --git a/ground/src/plugins/hitl/hitloptionspage.h b/ground/src/plugins/hitl/hitloptionspage.h
new file mode 100644
index 000000000..f8ec6dd47
--- /dev/null
+++ b/ground/src/plugins/hitl/hitloptionspage.h
@@ -0,0 +1,67 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitloptionspage.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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:
+ void onLoadFileBinClicked();
+ void onLoadFileDataClicked();
+
+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
new file mode 100644
index 000000000..27a0c93f9
--- /dev/null
+++ b/ground/src/plugins/hitl/hitloptionspage.ui
@@ -0,0 +1,162 @@
+
+
+ HITLOptionsPage
+
+
+
+ 0
+ 0
+ 675
+ 300
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+
+ -1
+ -1
+ 481
+ 339
+
+
+
+
+ QLayout::SetMinimumSize
+
+
+ 10
+
+
+ 5
+
+
+ 10
+
+
+ 10
+
+
+
+
+ 10
+
+
+ QLayout::SetMinimumSize
+
+
+ 10
+
+
+
+
+
+ 0
+ 0
+
+
+
+ FlightGear Executable
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+
+ Browse
+
+
+
+
+
+
+
+
+ QLayout::SetMinimumSize
+
+
+
+
+
+ 0
+ 0
+
+
+
+ FlightGear Data Directory
+
+
+
+
+
+
+
+
+
+ Browse
+
+
+
+
+
+
+
+
+ QLayout::SetMinimumSize
+
+
+
+
+ Manual aircraft control (can be used when hardware is not available)
+
+
+
+
+
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
diff --git a/ground/src/plugins/hitl/hitlplugin.cpp b/ground/src/plugins/hitl/hitlplugin.cpp
new file mode 100644
index 000000000..6d22e2aeb
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlplugin.cpp
@@ -0,0 +1,63 @@
+/**
+ ******************************************************************************
+ *
+ * @file mapplugin.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..ebc00800c
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlplugin.h
@@ -0,0 +1,47 @@
+/**
+ ******************************************************************************
+ *
+ * @file browserplugin.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..756c0d8ce
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlresources.qrc
@@ -0,0 +1,5 @@
+
+
+ opfgprotocol.xml
+
+
diff --git a/ground/src/plugins/hitl/hitlwidget.cpp b/ground/src/plugins/hitl/hitlwidget.cpp
new file mode 100644
index 000000000..17128b23e
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlwidget.cpp
@@ -0,0 +1,209 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlwidget.cpp
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..13182f2b1
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlwidget.h
@@ -0,0 +1,70 @@
+/**
+ ******************************************************************************
+ *
+ * @file hitlwidget.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup hitl
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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
new file mode 100644
index 000000000..6576e5852
--- /dev/null
+++ b/ground/src/plugins/hitl/hitlwidget.ui
@@ -0,0 +1,210 @@
+
+
+ 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
new file mode 100644
index 000000000..994c1091a
--- /dev/null
+++ b/ground/src/plugins/hitl/opfgprotocol.xml
@@ -0,0 +1,201 @@
+
+
+
+
+
+ \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
+
+
+
+
+
+
+
+
diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro
index 82e601fcc..762469d8b 100644
--- a/ground/src/plugins/plugins.pro
+++ b/ground/src/plugins/plugins.pro
@@ -47,6 +47,7 @@ SUBDIRS += plugin_emptygadget
# Map UAVGadget
plugin_map.subdir = map
plugin_map.depends = plugin_coreplugin
+plugin_map.depends = plugin_uavobjects
SUBDIRS += plugin_map
# Scope UAVGadget
@@ -54,17 +55,18 @@ plugin_scope.subdir = scope
plugin_scope.depends = plugin_coreplugin
SUBDIRS += plugin_scope
-# ModelView UAVGadget
-plugin_modelview.subdir = modelview
-plugin_scope.depends = plugin_coreplugin
-SUBDIRS += plugin_modelview
-
# UAVObject Browser Gadget
plugin_uavobjectbrowser.subdir = uavobjectbrowser
plugin_uavobjectbrowser.depends = plugin_coreplugin
plugin_uavobjectbrowser.depends = plugin_uavobjects
SUBDIRS += plugin_uavobjectbrowser
+# ModelView UAVGadget
+plugin_modelview.subdir = modelview
+plugin_modelview.depends = plugin_coreplugin
+plugin_modelview.depends = plugin_uavobjects
+SUBDIRS += plugin_modelview
+
#Uploader Gadget
plugin_uploader.subdir = uploader
plugin_uploader.depends = plugin_coreplugin
@@ -92,3 +94,10 @@ plugin_config.subdir = config
plugin_config.depends = plugin_coreplugin
SUBDIRS += plugin_config
+#HITL simulation Gadget
+plugin_hitl.subdir = hitl
+plugin_hitl.depends = plugin_coreplugin
+plugin_hitl.depends += plugin_uavobjects
+plugin_hitl.depends += plugin_uavtalk
+SUBDIRS += plugin_hitl
+