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->)
}
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
......@@ -39,23 +17,29 @@ void QGCHilConfiguration::receiveStatusMessage(const QString& message)
ui->statusLabel->setText(message);
}
void QGCHilConfiguration::toggleSimulation(bool connect)
QGCHilConfiguration::~QGCHilConfiguration()
{
delete ui;
}
void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
{
Q_UNUSED(connect);
if (!link->isConnected())
if(1 == index)
{
link->setRemoteHost(ui->hostComboBox->currentText());
link->connectSimulation();
ui->startButton->setText(tr("Disconnect"));
// Ensure the sim exists and is disabled
mav->enableHilFlightGear(false, "");
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this);
hfgconf->show();
ui->simulatorConfigurationDockWidget->setWidget(hfgconf);
}
else
else if(2 == index || 3 == index)
{
link->disconnectSimulation();
ui->startButton->setText(tr("Connect"));
}
}
// Ensure the sim exists and is disabled
mav->enableHilXPlane(false);
QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(mav->getHILSimulation(), this);
hxpconf->show();
ui->simulatorConfigurationDockWidget->setWidget(hxpconf);
QGCHilConfiguration::~QGCHilConfiguration()
{
delete ui;
}
}
......@@ -4,6 +4,7 @@
#include <QWidget>
#include "QGCHilLink.h"
#include "UAS.h"
namespace Ui {
class QGCHilConfiguration;
......@@ -14,18 +15,19 @@ class QGCHilConfiguration : public QWidget
Q_OBJECT
public:
QGCHilConfiguration(QGCHilLink* link, QWidget *parent = 0);
QGCHilConfiguration(UAS* mav, QWidget *parent = 0);
~QGCHilConfiguration();
public slots:
/** @brief Start / stop simulation */
void toggleSimulation(bool connect);
/** @brief Receive status message */
void receiveStatusMessage(const QString& message);
protected:
QGCHilLink* link;
UAS* mav;
private slots:
void on_simComboBox_currentIndexChanged(int index);
private:
Ui::QGCHilConfiguration *ui;
};
......
......@@ -7,70 +7,19 @@
<x>0</x>
<y>0</y>
<width>305</width>
<height>261</height>
<height>355</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="40,60,50,50">
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="airframeComboBox">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>X-Plane default</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/MK</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/Ardrone</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/PWM</string>
</property>
</item>
<item>
<property name="text">
<string>Unlimited</string>
</property>
</item>
<item>
<property name="text">
<string>Twinjet</string>
</property>
</item>
<item>
<property name="text">
<string>Early Bird</string>
</property>
</item>
<item>
<property name="text">
<string>Reno Racer</string>
</property>
</item>
<item>
<property name="text">
<string>Slowstick</string>
</property>
</item>
<item>
<property name="text">
<string>Tiny</string>
</property>
</item>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout" columnstretch="40,0,0">
<item row="0" column="0">
<widget class="QLabel" name="simLabel">
<property name="text">
......@@ -78,96 +27,69 @@
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<widget class="QPushButton" name="setHomeButton">
<property name="text">
<string>Set HOME</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="3" column="0">
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Airframe</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<item row="0" column="2">
<widget class="QComboBox" name="simComboBox">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>X-Plane 10</string>
<string/>
</property>
</item>
<item>
<property name="text">
<string>X-Plane 9</string>
<string>Flightgear</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="hostComboBox">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>127.0.0.1:49000</string>
<string>X-Plane 10</string>
</property>
</item>
<item>
<property name="text">
<string>X-Plane 9</string>
</property>
</item>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QPushButton" name="randomPositionButton">
<property name="text">
<string>Random POS</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="randomAttitudeButton">
<property name="text">
<string>Random ATT</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="hostLabel">
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="startButton">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="2" column="0" colspan="3">
<widget class="QDockWidget" name="simulatorConfigurationDockWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<property name="minimumSize">
<size>
<width>20</width>
<height>40</height>
<height>150</height>
</size>
</property>
</spacer>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Simulator Options</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
......
#include "QGCHilFlightGearConfiguration.h"
#include "ui_QGCHilFlightGearConfiguration.h"
#include "MainWindow.h"
QGCHilFlightGearConfiguration::QGCHilFlightGearConfiguration(UAS* mav,QWidget *parent) :
QWidget(parent),
mav(mav),
ui(new Ui::QGCHilFlightGearConfiguration)
{
ui->setupUi(this);
QStringList items = QStringList();
if (mav->getSystemType() == MAV_TYPE_FIXED_WING)
{
items << "Rascal110-JSBSim";
items << "c172p";
items << "YardStik";
items << "Malolo1";
}
else if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
{
items << "arducopter";
}
else
{
items << "<aircraft>";
}
ui->aircraftComboBox->addItems(items);
}
QGCHilFlightGearConfiguration::~QGCHilFlightGearConfiguration()
{
delete ui;
}
void QGCHilFlightGearConfiguration::on_startButton_clicked()
{
//XXX check validity of inputs
QString options = ui->optionsPlainTextEdit->toPlainText();
options.append(" --aircraft=" + ui->aircraftComboBox->currentText());
mav->enableHilFlightGear(true, options);
}
#ifndef QGCHILFLIGHTGEARCONFIGURATION_H
#define QGCHILFLIGHTGEARCONFIGURATION_H
#include <QWidget>
#include "QGCHilLink.h"
#include "QGCFlightGearLink.h"
#include "UAS.h"
namespace Ui {
class QGCHilFlightGearConfiguration;
}
class QGCHilFlightGearConfiguration : public QWidget
{
Q_OBJECT
public:
explicit QGCHilFlightGearConfiguration(UAS* mav, QWidget *parent = 0);
~QGCHilFlightGearConfiguration();
protected:
UAS* mav;
private slots:
void on_startButton_clicked();
private:
Ui::QGCHilFlightGearConfiguration *ui;
};
#endif // QGCHILFLIGHTGEARCONFIGURATION_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCHilFlightGearConfiguration</class>
<widget class="QWidget" name="QGCHilFlightGearConfiguration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>246</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout" rowminimumheight="0,0,0,0,0,0">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="5" column="0">
<widget class="QPushButton" name="startButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="aircraftPlaintextInfoLabel">
<property name="text">
<string>Airframe:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="aircraftComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="optionsLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Additional Options:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPlainTextEdit" name="optionsPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="plainText">
<string>--in-air --roll=0 --pitch=0 --vc=90 --heading=300 --timeofday=noon --disable-hud-3d --disable-fullscreen --geometry=400x300 --disable-anti-alias-hud --wind=0@0 --turbulence=0.0 --prop:/sim/frame-rate-throttle-hz=30 --control=mouse --disable-intro-music --disable-sound --disable-random-objects --disable-ai-models --shading-flat --fog-disable --disable-specular-highlight --disable-random-objects --disable-panel --disable-clouds --fdm=jsb --units-meters --notrim --prop:/engines/engine/running=true</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "QGCHilXPlaneConfiguration.h"
#include "ui_QGCHilXPlaneConfiguration.h"
#include "QGCXPlaneLink.h"
QGCHilXPlaneConfiguration::QGCHilXPlaneConfiguration(QGCHilLink* link, QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCHilXPlaneConfiguration)
{
ui->setupUi(this);
this->link = link;
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)), parent, SLOT(receiveStatusMessage(QString)));
// connect(mav->getHILSimulation(), SIGNAL(statusMessage(QString)), this, SLOT(receiveStatusMessage(QString)));
// connect(ui->simComboBox, SIGNAL(activated(QString)), mav->getHILSimulation(), SLOT(setVersion(QString)));
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(selectAirframe(QString)));
ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex());
}
ui->hostComboBox->clear();
ui->hostComboBox->addItem(link->getRemoteHost());
}
void QGCHilXPlaneConfiguration::toggleSimulation(bool connect)
{
Q_UNUSED(connect);
if (!link->isConnected())
{
link->setRemoteHost(ui->hostComboBox->currentText());
link->connectSimulation();
ui->startButton->setText(tr("Disconnect"));
}
else
{
link->disconnectSimulation();
ui->startButton->setText(tr("Connect"));
}
}
QGCHilXPlaneConfiguration::~QGCHilXPlaneConfiguration()
{
delete ui;
}
#ifndef QGCHILXPLANECONFIGURATION_H
#define QGCHILXPLANECONFIGURATION_H
#include <QWidget>
#include "QGCHilLink.h"
namespace Ui {
class QGCHilXPlaneConfiguration;
}
class QGCHilXPlaneConfiguration : public QWidget
{
Q_OBJECT
public:
explicit QGCHilXPlaneConfiguration(QGCHilLink* link, QWidget *parent = 0);
~QGCHilXPlaneConfiguration();
public slots:
/** @brief Start / stop simulation */
void toggleSimulation(bool connect);
protected:
QGCHilLink* link;
private:
Ui::QGCHilXPlaneConfiguration *ui;
};
#endif // QGCHILXPLANECONFIGURATION_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCHilXPlaneConfiguration</class>
<widget class="QWidget" name="QGCHilXPlaneConfiguration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>243</width>
<height>261</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="40,0,0,0">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Airframe</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="airframeComboBox">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>X-Plane default</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/MK</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/Ardrone</string>
</property>
</item>
<item>
<property name="text">
<string>QRO_X/PWM</string>
</property>
</item>
<item>
<property name="text">
<string>Unlimited</string>
</property>
</item>
<item>
<property name="text">
<string>Twinjet</string>
</property>
</item>
<item>
<property name="text">
<string>Early Bird</string>
</property>
</item>
<item>
<property name="text">
<string>Reno Racer</string>
</property>
</item>
<item>
<property name="text">
<string>Slowstick</string>
</property>
</item>
<item>
<property name="text">
<string>Tiny</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QPushButton" name="setHomeButton">
<property name="text">
<string>Set HOME</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="hostComboBox">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>127.0.0.1:49000</string>
</property>
</item>
</widget>
</item>
<item row="5" column="2" colspan="2">
<widget class="QPushButton" name="randomPositionButton">
<property name="text">
<string>Random POS</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="randomAttitudeButton">
<property name="text">
<string>Random ATT</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="hostLabel">
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="startButton">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="6" 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>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -57,7 +57,7 @@ public:
double getParamMin(const QString& param) { return paramMin.value(param, 0.0f); }
double getParamMax(const QString& param) { return paramMax.value(param, 0.0f); }
double getParamDefault(const QString& param) { return paramDefault.value(param, 0.0f); }
const QString& getParamInfo(const QString& param) { return paramToolTips.value(param, ""); }
QString getParamInfo(const QString& param) { return paramToolTips.value(param, ""); }
signals:
/** @brief A parameter was changed in the widget, NOT onboard */
......
......@@ -54,7 +54,7 @@ QGCToolBar::QGCToolBar(QWidget *parent) :
// Add internal actions
// Add MAV widget
symbolButton = new QToolButton(this);
symbolButton->setStyleSheet("QWidget { background-color: #050508; color: #DDDDDF; background-clip: border; } QToolButton { font-weight: bold; font-size: 12px; border: 0px solid #999999; border-radius: 5px; min-width:22px; max-width: 22px; min-height: 22px; max-height: 22px; padding: 0px; margin: 0px 0px 0px 20px; background-color: none; }");
symbolButton->setStyleSheet("QWidget { background-color: #050508; color: #DDDDDF; background-clip: border; }");
addWidget(symbolButton);
toolBarNameLabel = new QLabel("------", this);
......@@ -226,39 +226,6 @@ void QGCToolBar::logging(bool checked)
void QGCToolBar::addPerspectiveChangeAction(QAction* action)
{
insertAction(toggleLoggingAction, action);
// Set tab style
QWidget* widget = widgetForAction(action);
widget->setStyleSheet("\
* { font-weight: bold; min-height: 16px; min-width: 24px; \
border-top: 1px solid #BBBBBB; \
border-bottom: 0px; \
border-left: 1px solid #BBBBBB; \
border-right: 1px solid #BBBBBB; \
border-top-left-radius: 5px; \
border-top-right-radius: 5px; \
border-bottom-left-radius: 0px; \
border-bottom-right-radius: 0px; \
max-height: 22px; \
margin-top: 4px; \
margin-left: 2px; \
margin-bottom: 0px; \
margin-right: 2px; \
background-color: #222222; \
} \
*:checked { \
background-color: #000000; \
border-top: 2px solid #379AC3; \
border-bottom: 0px; \
border-left: 2px solid #379AC3; \
border-right: 2px solid #379AC3; \
} \
*:pressed { \
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bbbbbb, stop: 1 #b0b0b0); \
border-top: 2px solid #379AC3; \
border-bottom: 0px; \
border-left: 2px solid #379AC3; \
border-right: 2px solid #379AC3; }");
}
void QGCToolBar::setActiveUAS(UASInterface* active)
......@@ -322,6 +289,8 @@ void QGCToolBar::updateArmingState(bool armed)
{
systemArmed = armed;
changed = true;
/* important, immediately update */
updateView();
}
void QGCToolBar::updateView()
......@@ -377,6 +346,8 @@ void QGCToolBar::updateState(UASInterface* system, QString name, QString descrip
Q_UNUSED(description);
if (state != name) changed = true;
state = name;
/* important, immediately update */
updateView();
}
void QGCToolBar::updateMode(int system, QString name, QString description)
......@@ -385,11 +356,16 @@ void QGCToolBar::updateMode(int system, QString name, QString description)
Q_UNUSED(description);
if (mode != name) changed = true;
mode = name;
/* important, immediately update */
updateView();
}
void QGCToolBar::updateName(const QString& name)
{
if (systemName != name) changed = true;
if (systemName != name)
{
changed = true;
}
systemName = name;
}
......
......@@ -191,10 +191,10 @@ void QGCVehicleConfig::writeCalibrationRC()
for (unsigned int i = 0; i < chanMax; ++i)
{
mav->setParameter(0, minTpl.arg(i), rcMin[i]);
mav->setParameter(0, trimTpl.arg(i), rcTrim[i]);
mav->setParameter(0, maxTpl.arg(i), rcMax[i]);
mav->setParameter(0, revTpl.arg(i), (rcRev[i]) ? -1 : 1);
mav->setParameter(0, minTpl.arg(i+1), rcMin[i]);
mav->setParameter(0, trimTpl.arg(i+1), rcTrim[i]);
mav->setParameter(0, maxTpl.arg(i+1), rcMax[i]);
mav->setParameter(0, revTpl.arg(i+1), (rcRev[i]) ? -1 : 1);
}
// Write mappings
......@@ -222,13 +222,13 @@ void QGCVehicleConfig::requestCalibrationRC()
for (unsigned int i = 0; i < chanMax; ++i)
{
mav->requestParameter(0, minTpl.arg(i));
mav->requestParameter(0, minTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, trimTpl.arg(i));
mav->requestParameter(0, trimTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, maxTpl.arg(i));
mav->requestParameter(0, maxTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, revTpl.arg(i));
mav->requestParameter(0, revTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
}
}
......@@ -379,7 +379,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if (minTpl.exactMatch(parameterName)) {
bool ok;
unsigned int index = parameterName.mid(2, 1).toInt(&ok);
unsigned int index = parameterName.mid(2, 1).toInt(&ok) - 1;
if (ok && (index > 0) && (index < chanMax))
{
rcMin[index] = value.toInt();
......@@ -388,7 +388,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if (maxTpl.exactMatch(parameterName)) {
bool ok;
unsigned int index = parameterName.mid(2, 1).toInt(&ok);
unsigned int index = parameterName.mid(2, 1).toInt(&ok) - 1;
if (ok && (index > 0) && (index < chanMax))
{
rcMax[index] = value.toInt();
......@@ -397,7 +397,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if (trimTpl.exactMatch(parameterName)) {
bool ok;
unsigned int index = parameterName.mid(2, 1).toInt(&ok);
unsigned int index = parameterName.mid(2, 1).toInt(&ok) - 1;
if (ok && (index > 0) && (index < chanMax))
{
rcTrim[index] = value.toInt();
......@@ -406,7 +406,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if (revTpl.exactMatch(parameterName)) {
bool ok;
unsigned int index = parameterName.mid(2, 1).toInt(&ok);
unsigned int index = parameterName.mid(2, 1).toInt(&ok) - 1;
if (ok && (index > 0) && (index < chanMax))
{
rcRev[index] = (value.toInt() == -1) ? true : false;
......
This diff is collapsed.
......@@ -50,8 +50,6 @@ This file is part of the QGROUNDCONTROL project
#include "SwitchCalibrator.h"
#include "CurveCalibrator.h"
#include "../../../mavlink/include/mavlink/v1.0/common/mavlink.h"
#include "../../../mavlink/include/mavlink/v1.0/mavlink_types.h"
#include "UAS.h"
#include "UASManager.h"
#include "RadioCalibrationData.h"
......
......@@ -2,6 +2,7 @@
#include <QContextMenuEvent>
#include <QSettings>
#include <QTimer>
#include <QToolTip>
#include "QGCParamSlider.h"
#include "ui_QGCParamSlider.h"
......@@ -53,7 +54,8 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
connect(ui->readButton, SIGNAL(clicked()), this, SLOT(requestParameter()));
connect(ui->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParamList()));
connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(showInfo(bool)));
// connect to self
connect(ui->infoLabel, SIGNAL(released()), this, SLOT(showTooltip()));
// Set the current UAS if present
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
}
......@@ -63,6 +65,17 @@ QGCParamSlider::~QGCParamSlider()
delete ui;
}
void QGCParamSlider::showTooltip()
{
QWidget* sender = dynamic_cast<QWidget*>(QObject::sender());
if (sender)
{
QPoint point = mapToGlobal(pos());
QToolTip::showText(point, sender->toolTip());
}
}
void QGCParamSlider::refreshParamList()
{
ui->editSelectParamComboBox->setEnabled(true);
......@@ -70,6 +83,7 @@ void QGCParamSlider::refreshParamList()
if (uas)
{
uas->getParamManager()->requestParameterList();
ui->editStatusLabel->setText(tr("Parameter list updating.."));
}
}
......@@ -89,7 +103,7 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
requestParameter();
// Set param info
QString text = uas->getParamManager()->getParamInfo(parameterName);
ui->infoLabel->setText(text);
ui->infoLabel->setToolTip(text);
// Force-uncheck and hide label if no description is available
if (ui->editInfoCheckBox->isChecked())
{
......@@ -345,6 +359,11 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i
}
ui->valueSlider->setValue(floatToScaledInt(value.toDouble()));
}
if (paramIndex == paramCount - 1)
{
ui->editStatusLabel->setText(tr("Complete parameter list received."));
}
}
void QGCParamSlider::changeEvent(QEvent *e)
......
......@@ -41,6 +41,8 @@ public slots:
void setParamValue(int value);
/** @brief Show descriptive text next to slider */
void showInfo(bool enable);
/** @brief Show tool tip of calling element */
void showTooltip();
protected slots:
/** @brief Request the parameter of this widget from the MAV */
......
This diff is collapsed.
......@@ -40,6 +40,7 @@ This file is part of the PIXHAWK project
#include "UASWaypointManager.h"
#include "MainWindow.h"
#include "ui_UASView.h"
#include <QGCHilFlightGearConfiguration.h>
UASView::UASView(UASInterface* uas, QWidget *parent) :
QWidget(parent),
......@@ -68,8 +69,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
removeAction(new QAction("Delete this system", this)),
renameAction(new QAction("Rename..", this)),
selectAction(new QAction("Control this system", this )),
hilAction(new QAction("Enable Flightgear Hardware-in-the-Loop Simulation", this )),
hilXAction(new QAction("Enable X-Plane Hardware-in-the-Loop Simulation", this )),
hilAction(new QAction("HIL - Hardware in the Loop", this )),
selectAirframeAction(new QAction("Choose Airframe", this)),
setBatterySpecsAction(new QAction("Set Battery Options", this)),
lowPowerModeEnabled(true),
......@@ -81,9 +81,6 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
lowPowerModeEnabled = MainWindow::instance()->lowPowerModeEnabled();
hilAction->setCheckable(true);
// Flightgear is not ready for prime time
//hilAction->setEnabled(false);
hilXAction->setCheckable(true);
m_ui->setupUi(this);
......@@ -122,8 +119,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
connect(removeAction, SIGNAL(triggered()), this, SLOT(deleteLater()));
connect(renameAction, SIGNAL(triggered()), this, SLOT(rename()));
connect(selectAction, SIGNAL(triggered()), uas, SLOT(setSelected()));
connect(hilAction, SIGNAL(triggered(bool)), uas, SLOT(enableHilFlightGear(bool)));
connect(hilXAction, SIGNAL(triggered(bool)), uas, SLOT(enableHilXPlane(bool)));
connect(hilAction, SIGNAL(triggered(bool)), this, SLOT(showHILUi()));
connect(selectAirframeAction, SIGNAL(triggered()), this, SLOT(selectAirframe()));
connect(setBatterySpecsAction, SIGNAL(triggered()), this, SLOT(setBatterySpecs()));
connect(uas, SIGNAL(systemRemoved()), this, SLOT(deleteLater()));
......@@ -504,8 +500,6 @@ void UASView::contextMenuEvent (QContextMenuEvent* event)
menu.addAction(removeAction);
}
menu.addAction(hilAction);
menu.addAction(hilXAction);
// XXX Re-enable later menu.addAction(hilXAction);
menu.addAction(selectAirframeAction);
menu.addAction(setBatterySpecsAction);
menu.exec(event->globalPos());
......@@ -566,6 +560,11 @@ void UASView::selectAirframe()
}
}
void UASView::showHILUi()
{
MainWindow::instance()->showHILConfigurationWidget(uas);
}
void UASView::refresh()
{
//setUpdatesEnabled(false);
......
......@@ -64,6 +64,7 @@ public slots:
void updateMode(int sysId, QString status, QString description);
void updateLoad(UASInterface* uas, double load);
//void receiveValue(int uasid, QString id, double value, quint64 time);
void showHILUi();
void refresh();
/** @brief Receive new waypoint information */
void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current);
......
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