Commit 8d0f9620 authored by Bryant's avatar Bryant
parents fd7f93df afd634b4
......@@ -4,4 +4,8 @@
| BAT_N_CELLS | 1 | 100 | 3 | 1 | 1 | Number of SERIAL battery cells. Typically this ranges from 2S to 6S in small-scale UAVs |
| BAT_V_SCALING | 0.001 | 1.0 | 0.00838 | 1 | 1 | Conversion from ADC ticks to battery voltage. Depends on the connected board, calibrate with a multimeter. |
| MC_ATTRATE_P | 0.0 | 20.0 | 0.20 | 1 | 1 | Multirotor attitude rate control P gain. This gain controls how much of the motor thrust should be used to control angular velocity. A larger number will increase the control response, but will make the system also more twitchy. |
| FW_ROLLRATE_P | 0.0 | 20.0 | 0.30 | 1 | 1 | Fixed wing roll rate control P gain. This gain controls how strong the ailerons or rudder should be actuated in order to achieve a certain roll rate. A larger number will increase the control response, but will make the system also more twitchy. |
\ No newline at end of file
| MC_ATTRATE_D | 0.0 | 20.0 | 0.05 | 1 | 1 | Multirotor attitude rate control D gain. A large value will allow to damp oscillations due to a high P gain, but will make the system response suspectible to noise.|
| MC_ATT_P | 0.0 | 20.0 | 0.20 | 1 | 1 | Multirotor attitude control proportional (P) gain. This defines how strong the response of the system will be to an attitude error|
| MC_ATT_D | 0.0 | 20.0 | 0.05 | 1 | 1 | Multirotor attitude control D gain. A large value will allow to damp oscillations due to a high P gain, but will make the system response suspectible to noise.|
| FW_ROLLRATE_P | 0.0 | 20.0 | 0.30 | 1 | 1 | Fixed wing roll rate control P gain. This gain controls how strong the ailerons or rudder should be actuated in order to achieve a certain roll rate. A larger number will increase the control response, but will make the system also more twitchy. |
| FW_HEADING_P | 0.0 | 20.0 | 4.00 | 1 | 1 | Fixed wing heading error to bank angle gain |
\ No newline at end of file
......@@ -96,46 +96,39 @@ border: 1px solid #777777;
margin-top: 1ex; /* leave space at the top for the title */
}
QDockWidget {
border: 1px solid #32345E;
/* titlebar-close-icon: url(close.png);
titlebar-normal-icon: url(undock.png);*/
}
QDockWidget::title {
text-align: left; /* align the text to the left */
background: lightgray;
padding-left: 5px;
}
QDockWidget::close-button, QDockWidget::float-button {
border: 1px solid transparent;
background: darkgray;
padding: 0px;
}
QDockWidget::close-button, QDockWidget::float-button {
border: 1px solid transparent;
background: none;
padding: 0px;
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
background: gray;
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
background: none;
}
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
padding: 1px -1px -1px 1px;
}
background: none;
}
QDockWidget::close-button, QDockWidget::float-button {
background-color: #181820;
color: #EEEEEE;
QDockWidget {
border: 10px solid #66666B;
padding: 2px;
margin: 1px;
border-radius: 1px;
/*background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #59666f, stop: 1 #414B52);*/
/* titlebar-close-icon: url(close.png);
titlebar-normal-icon: url(undock.png);*/
}
QDockWidget::title {
text-align: left;
background: #121214;
color: #4A4A4F;
padding-left: 5px;
height: 10px;
border-bottom: 1px solid #555555;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3F556A, stop: 1 #293645);
color: #EDEDED;
padding-left: 10px;
height: 14px;
border-bottom: 1px solid #1B1F22;
border-bottom: 2px solid #2C3A4A;
}
QSeparator {
......@@ -190,31 +183,36 @@ QPushButton {
min-height: 18px;
max-height: 18px;
min-width: 60px;*/
border: 2px solid #4A4A4F;
border-radius: 3px;
min-height: 20px;
/*min-width: 24px;*/
max-height: 20px;
border: 0px solid #59666f;
border-radius: 2px;
padding-left: 8px;
padding-right: 8px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #232228, stop: 1 #020208);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #59666f, stop: 1 #414B52);
}
QPushButton:checked {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #404040, stop: 1 #808080);
border: 2px solid #379AC3;
border: 0px solid #379AC3;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bbbbbb, stop: 1 #b0b0b0);
border: 2px solid #379AC3;
border: 0px solid #379AC3;
}
QToolButton {
font-weight: bold;
min-height: 18px;
min-width: 24px;
max-height: 18px;
border: 2px solid #4A4A4F;
border-radius: 3px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #232228, stop: 1 #020208);
min-height: 20px;
/*min-width: 24px;*/
max-height: 20px;
border: 0px solid #4A4A4F;
border-radius: 2px;
padding-left: 3px;
padding-right: 3px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #59666f, stop: 1 #414B52);
}
QToolButton:checked {
......@@ -228,8 +226,9 @@ QToolButton:pressed {
}
QToolTip {
background-color: #090909;
border: 1px solid #379AC3;
background-color: #3D5368;
border: 0px solid #379AC3;
margin: 3px;
border-radius: 3px;
color: #DDDDDF;
}
......@@ -400,11 +399,11 @@ QDialog {
/* Style the tab using the tab sub-control. Note that
it reads QTabBar _not_ QTabWidget */
QTabBar::tab {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #090909, stop: 1 #353535);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #090909, stop: 1 #353535);
border: 2px solid #62676B;
border-radius: 4px;
min-width: 8ex;
padding: 2px;
border-radius: 4px;
min-width: 8ex;
padding: 2px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
......
......@@ -224,7 +224,9 @@ FORMS += src/ui/MainWindow.ui \
src/ui/mission/QGCMissionDoStartSearch.ui \
src/ui/mission/QGCMissionDoFinishSearch.ui \
src/ui/QGCVehicleConfig.ui \
src/ui/QGCHilConfiguration.ui
src/ui/QGCHilConfiguration.ui \
src/ui/QGCHilFlightGearConfiguration.ui \
src/ui/QGCHilXPlaneConfiguration.ui
INCLUDEPATH += src \
src/ui \
src/ui/linechart \
......@@ -362,7 +364,9 @@ HEADERS += src/MG.h \
src/ui/mission/QGCMissionDoFinishSearch.h \
src/ui/QGCVehicleConfig.h \
src/comm/QGCHilLink.h \
src/ui/QGCHilConfiguration.h
src/ui/QGCHilConfiguration.h \
src/ui/QGCHilFlightGearConfiguration.h \
src/ui/QGCHilXPlaneConfiguration.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -520,7 +524,9 @@ SOURCES += src/main.cc \
src/ui/mission/QGCMissionDoFinishSearch.cc \
src/ui/QGCVehicleConfig.cc \
src/comm/QGCHilLink.cc \
src/ui/QGCHilConfiguration.cc
src/ui/QGCHilConfiguration.cc \
src/ui/QGCHilFlightGearConfiguration.cc \
src/ui/QGCHilXPlaneConfiguration.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -39,9 +39,11 @@ This file is part of the QGROUNDCONTROL project
#include <QHostInfo>
#include "MainWindow.h"
QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString remoteHost, QHostAddress host, quint16 port) :
QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments, QString remoteHost, QHostAddress host, quint16 port) :
process(NULL),
terraSync(NULL),
socket(NULL),
startupArguments(startupArguments),
flightGearVersion(0)
{
this->host = host;
......@@ -349,20 +351,7 @@ bool QGCFlightGearLink::connectSimulation()
QString fgRoot;
QString fgScenery;
QString terraSyncScenery;
QString aircraft;
if (mav->getSystemType() == MAV_TYPE_FIXED_WING)
{
aircraft = "Rascal110-JSBSim";
}
else if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
{
aircraft = "arducopter";
}
else
{
aircraft = "Rascal110-JSBSim";
}
QString fgAircraft;
#ifdef Q_OS_MACX
processFgfs = "/Applications/FlightGear.app/Contents/Resources/fgfs";
......@@ -387,6 +376,8 @@ bool QGCFlightGearLink::connectSimulation()
terraSyncScenery = QDir::homePath() + "/.terrasync/Scenery"; //according to http://wiki.flightgear.org/TerraSync a separate directory is used
#endif
fgAircraft = QApplication::applicationDirPath() + "/files/flightgear/Aircraft";
// Sanity checks
bool sane = true;
QFileInfo executable(processFgfs);
......@@ -426,6 +417,7 @@ bool QGCFlightGearLink::connectSimulation()
/*Prepare FlightGear Arguments */
flightGearArguments << QString("--fg-root=%1").arg(fgRoot);
flightGearArguments << QString("--fg-scenery=%1:%2").arg(fgScenery).arg(terraSyncScenery); //according to http://wiki.flightgear.org/TerraSync a separate directory is used
flightGearArguments << QString("--fg-aircraft=%1").arg(fgAircraft);
if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
{
// FIXME ADD QUAD-Specific protocol here
......@@ -438,35 +430,37 @@ bool QGCFlightGearLink::connectSimulation()
flightGearArguments << QString("--generic=socket,in,50,127.0.0.1,%1,udp,qgroundcontrol").arg(currentPort);
}
flightGearArguments << "--atlas=socket,out,1,localhost,5505,udp";
flightGearArguments << "--in-air";
flightGearArguments << "--roll=0";
flightGearArguments << "--pitch=0";
flightGearArguments << "--vc=90";
flightGearArguments << "--heading=300";
flightGearArguments << "--timeofday=noon";
flightGearArguments << "--disable-hud-3d";
flightGearArguments << "--disable-fullscreen";
flightGearArguments << "--geometry=400x300";
flightGearArguments << "--disable-anti-alias-hud";
flightGearArguments << "--wind=0@0";
flightGearArguments << "--turbulence=0.0";
flightGearArguments << "--prop:/sim/frame-rate-throttle-hz=30";
flightGearArguments << "--control=mouse";
flightGearArguments << "--disable-intro-music";
flightGearArguments << "--disable-sound";
flightGearArguments << "--disable-random-objects";
flightGearArguments << "--disable-ai-models";
flightGearArguments << "--shading-flat";
flightGearArguments << "--fog-disable";
flightGearArguments << "--disable-specular-highlight";
//flightGearArguments << "--disable-skyblend";
flightGearArguments << "--disable-random-objects";
flightGearArguments << "--disable-panel";
//flightGearArguments << "--disable-horizon-effect";
flightGearArguments << "--disable-clouds";
flightGearArguments << "--fdm=jsb";
flightGearArguments << "--units-meters"; //XXX: check: the protocol xml has already a conversion from feet to m?
flightGearArguments << "--notrim";
// flightGearArguments << "--in-air";
// flightGearArguments << "--roll=0";
// flightGearArguments << "--pitch=0";
// flightGearArguments << "--vc=90";
// flightGearArguments << "--heading=300";
// flightGearArguments << "--timeofday=noon";
// flightGearArguments << "--disable-hud-3d";
// flightGearArguments << "--disable-fullscreen";
// flightGearArguments << "--geometry=400x300";
// flightGearArguments << "--disable-anti-alias-hud";
// flightGearArguments << "--wind=0@0";
// flightGearArguments << "--turbulence=0.0";
// flightGearArguments << "--prop:/sim/frame-rate-throttle-hz=30";
// flightGearArguments << "--control=mouse";
// flightGearArguments << "--disable-intro-music";
// flightGearArguments << "--disable-sound";
// flightGearArguments << "--disable-random-objects";
// flightGearArguments << "--disable-ai-models";
// flightGearArguments << "--shading-flat";
// flightGearArguments << "--fog-disable";
// flightGearArguments << "--disable-specular-highlight";
// //flightGearArguments << "--disable-skyblend";
// flightGearArguments << "--disable-random-objects";
// flightGearArguments << "--disable-panel";
// //flightGearArguments << "--disable-horizon-effect";
// flightGearArguments << "--disable-clouds";
// flightGearArguments << "--fdm=jsb";
// flightGearArguments << "--units-meters"; //XXX: check: the protocol xml has already a conversion from feet to m?
// flightGearArguments << "--notrim";
flightGearArguments += startupArguments.split(" ");
if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
{
// Start all engines of the quad
......@@ -483,7 +477,7 @@ bool QGCFlightGearLink::connectSimulation()
flightGearArguments << QString("--lon=%1").arg(UASManager::instance()->getHomeLongitude());
flightGearArguments << QString("--altitude=%1").arg(UASManager::instance()->getHomeAltitude());
// Add new argument with this: flightGearArguments << "";
flightGearArguments << QString("--aircraft=%2").arg(aircraft);
//flightGearArguments << QString("--aircraft=%2").arg(aircraft);
/*Prepare TerraSync Arguments */
QStringList terraSyncArguments;
......@@ -542,6 +536,15 @@ void QGCFlightGearLink::printTerraSyncError()
}
}
/**
* @brief Set the startup arguments used to start flightgear
*
**/
void QGCFlightGearLink::setStartupArguments(QString startupArguments)
{
this->startupArguments = startupArguments;
}
/**
* @brief Check if connection is active.
*
......
......@@ -49,7 +49,7 @@ class QGCFlightGearLink : public QGCHilLink
//Q_INTERFACES(QGCFlightGearLinkInterface:LinkInterface)
public:
QGCFlightGearLink(UASInterface* mav, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
QGCFlightGearLink(UASInterface* mav, QString startupArguments, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
~QGCFlightGearLink();
bool isConnected();
......@@ -99,6 +99,11 @@ public slots:
Q_UNUSED(version);
}
void selectAirframe(const QString& airframe)
{
Q_UNUSED(airframe);
}
void readBytes();
/**
* @brief Write a number of bytes to the interface.
......@@ -112,6 +117,7 @@ public slots:
void printTerraSyncOutput();
void printTerraSyncError();
void setStartupArguments(QString startupArguments);
protected:
QString name;
......@@ -137,6 +143,7 @@ protected:
QProcess* process;
QProcess* terraSync;
unsigned int flightGearVersion;
QString startupArguments;
void setName(QString name);
......
......@@ -48,6 +48,8 @@ public slots:
/** @brief Set the simulator version as text string */
virtual void setVersion(const QString& version) = 0;
virtual void selectAirframe(const QString& airframe) = 0;
virtual void readBytes() = 0;
/**
* @brief Write a number of bytes to the interface.
......
......@@ -75,7 +75,7 @@ void QGCXPlaneLink::loadSettings()
settings.beginGroup("QGC_XPLANE_LINK");
setRemoteHost(settings.value("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort)).toString());
setVersion(settings.value("XPLANE_VERSION", 10).toInt());
selectPlane(settings.value("AIRFRAME", "default").toString());
selectAirframe(settings.value("AIRFRAME", "default").toString());
settings.endGroup();
}
......@@ -182,7 +182,6 @@ void QGCXPlaneLink::setRemoteHost(const QString& newHost)
if (newHost.contains(":"))
{
//qDebug() << "HOST: " << newHost.split(":").first();
QHostInfo info = QHostInfo::fromName(newHost.split(":").first());
if (info.error() == QHostInfo::NoError)
{
......@@ -198,7 +197,6 @@ void QGCXPlaneLink::setRemoteHost(const QString& newHost)
}
}
remoteHost = address;
//qDebug() << "Address:" << address.toString();
// Set localPort according to user input
remotePort = newHost.split(":").last().toInt();
}
......@@ -586,7 +584,7 @@ bool QGCXPlaneLink::disconnectSimulation()
return !connectState;
}
void QGCXPlaneLink::selectPlane(const QString& plane)
void QGCXPlaneLink::selectAirframe(const QString& plane)
{
airframeName = plane;
......@@ -718,6 +716,8 @@ void QGCXPlaneLink::setRandomAttitude()
bool QGCXPlaneLink::connectSimulation()
{
qDebug() << "STARTING X-PLANE LINK, CONNECTING TO" << remoteHost << ":" << remotePort;
// XXX Hack
storeSettings();
start(LowPriority);
......@@ -730,9 +730,6 @@ bool QGCXPlaneLink::connectSimulation()
QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(readBytes()));
//process = new QProcess(this);
//terraSync = new QProcess(this);
connect(mav, SIGNAL(hilControlsChanged(uint64_t, float, float, float, float, uint8_t, uint8_t)), this, SLOT(updateControls(uint64_t,float,float,float,float,uint8_t,uint8_t)));
connect(mav, SIGNAL(hilActuatorsChanged(uint64_t, float, float, float, float, float, float, float, float)), this, SLOT(updateActuators(uint64_t,float,float,float,float,float,float,float,float)));
connect(this, SIGNAL(hilStateChanged(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)), mav, SLOT(sendHilState(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)));
......
......@@ -130,7 +130,7 @@ public slots:
* @brief Select airplane model
* @param plane the name of the airplane
*/
void selectPlane(const QString& plane);
void selectAirframe(const QString& airframe);
/**
* @brief Set the airplane position and attitude
* @param lat
......
......@@ -42,7 +42,7 @@ public:
virtual double getParamMin(const QString& param) = 0;
virtual double getParamMax(const QString& param) = 0;
virtual double getParamDefault(const QString& param) = 0;
virtual const QString& getParamInfo(const QString& param) = 0;
virtual QString getParamInfo(const QString& param) = 0;
/** @brief Request an update for the parameter list */
void requestParameterListUpdate(int component = 0);
......
......@@ -97,7 +97,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
paramManager(NULL),
attitudeStamped(false),
lastAttitude(0),
simulation(new QGCXPlaneLink(this)),
simulation(0),
isLocalPositionKnown(false),
isGlobalPositionKnown(false),
systemIsArmed(false),
......@@ -2263,18 +2263,13 @@ void UAS::setParameter(const int component, const QString& id, const QVariant& v
for (unsigned int i = 0; i < sizeof(p.param_id); i++)
{
// String characters
if ((int)i < id.length() && i < (sizeof(p.param_id) - 1))
if ((int)i < id.length())
{
p.param_id[i] = id.toAscii()[i];
}
// // Null termination at end of string or end of buffer
// else if ((int)i == id.length() || i == (sizeof(p.param_id) - 1))
// {
// p.param_id[i] = '\0';
// }
// Zero fill
else
{
// Fill rest with zeros
p.param_id[i] = 0;
}
}
......@@ -2588,14 +2583,24 @@ bool UAS::emergencyKILL()
}
/**
* If enabled, connect the fligth gear link.
* If enabled, connect the flight gear link.
*/
void UAS::enableHilFlightGear(bool enable)
{
void UAS::enableHilFlightGear(bool enable, QString options)
{
QGCFlightGearLink* link = dynamic_cast<QGCFlightGearLink*>(simulation);
if (!link || !simulation) {
// Delete wrong sim
if (simulation) {
stopHil();
delete simulation;
}
simulation = new QGCFlightGearLink(this, options);
}
// Connect Flight Gear Link
link = dynamic_cast<QGCFlightGearLink*>(simulation);
link->setStartupArguments(options);
if (enable)
{
simulation = new QGCFlightGearLink(this);
startHil();
}
else
......@@ -2605,11 +2610,20 @@ void UAS::enableHilFlightGear(bool enable)
}
/**
* If enabled, connect the fligth gear link.
* If enabled, connect the X-plane gear link.
*/
void UAS::enableHilXPlane(bool enable)
{
// Connect Flight Gear Link
QGCXPlaneLink* link = dynamic_cast<QGCXPlaneLink*>(simulation);
if (!link || !simulation) {
if (simulation) {
stopHil();
delete simulation;
}
qDebug() << "CREATED NEW XPLANE LINK";
simulation = new QGCXPlaneLink(this);
}
// Connect X-Plane Link
if (enable)
{
startHil();
......@@ -2679,7 +2693,7 @@ void UAS::startHil()
*/
void UAS::stopHil()
{
simulation->disconnectSimulation();
if (simulation) simulation->disconnectSimulation();
mavlink_message_t msg;
mavlink_msg_set_mode_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), mode & !MAV_MODE_FLAG_HIL_ENABLED, navMode);
sendMessage(msg);
......
......@@ -531,7 +531,7 @@ public slots:
void go();
/** @brief Enable / disable HIL */
void enableHilFlightGear(bool enable);
void enableHilFlightGear(bool enable, QString options);
void enableHilXPlane(bool enable);
......
......@@ -108,8 +108,8 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
laserFix(0),
iruFix(0),
mavInitialized(false),
topMargin(12.0f),
bottomMargin(10.0f),
topMargin(18.0f),
bottomMargin(12.0f),
attControlKnown(false),
xyControlKnown(false),
zControlKnown(false),
......
This diff is collapsed.
......@@ -47,7 +47,7 @@
<number>10</number>
</property>
<widget class="QWidget" name="curveGroupBox" native="true">
<layout class="QGridLayout" name="gridLayout" rowstretch="50,1">
<layout class="QGridLayout" name="gridLayout" rowstretch="50,0">
<property name="leftMargin">
<number>6</number>
</property>
......@@ -103,8 +103,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>202</width>
<height>488</height>
<width>884</width>
<height>491</height>
</rect>
</property>
</widget>
......@@ -164,6 +164,28 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="recolorButton">
<property name="toolTip">
......
......@@ -37,6 +37,7 @@ This file is part of the QGROUNDCONTROL project
#include <QSplashScreen>
#include <QGCHilLink.h>
#include <QGCHilConfiguration.h>
#include <QGCHilFlightGearConfiguration.h>
#include "QGC.h"
#include "MAVLinkSimulationLink.h"
......@@ -643,6 +644,26 @@ void MainWindow::showCentralWidget()
centerStack->setCurrentWidget(widget);
}
void MainWindow::showHILConfigurationWidget(UASInterface* uas)
{
// Add simulation configuration widget
UAS* mav = dynamic_cast<UAS*>(uas);
if (mav)
{
QGCHilConfiguration* hconf = new QGCHilConfiguration(mav, this);
QString hilDockName = tr("HIL Config (%1)").arg(uas->getUASName());
QDockWidget* hilDock = new QDockWidget(hilDockName, this);
hilDock->setWidget(hconf);
hilDock->setObjectName(QString("HIL_CONFIG_%1").arg(uas->getUASID()));
addTool(hilDock, hilDockName, Qt::RightDockWidgetArea);
}
// Reload view state in case new widgets were added
loadViewState();
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if (isVisible()) storeViewState();
......@@ -1424,19 +1445,6 @@ void MainWindow::UASCreated(UASInterface* uas)
if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true);
if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true);
// Add simulation configuration widget
UAS* mav = dynamic_cast<UAS*>(uas);
if (mav)
{
QGCHilConfiguration* hconf = new QGCHilConfiguration(mav->getHILSimulation(), this);
QString hilDockName = tr("HIL Config (%1)").arg(uas->getUASName());
QDockWidget* hilDock = new QDockWidget(hilDockName, this);
hilDock->setWidget(hconf);
hilDock->setObjectName(QString("HIL_CONFIG_%1").arg(uas->getUASID()));
addTool(hilDock, hilDockName, Qt::RightDockWidgetArea);
}
// Reload view state in case new widgets were added
loadViewState();
}
......
......@@ -201,6 +201,9 @@ public slots:
/** @brief Load custom widgets from default file */
void loadCustomWidgetsFromDefaults(const QString& systemType, const QString& autopilotType);
/** @brief Loads and shows the HIL Configuration Widget for the given UAS*/
void showHILConfigurationWidget(UASInterface *uas);
void closeEvent(QCloseEvent* event);
/** @brief Load data view, allowing to plot flight data */
......
#include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h"
#include "QGCXPlaneLink.h"
QGCHilConfiguration::QGCHilConfiguration(QGCHilLink* link, QWidget *parent) :
#include "QGCHilFlightGearConfiguration.h"
#include "QGCHilXPlaneConfiguration.h"
QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
QWidget(parent),
link(link),
mav(mav),
ui(new Ui::QGCHilConfiguration)
{
ui->setupUi(this);
connect(ui->startButton, SIGNAL(clicked(bool)), this, SLOT(toggleSimulation(bool)));
connect(ui->hostComboBox, SIGNAL(activated(QString)), link, SLOT(setRemoteHost(QString)));
connect(link, SIGNAL(remoteChanged(QString)), ui->hostComboBox, SLOT(setEditText(QString)));
connect(link, SIGNAL(statusMessage(QString)), this, SLOT(receiveStatusMessage(QString)));
connect(link, SIGNAL(versionChanged(QString)), ui->simComboBox, SLOT(setEditText(QString)));
connect(ui->simComboBox, SIGNAL(activated(QString)), link, SLOT(setVersion(QString)));
ui->simComboBox->setEditText(link->getVersion());
ui->startButton->setText(tr("Connect"));
QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(link);
if (xplane)
{
connect(ui->randomAttitudeButton, SIGNAL(clicked()), link, SLOT(setRandomAttitude()));
connect(ui->randomPositionButton, SIGNAL(clicked()), link, SLOT(setRandomPosition()));
connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(setAirframe(QString)));
ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex());
}
ui->hostComboBox->clear();
ui->hostComboBox->addItem(link->getRemoteHost());
// connect(ui->)