Commit 18511a93 authored by Lorenz Meier's avatar Lorenz Meier

Made sensor HIL configurable, fixed runtime warnings, WIP

parent 0c9de33c
...@@ -79,6 +79,10 @@ public: ...@@ -79,6 +79,10 @@ public:
return -1; return -1;
} }
bool sensorHilEnabled() {
return _sensorHilEnabled;
}
void run(); void run();
public slots: public slots:
...@@ -104,6 +108,12 @@ public slots: ...@@ -104,6 +108,12 @@ public slots:
Q_UNUSED(airframe); Q_UNUSED(airframe);
} }
void enableSensorHIL(bool enable) {
if (enable != _sensorHilEnabled)
_sensorHilEnabled = enable;
emit sensorHilChanged(enable);
}
void readBytes(); void readBytes();
/** /**
* @brief Write a number of bytes to the interface. * @brief Write a number of bytes to the interface.
...@@ -144,6 +154,7 @@ protected: ...@@ -144,6 +154,7 @@ protected:
QProcess* terraSync; QProcess* terraSync;
unsigned int flightGearVersion; unsigned int flightGearVersion;
QString startupArguments; QString startupArguments;
bool _sensorHilEnabled;
void setName(QString name); void setName(QString name);
......
...@@ -37,6 +37,12 @@ public: ...@@ -37,6 +37,12 @@ public:
*/ */
virtual int getAirFrameIndex() = 0; virtual int getAirFrameIndex() = 0;
/**
* @brief Check if sensor level HIL is enabled
* @return true if sensor HIL is enabled
*/
virtual bool sensorHilEnabled() = 0;
public slots: public slots:
virtual void setPort(int port) = 0; virtual void setPort(int port) = 0;
/** @brief Add a new host to broadcast messages to */ /** @brief Add a new host to broadcast messages to */
...@@ -47,6 +53,8 @@ public slots: ...@@ -47,6 +53,8 @@ public slots:
virtual void processError(QProcess::ProcessError err) = 0; virtual void processError(QProcess::ProcessError err) = 0;
/** @brief Set the simulator version as text string */ /** @brief Set the simulator version as text string */
virtual void setVersion(const QString& version) = 0; virtual void setVersion(const QString& version) = 0;
/** @brief Enable sensor-level HIL (instead of state-level HIL) */
virtual void enableSensorHIL(bool enable) = 0;
virtual void selectAirframe(const QString& airframe) = 0; virtual void selectAirframe(const QString& airframe) = 0;
...@@ -105,6 +113,9 @@ signals: ...@@ -105,6 +113,9 @@ signals:
/** @brief Selected sim version changed */ /** @brief Selected sim version changed */
void versionChanged(const QString& version); void versionChanged(const QString& version);
/** @brief Sensor leve HIL state changed */
void sensorHilChanged(bool enabled);
}; };
#endif // QGCHILLINK_H #endif // QGCHILLINK_H
...@@ -81,6 +81,10 @@ public: ...@@ -81,6 +81,10 @@ public:
void run(); void run();
bool sensorHilEnabled() {
return _sensorHilEnabled;
}
public slots: public slots:
// void setAddress(QString address); // void setAddress(QString address);
void setPort(int port); void setPort(int port);
...@@ -104,6 +108,12 @@ public slots: ...@@ -104,6 +108,12 @@ public slots:
script = airframe; script = airframe;
} }
void enableSensorHIL(bool enable) {
if (enable != _sensorHilEnabled)
_sensorHilEnabled = enable;
emit sensorHilChanged(enable);
}
void readBytes(); void readBytes();
/** /**
* @brief Write a number of bytes to the interface. * @brief Write a number of bytes to the interface.
...@@ -142,6 +152,7 @@ protected: ...@@ -142,6 +152,7 @@ protected:
unsigned int flightGearVersion; unsigned int flightGearVersion;
QString startupArguments; QString startupArguments;
QString script; QString script;
bool _sensorHilEnabled;
void setName(QString name); void setName(QString name);
......
...@@ -54,7 +54,7 @@ QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress ...@@ -54,7 +54,7 @@ QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress
simUpdateLast(QGC::groundTimeMilliseconds()), simUpdateLast(QGC::groundTimeMilliseconds()),
simUpdateLastText(QGC::groundTimeMilliseconds()), simUpdateLastText(QGC::groundTimeMilliseconds()),
simUpdateHz(0), simUpdateHz(0),
sensorHilEnabled(true) _sensorHilEnabled(true)
{ {
this->localHost = localHost; this->localHost = localHost;
this->localPort = localPort/*+mav->getUASID()*/; this->localPort = localPort/*+mav->getUASID()*/;
...@@ -81,6 +81,7 @@ void QGCXPlaneLink::loadSettings() ...@@ -81,6 +81,7 @@ void QGCXPlaneLink::loadSettings()
setRemoteHost(settings.value("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort)).toString()); setRemoteHost(settings.value("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort)).toString());
setVersion(settings.value("XPLANE_VERSION", 10).toInt()); setVersion(settings.value("XPLANE_VERSION", 10).toInt());
selectAirframe(settings.value("AIRFRAME", "default").toString()); selectAirframe(settings.value("AIRFRAME", "default").toString());
_sensorHilEnabled = settings.value("SENSOR_HIL", _sensorHilEnabled).toBool();
settings.endGroup(); settings.endGroup();
} }
...@@ -92,6 +93,7 @@ void QGCXPlaneLink::storeSettings() ...@@ -92,6 +93,7 @@ void QGCXPlaneLink::storeSettings()
settings.setValue("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort)); settings.setValue("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort));
settings.setValue("XPLANE_VERSION", xPlaneVersion); settings.setValue("XPLANE_VERSION", xPlaneVersion);
settings.setValue("AIRFRAME", airframeName); settings.setValue("AIRFRAME", airframeName);
settings.setValue("SENSOR_HIL", _sensorHilEnabled);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
} }
...@@ -623,7 +625,7 @@ void QGCXPlaneLink::readBytes() ...@@ -623,7 +625,7 @@ void QGCXPlaneLink::readBytes()
} }
simUpdateLast = QGC::groundTimeMilliseconds(); simUpdateLast = QGC::groundTimeMilliseconds();
if (sensorHilEnabled) if (_sensorHilEnabled)
{ {
diff_pressure = 0.0f; diff_pressure = 0.0f;
pressure_alt = alt; pressure_alt = alt;
......
...@@ -91,6 +91,20 @@ public: ...@@ -91,6 +91,20 @@ public:
AIRFRAME_FIXED_WING_BIXLER_II_AILERONS AIRFRAME_FIXED_WING_BIXLER_II_AILERONS
}; };
QString getVersion()
{
return QString("X-Plane %1").arg(xPlaneVersion);
}
int getAirFrameIndex()
{
return (int)airframeID;
}
bool sensorHilEnabled() {
return _sensorHilEnabled;
}
public slots: public slots:
// void setAddress(QString address); // void setAddress(QString address);
void setPort(int port); void setPort(int port);
...@@ -104,14 +118,11 @@ public slots: ...@@ -104,14 +118,11 @@ public slots:
void setVersion(const QString& version); void setVersion(const QString& version);
/** @brief Set the simulator version as integer */ /** @brief Set the simulator version as integer */
void setVersion(unsigned int version); void setVersion(unsigned int version);
QString getVersion()
{
return QString("X-Plane %1").arg(xPlaneVersion);
}
int getAirFrameIndex() void enableSensorHIL(bool enable) {
{ if (enable != _sensorHilEnabled)
return (int)airframeID; _sensorHilEnabled = enable;
emit sensorHilChanged(enable);
} }
void processError(QProcess::ProcessError err); void processError(QProcess::ProcessError err);
...@@ -194,10 +205,9 @@ protected: ...@@ -194,10 +205,9 @@ protected:
quint64 simUpdateLast; quint64 simUpdateLast;
quint64 simUpdateLastText; quint64 simUpdateLastText;
float simUpdateHz; float simUpdateHz;
bool sensorHilEnabled; bool _sensorHilEnabled;
void setName(QString name); void setName(QString name);
}; };
#endif // QGCXPLANESIMULATIONLINK_H #endif // QGCXPLANESIMULATIONLINK_H
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
#define WITH_TEXT_TO_SPEECH 1 #define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 1.0.4 (beta)" #define QGC_APPLICATION_VERSION "v. 1.0.2 (beta)"
namespace QGC namespace QGC
{ {
const QString APPNAME = "QGROUNDCONTROL"; const QString APPNAME = "QGROUNDCONTROL";
const QString COMPANYNAME = "QGROUNDCONTROL"; const QString COMPANYNAME = "QGROUNDCONTROL";
const int APPLICATIONVERSION = 104; // 1.0.4 const int APPLICATIONVERSION = 105; // 1.0.4
} }
#endif // QGC_CONFIGURATION_H #endif // QGC_CONFIGURATION_H
...@@ -236,9 +236,10 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -236,9 +236,10 @@ MainWindow::MainWindow(QWidget *parent):
const int screenWidth = QApplication::desktop()->width(); const int screenWidth = QApplication::desktop()->width();
const int screenHeight = QApplication::desktop()->height(); const int screenHeight = QApplication::desktop()->height();
if (screenWidth < 1200) if (screenWidth < 1400)
{ {
showFullScreen(); resize(screenWidth, screenHeight - 80);
show();
} }
else else
{ {
...@@ -680,7 +681,7 @@ void MainWindow::showHILConfigurationWidget(UASInterface* uas) ...@@ -680,7 +681,7 @@ void MainWindow::showHILConfigurationWidget(UASInterface* uas)
QDockWidget* hilDock = new QDockWidget(hilDockName, this); QDockWidget* hilDock = new QDockWidget(hilDockName, this);
hilDock->setWidget(hconf); hilDock->setWidget(hconf);
hilDock->setObjectName(QString("HIL_CONFIG_%1").arg(uas->getUASID())); hilDock->setObjectName(QString("HIL_CONFIG_%1").arg(uas->getUASID()));
addTool(hilDock, hilDockName, Qt::RightDockWidgetArea); addTool(hilDock, hilDockName, Qt::LeftDockWidgetArea);
hilDocks.insert(mav->getUASID(), hilDock); hilDocks.insert(mav->getUASID(), hilDock);
if (currentView != VIEW_SIMULATION) if (currentView != VIEW_SIMULATION)
......
...@@ -497,7 +497,7 @@ ...@@ -497,7 +497,7 @@
<normaloff>:/files/images/control/launch.svg</normaloff>:/files/images/control/launch.svg</iconset> <normaloff>:/files/images/control/launch.svg</normaloff>:/files/images/control/launch.svg</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Simulation View</string> <string>Simulation</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Open the simulation view</string> <string>Open the simulation view</string>
......
#include <QSettings>
#include "QGCHilConfiguration.h" #include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h" #include "ui_QGCHilConfiguration.h"
...@@ -11,6 +13,22 @@ QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) : ...@@ -11,6 +13,22 @@ QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
ui(new Ui::QGCHilConfiguration) ui(new Ui::QGCHilConfiguration)
{ {
ui->setupUi(this); ui->setupUi(this);
// XXX its quite wrong that this is implicitely a factory
// class, but this is something to clean up for later.
QSettings settings;
int i = settings.value("SIMULATOR_INDEX", -1).toInt();
settings.beginGroup("QGC_HILCONFIG");
if (i > 0) {
on_simComboBox_currentIndexChanged(i);
ui->simComboBox->blockSignals(true);
ui->simComboBox->setCurrentIndex(i);
ui->simComboBox->blockSignals(false);
}
settings.endGroup();
} }
void QGCHilConfiguration::receiveStatusMessage(const QString& message) void QGCHilConfiguration::receiveStatusMessage(const QString& message)
...@@ -20,6 +38,11 @@ void QGCHilConfiguration::receiveStatusMessage(const QString& message) ...@@ -20,6 +38,11 @@ void QGCHilConfiguration::receiveStatusMessage(const QString& message)
QGCHilConfiguration::~QGCHilConfiguration() QGCHilConfiguration::~QGCHilConfiguration()
{ {
QSettings settings;
settings.beginGroup("QGC_HILCONFIG");
settings.setValue("SIMULATOR_INDEX", ui->simComboBox->currentIndex());
settings.endGroup();
settings.sync();
delete ui; delete ui;
} }
...@@ -29,8 +52,8 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index) ...@@ -29,8 +52,8 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
QLayoutItem *child; QLayoutItem *child;
while ((child = ui->simulatorConfigurationLayout->takeAt(0)) != 0) while ((child = ui->simulatorConfigurationLayout->takeAt(0)) != 0)
{ {
delete child->widget(); delete child->widget();
delete child; delete child;
} }
if(1 == index) if(1 == index)
......
...@@ -27,6 +27,11 @@ QGCHilXPlaneConfiguration::QGCHilXPlaneConfiguration(QGCHilLink* link, QWidget * ...@@ -27,6 +27,11 @@ QGCHilXPlaneConfiguration::QGCHilXPlaneConfiguration(QGCHilLink* link, QWidget *
// connect(ui->randomPositionButton, SIGNAL(clicked()), link, SLOT(setRandomPosition())); // connect(ui->randomPositionButton, SIGNAL(clicked()), link, SLOT(setRandomPosition()));
connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(selectAirframe(QString))); connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(selectAirframe(QString)));
ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex()); ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex());
// XXX not implemented yet
ui->airframeComboBox->hide();
ui->sensorHilCheckBox->setChecked(link->sensorHilEnabled());
connect(link, SIGNAL(sensorHilChanged(bool)), ui->sensorHilCheckBox, SLOT(setChecked(bool)));
connect(ui->sensorHilCheckBox, SIGNAL(clicked(bool)), link, SLOT(enableSensorHIL(bool)));
} }
ui->hostComboBox->clear(); ui->hostComboBox->clear();
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>249</width> <width>295</width>
<height>100</height> <height>148</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="40,0,0,0"> <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,100" columnstretch="40,10,10,40">
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
...@@ -24,19 +24,6 @@ ...@@ -24,19 +24,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="3"> <item row="0" column="1" colspan="3">
<widget class="QComboBox" name="airframeComboBox"> <widget class="QComboBox" name="airframeComboBox">
<property name="editable"> <property name="editable">
...@@ -127,6 +114,26 @@ ...@@ -127,6 +114,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="4">
<widget class="QCheckBox" name="sensorHilCheckBox">
<property name="text">
<string>Enable sensor level HIL</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -18,6 +18,7 @@ SystemViewParams::SystemViewParams(int systemId) ...@@ -18,6 +18,7 @@ SystemViewParams::SystemViewParams(int systemId)
, mSetpointHistoryLength(100) , mSetpointHistoryLength(100)
{ {
setObjectName("RGBD VIEW PARAMS");
} }
bool& bool&
......
...@@ -19,6 +19,7 @@ ViewParamWidget::ViewParamWidget(GlobalViewParamsPtr& globalViewParams, ...@@ -19,6 +19,7 @@ ViewParamWidget::ViewParamWidget(GlobalViewParamsPtr& globalViewParams,
, mFollowCameraComboBox(new QComboBox(this)) , mFollowCameraComboBox(new QComboBox(this))
, mTabWidget(new QTabWidget(this)) , mTabWidget(new QTabWidget(this))
{ {
setObjectName("RGBD VIEW PARAMS WIDGET");
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
QWidget* widget = new QWidget; QWidget* widget = new QWidget;
widget->setLayout(layout); widget->setLayout(layout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment