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),
......
......@@ -70,7 +70,7 @@ HUD::HUD(int width, int height, QWidget* parent)
yCenterOffset(0.0f),
vwidth(200.0f),
vheight(150.0f),
vGaugeSpacing(50.0f),
vGaugeSpacing(65.0f),
vPitchPerDeg(6.0f), ///< 4 mm y translation per degree)
rawBuffer1(NULL),
rawBuffer2(NULL),
......@@ -335,7 +335,7 @@ void HUD::updateAttitude(UASInterface* uas, int component, double roll, double p
void HUD::updateBattery(UASInterface* uas, double voltage, double percent, int seconds)
{
Q_UNUSED(uas);
fuelStatus = tr("BAT [%1% | %2V] (%3:%4)").arg(percent, 2, 'f', 0, QChar('0')).arg(voltage, 4, 'f', 1, QChar('0')).arg(seconds/60, 2, 10, QChar('0')).arg(seconds%60, 2, 10, QChar('0'));
fuelStatus = tr("BAT [%1% | %2V]").arg(percent, 2, 'f', 0, QChar('0')).arg(voltage, 4, 'f', 1, QChar('0'));
if (percent < 20.0f) {
fuelColor = warningColor;
} else if (percent < 10.0f) {
......@@ -622,7 +622,7 @@ void HUD::paintHUD()
// Low-pass roll, pitch and yaw
rollLP = roll;//rollLP * 0.2f + 0.8f * roll;
pitchLP = pitch;//pitchLP * 0.2f + 0.8f * pitch;
yawLP = yaw;//yawLP * 0.2f + 0.8f * yaw;
yawLP = (!isinf(yaw) && !isnan(yaw)) ? yaw : yawLP;//yawLP * 0.2f + 0.8f * yaw;
// Translate for yaw
const float maxYawTrans = 60.0f;
......@@ -650,6 +650,8 @@ void HUD::paintHUD()
// Negate to correct direction
yawTrans = -yawTrans;
yawTrans = 0;
//qDebug() << "yaw translation" << yawTrans << "integral" << yawInt << "difference" << yawDiff << "yaw" << yaw;
// Update scaling factor
......@@ -714,20 +716,20 @@ void HUD::paintHUD()
painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
painter.translate((this->vwidth/2.0+xCenterOffset)*scalingFactor, (this->vheight/2.0+yCenterOffset)*scalingFactor);
// COORDINATE FRAME IS NOW (0,0) at CENTER OF WIDGET
// Draw all fixed indicators
// MODE
paintText(mode, infoColor, 2.0f, (-vwidth/2.0) + 10, -vheight/2.0 + 10, &painter);
// STATE
paintText(state, infoColor, 2.0f, (-vwidth/2.0) + 10, -vheight/2.0 + 15, &painter);
// BATTERY
paintText(fuelStatus, fuelColor, 2.0f, (-vwidth/2.0) + 10, -vheight/2.0 + 20, &painter);
paintText(fuelStatus, fuelColor, 6.0f, (-vwidth/2.0) + 10, -vheight/2.0 + 6, &painter);
// Waypoint
paintText(waypointName, defaultColor, 2.0f, (-vwidth/3.0) + 10, +vheight/3.0 + 15, &painter);
paintText(waypointName, defaultColor, 6.0f, (-vwidth/3.0) + 10, +vheight/3.0 + 15, &painter);
QPen linePen(Qt::SolidLine);
linePen.setWidth(refLineWidthToPen(1.0f));
linePen.setColor(defaultColor);
painter.setBrush(Qt::NoBrush);
painter.setPen(linePen);
// YAW INDICATOR
//
......@@ -735,15 +737,15 @@ void HUD::paintHUD()
// . .
// .......
//
const float yawIndicatorWidth = 4.0f;
const float yawIndicatorY = vheight/2.0f - 10.0f;
const float yawIndicatorWidth = 12.0f;
const float yawIndicatorY = vheight/2.0f - 15.0f;
QPolygon yawIndicator(4);
yawIndicator.setPoint(0, QPoint(refToScreenX(0.0f), refToScreenY(yawIndicatorY)));
yawIndicator.setPoint(1, QPoint(refToScreenX(yawIndicatorWidth/2.0f), refToScreenY(yawIndicatorY+yawIndicatorWidth)));
yawIndicator.setPoint(2, QPoint(refToScreenX(-yawIndicatorWidth/2.0f), refToScreenY(yawIndicatorY+yawIndicatorWidth)));
yawIndicator.setPoint(3, QPoint(refToScreenX(0.0f), refToScreenY(yawIndicatorY)));
painter.setPen(defaultColor);
painter.drawPolyline(yawIndicator);
painter.setPen(linePen);
// CENTER
......@@ -752,7 +754,7 @@ void HUD::paintHUD()
// __ __
// \/\/
//
const float hIndicatorWidth = 7.0f;
const float hIndicatorWidth = 20.0f;
const float hIndicatorY = -25.0f;
const float hIndicatorYLow = hIndicatorY + hIndicatorWidth / 6.0f;
const float hIndicatorSegmentWidth = hIndicatorWidth / 7.0f;
......@@ -764,18 +766,15 @@ void HUD::paintHUD()
hIndicator.setPoint(4, QPoint(refToScreenX(0.0f+hIndicatorSegmentWidth*1.0f), refToScreenY(hIndicatorYLow)));
hIndicator.setPoint(5, QPoint(refToScreenX(0.0f+hIndicatorWidth/2.0f-hIndicatorSegmentWidth*1.75f), refToScreenY(hIndicatorY)));
hIndicator.setPoint(6, QPoint(refToScreenX(0.0f+hIndicatorWidth/2.0f), refToScreenY(hIndicatorY)));
painter.setPen(defaultColor);
painter.drawPolyline(hIndicator);
// SETPOINT
const float centerWidth = 4.0f;
painter.setPen(defaultColor);
painter.setBrush(Qt::NoBrush);
const float centerWidth = 8.0f;
// TODO
//painter.drawEllipse(QPointF(refToScreenX(qMin(10.0f, values.value("roll desired", 0.0f) * 10.0f)), refToScreenY(qMin(10.0f, values.value("pitch desired", 0.0f) * 10.0f))), refToScreenX(centerWidth/2.0f), refToScreenX(centerWidth/2.0f));
const float centerCrossWidth = 10.0f;
const float centerCrossWidth = 20.0f;
// left
painter.drawLine(QPointF(refToScreenX(-centerWidth / 2.0f), refToScreenY(0.0f)), QPointF(refToScreenX(-centerCrossWidth / 2.0f), refToScreenY(0.0f)));
// right
......@@ -786,12 +785,11 @@ void HUD::paintHUD()
// COMPASS
const float compassY = -vheight/2.0f + 10.0f;
QRectF compassRect(QPointF(refToScreenX(-5.0f), refToScreenY(compassY)), QSizeF(refToScreenX(10.0f), refToScreenY(5.0f)));
const float compassY = -vheight/2.0f + 6.0f;
QRectF compassRect(QPointF(refToScreenX(-12.0f), refToScreenY(compassY)), QSizeF(refToScreenX(24.0f), refToScreenY(12.0f)));
painter.setBrush(Qt::NoBrush);
painter.setPen(Qt::SolidLine);
painter.setPen(defaultColor);
painter.drawRoundedRect(compassRect, 2, 2);
painter.setPen(linePen);
painter.drawRoundedRect(compassRect, 3, 3);
QString yawAngle;
// const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f;
......@@ -803,13 +801,16 @@ void HUD::paintHUD()
/* final safeguard for really stupid systems */
int yawCompass = static_cast<int>(yawDeg) % 360;
yawAngle.sprintf("%03d", yawCompass);
paintText(yawAngle, defaultColor, 3.5f, -4.3f, compassY+ 0.97f, &painter);
paintText(yawAngle, defaultColor,8.5f, -9.8f, compassY+ 1.7f, &painter);
painter.setBrush(Qt::NoBrush);
painter.setPen(linePen);
// CHANGE RATE STRIPS
drawChangeRateStrip(-51.0f, -50.0f, 15.0f, -1.0f, 1.0f, -zSpeed, &painter);
drawChangeRateStrip(-65.0f, -60.0f, 25.0f, -10.0f, 10.0f, -zSpeed, &painter);
// CHANGE RATE STRIPS
drawChangeRateStrip(49.0f, -50.0f, 15.0f, -1.0f, 1.0f, totalAcc, &painter);
drawChangeRateStrip(65.0f, -60.0f, 25.0f, -10.0f, 10.0f, totalAcc, &painter);
// GAUGES
......@@ -822,10 +823,15 @@ void HUD::paintHUD()
gaugeAltitude = -zPos;
}
drawChangeIndicatorGauge(-vGaugeSpacing, -15.0f, 10.0f, 2.0f, gaugeAltitude, defaultColor, &painter, false);
painter.setBrush(Qt::NoBrush);
painter.setPen(linePen);
drawChangeIndicatorGauge(-vGaugeSpacing, 35.0f, 30.0f, 10.0f, gaugeAltitude, defaultColor, &painter, false);
paintText("alt m", defaultColor, 5.5f, -73.0f, 50, &painter);
// Right speed gauge
drawChangeIndicatorGauge(vGaugeSpacing, -15.0f, 10.0f, 5.0f, totalSpeed, defaultColor, &painter, false);
drawChangeIndicatorGauge(vGaugeSpacing, 35.0f, 30.0f, 10.0f, totalSpeed, defaultColor, &painter, false);
paintText("v m/s", defaultColor, 5.5f, 55.0f, 50, &painter);
// Waypoint name
......@@ -961,8 +967,8 @@ void HUD::paintPitchLinePos(QString text, float refPosX, float refPosY, QPainter
const float pitchWidth = 30.0f;
const float pitchGap = pitchWidth / 2.5f;
const float pitchHeight = pitchWidth / 12.0f;
const float textSize = pitchHeight * 1.1f;
const float lineWidth = 0.5f;
const float textSize = pitchHeight * 1.6f;
const float lineWidth = 1.5f;
// Positive pitch indicator:
//
......@@ -975,7 +981,7 @@ void HUD::paintPitchLinePos(QString text, float refPosX, float refPosY, QPainter
// Left horizontal line
drawLine(refPosX-pitchWidth/2.0f, refPosY, refPosX-pitchGap/2.0f, refPosY, lineWidth, defaultColor, painter);
// Text left
paintText(text, defaultColor, textSize, refPosX-pitchWidth/2.0 + 0.75f, refPosY + pitchHeight - 1.75f, painter);
paintText(text, defaultColor, textSize, refPosX-pitchWidth/2.0 + 0.75f, refPosY + pitchHeight - 1.3f, painter);
// Right vertical line
drawLine(refPosX+pitchWidth/2.0f, refPosY, refPosX+pitchWidth/2.0f, refPosY+pitchHeight, lineWidth, defaultColor, painter);
......@@ -988,10 +994,10 @@ void HUD::paintPitchLineNeg(QString text, float refPosX, float refPosY, QPainter
const float pitchWidth = 30.0f;
const float pitchGap = pitchWidth / 2.5f;
const float pitchHeight = pitchWidth / 12.0f;
const float textSize = pitchHeight * 1.1f;
const float textSize = pitchHeight * 1.6f;
const float segmentWidth = ((pitchWidth - pitchGap)/2.0f) / 7.0f; ///< Four lines and three gaps -> 7 segments
const float lineWidth = 0.1f;
const float lineWidth = 1.5f;
// Negative pitch indicator:
//
......@@ -1007,7 +1013,7 @@ void HUD::paintPitchLineNeg(QString text, float refPosX, float refPosY, QPainter
drawLine(refPosX-pitchWidth/2.0+(i*segmentWidth), refPosY, refPosX-pitchWidth/2.0+(i*segmentWidth)+segmentWidth, refPosY, lineWidth, defaultColor, painter);
}
// Text left
paintText(text, defaultColor, textSize, refPosX-pitchWidth/2.0f + 0.75f, refPosY + pitchHeight - 1.75f, painter);
paintText(text, defaultColor, textSize, refPosX-pitchWidth/2.0f + 0.75f, refPosY + pitchHeight - 1.3f, painter);
// Right vertical line
drawLine(refPosX+pitchGap/2.0, refPosY, refPosX+pitchGap/2.0, refPosY-pitchHeight, lineWidth, defaultColor, painter);
......@@ -1080,13 +1086,6 @@ void HUD::drawPolygon(QPolygonF refPolygon, QPainter* painter)
void HUD::drawChangeRateStrip(float xRef, float yRef, float height, float minRate, float maxRate, float value, QPainter* painter)
{
QBrush brush(defaultColor, Qt::NoBrush);
painter->setBrush(brush);
QPen rectPen(Qt::SolidLine);
rectPen.setWidth(0);
rectPen.setColor(defaultColor);
painter->setPen(rectPen);
float scaledValue = value;
// Saturate value
......@@ -1105,7 +1104,7 @@ void HUD::drawChangeRateStrip(float xRef, float yRef, float height, float minRat
// -
const float width = height / 8.0f;
const float lineWidth = 0.5f;
const float lineWidth = 1.5f;
// Indicator lines
// Top horizontal line
......@@ -1120,7 +1119,7 @@ void HUD::drawChangeRateStrip(float xRef, float yRef, float height, float minRat
// Text
QString label;
label.sprintf("< %+06.2f", value);
paintText(label, defaultColor, 3.0f, xRef+width/2.0f, yRef+height-((scaledValue - minRate)/(maxRate-minRate))*height - 1.6f, painter);
paintText(label, defaultColor, 6.0f, xRef+width/2.0f, yRef+height-((scaledValue - minRate)/(maxRate-minRate))*height - 1.6f, painter);
}
//void HUD::drawSystemIndicator(float xRef, float yRef, int maxNum, float maxWidth, float maxHeight, QPainter* painter)
......@@ -1205,17 +1204,19 @@ void HUD::drawChangeIndicatorGauge(float xRef, float yRef, float radius, float e
// Draw the circle
QPen circlePen(Qt::SolidLine);
if (!solid) circlePen.setStyle(Qt::DotLine);
circlePen.setWidth(refLineWidthToPen(0.5f));
circlePen.setColor(defaultColor);
circlePen.setWidth(refLineWidthToPen(2.0f));
painter->setBrush(Qt::NoBrush);
painter->setPen(circlePen);
drawCircle(xRef, yRef, radius, 200.0f, 170.0f, 1.0f, color, painter);
drawCircle(xRef, yRef, radius, 200.0f, 170.0f, 1.5f, color, painter);
QString label;
label.sprintf("%05.1f", value);
float textSize = radius / 2.5;
// Draw the value
paintText(label, color, 4.5f, xRef-7.5f, yRef-2.0f, painter);
paintText(label, color, textSize, xRef-textSize*1.7f, yRef-textSize*0.4f, painter);
// Draw the needle
// Scale the rotation so that the gauge does one revolution
......
......@@ -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;
......
......@@ -40,13 +40,16 @@
<item row="0" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="rcTab">
<attribute name="title">
<string>RC Calibration</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5" columnstretch="1,1,10,1,1,10,1,1,1,1,1,1,1,1,10">
<property name="topMargin">
<number>20</number>
</property>
<item row="8" column="1" rowspan="3">
<widget class="QSlider" name="throttleSlider">
<property name="minimum">
......@@ -716,10 +719,26 @@
<string>Sensor Calibration</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6" columnstretch="70,30">
<property name="topMargin">
<number>20</number>
</property>
<item row="0" column="1">
<layout class="QVBoxLayout" name="sensorLayout"/>
</item>
<item row="0" column="0">
<item row="1" column="1">
<spacer name="verticalSpacer_8">
<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="0" rowspan="2">
<widget class="QTextBrowser" name="sensorTips">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
......@@ -732,7 +751,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Magnetometer Calibration&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Carefully follow the instructions. Click on MAG to start the calibration. Watch the communication console for further instructions (Available through Main Menu -&amp;gt; Tool Widgets -&amp;gt; Communication Console). Do not calibrate the vehicle in vincinity of metal, e.g. from a table or chair. Start the calibration, leave the system unmoved on the table. Wait for the double beep. Next move the system in a figure eight, roll and pitch it strongly and perform the figure eight also upside-down. The calibration is finished after the triple beep.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Carefully follow the instructions. Click on MAG to start the calibration. Watch the communication console for further instructions (Available through Main Menu -&amp;gt; Tool Widgets -&amp;gt; Communication Console). Do not calibrate the vehicle in vincinity of metal, e.g. from a table or chair. Start the calibration, leave the system unmoved on the table. Wait for the double beep. Next move the system in a figure eight, roll and pitch it strongly, rotate around all axes and perform the figure eight also upside-down. The calibration is finished after the triple beep.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Accelerometer Calibration&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
......@@ -746,71 +765,106 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="multirotorTab">
<attribute name="title">
<string>Multirotor Control</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QComboBox" name="multiRotorComboBox"/>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_3" columnstretch="80,0,0">
<property name="topMargin">
<number>20</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="loadMultiRotorDefaultsButton">
<property name="text">
<string>Load Platform Defaults</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QWidget" name="multiRotorControlWidget" native="true">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="1">
<widget class="QGroupBox" name="multiRotorControlPositionGroupBox">
<property name="title">
<string>Position</string>
<item row="0" column="0">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="multiRotorComboBox"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="multiRotorControlPositionGroupBox">
<property name="title">
<string>Position</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="multiRotorPositionLayout"/>
</item>
</layout>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>203</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="multiRotorPositionLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="multiRotorControlAttitudeGroupBox">
<property name="title">
<string>Attitude</string>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="multiRotorControlAttitudeGroupBox">
<property name="title">
<string>Attitude</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="margin">
<number>0</number>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>204</height>
</rect>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>417</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="multiRotorAttitudeLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="multiRotorAttitudeLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......@@ -822,37 +876,103 @@ p, li { white-space: pre-wrap; }
<attribute name="title">
<string>Fixed Wing Control</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="fixedWingControlAttitudeGroupBox">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="65,30,19,1">
<property name="topMargin">
<number>20</number>
</property>
<item row="3" column="0" colspan="4">
<widget class="QGroupBox" name="fixedWingControlPositionGroupBox">
<property name="title">
<string>Attitude</string>
<string>Position</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="fixedWingAttitudeLayout"/>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>203</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="fixedWingPositionLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<item row="0" column="1">
<widget class="QComboBox" name="fixedWingComboBox"/>
</item>
<item row="0" column="1">
<item row="0" column="2" colspan="2">
<widget class="QPushButton" name="loadFixedWingDefaultsButton">
<property name="text">
<string>Load Platform Defaults</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="fixedWingControlPositionGroupBox">
<item row="0" column="0">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="fixedWingControlAttitudeGroupBox">
<property name="title">
<string>Position</string>
<string>Attitude</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="fixedWingPositionLayout"/>
<widget class="QScrollArea" name="scrollArea_4">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>204</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="fixedWingAttitudeLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
......
......@@ -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 */
......
......@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="10,0,0,0,0,0,0,0,0,0">
<layout class="QGridLayout" name="gridLayout" columnstretch="10,0,0,0,0,0,0,0,0,0,0">
<property name="leftMargin">
<number>6</number>
</property>
......@@ -32,7 +32,7 @@
<property name="verticalSpacing">
<number>12</number>
</property>
<item row="2" column="5">
<item row="2" column="6">
<widget class="QSpinBox" name="intValueSpinBox">
<property name="minimum">
<number>-999999999</number>
......@@ -42,7 +42,7 @@
</property>
</widget>
</item>
<item row="3" column="5" colspan="3">
<item row="3" column="6" colspan="3">
<widget class="QComboBox" name="editSelectParamComboBox">
<property name="enabled">
<bool>false</bool>
......@@ -55,39 +55,68 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="nameLabel">
<item row="0" column="0" colspan="11">
<widget class="Line" name="editLine1">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="7" colspan="2">
<widget class="QSlider" name="valueSlider">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Name</string>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="maximum">
<number>1000000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QDoubleSpinBox" name="editMinSpinBox">
<property name="prefix">
<string>MIN: </string>
<item row="4" column="10">
<widget class="QPushButton" name="editDoneButton">
<property name="text">
<string>Done</string>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</widget>
</item>
<item row="6" column="0" colspan="11">
<widget class="Line" name="editLine2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2" colspan="5">
<widget class="QLineEdit" name="editNameLabel">
<item row="3" column="9">
<widget class="QCheckBox" name="editInfoCheckBox">
<property name="text">
<string>&lt;Parameter Name / Label&gt;</string>
<string>Show Info</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
......@@ -104,77 +133,49 @@
</property>
</spacer>
</item>
<item row="2" column="8">
<widget class="QPushButton" name="writeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Transmit the current slider value to the system</string>
</property>
<property name="statusTip">
<string>Transmit the current slider value to the system</string>
<item row="3" column="10">
<widget class="QPushButton" name="editRefreshParamsButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>W</string>
<string>Refresh</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="10">
<widget class="Line" name="editLine2">
<property name="minimumSize">
<item row="5" column="2" colspan="9">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</spacer>
</item>
<item row="2" column="6" colspan="2">
<widget class="QSlider" name="valueSlider">
<item row="2" column="10">
<widget class="QPushButton" name="readButton">
<property name="minimumSize">
<size>
<width>60</width>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>1000000</number>
<property name="toolTip">
<string>Read the current parameter value on the system</string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="statusTip">
<string>Read the current parameter value on the system</string>
</property>
</widget>
</item>
<item row="3" column="8">
<widget class="QCheckBox" name="editInfoCheckBox">
<property name="text">
<string>Show Info</string>
</property>
<property name="checked">
<bool>true</bool>
<string>R</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<item row="3" column="1" colspan="5">
<widget class="QComboBox" name="editSelectComponentComboBox">
<property name="enabled">
<bool>false</bool>
......@@ -187,36 +188,59 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="7">
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string>&lt;Parameter Name / Label&gt;</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="8">
<widget class="QLabel" name="editStatusLabel">
<property name="text">
<string>Please click first on refresh to update selection menus..</string>
</property>
</widget>
</item>
<item row="2" column="9">
<widget class="QPushButton" name="readButton">
<widget class="QPushButton" name="writeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Read the current parameter value on the system</string>
<string>Transmit the current slider value to the system</string>
</property>
<property name="statusTip">
<string>Read the current parameter value on the system</string>
<string>Transmit the current slider value to the system</string>
</property>
<property name="text">
<string>R</string>
<string>W</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="6">
<widget class="QLabel" name="editStatusLabel">
<property name="text">
<string>Please click first on refresh to update selection menus..</string>
<item row="2" column="4">
<widget class="QDoubleSpinBox" name="doubleValueSpinBox">
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="8" colspan="2">
<widget class="QDoubleSpinBox" name="editMaxSpinBox">
<item row="1" column="8">
<widget class="QDoubleSpinBox" name="editMinSpinBox">
<property name="prefix">
<string>MAX: </string>
<string>MIN: </string>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
......@@ -226,8 +250,11 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="doubleValueSpinBox">
<item row="1" column="9" colspan="2">
<widget class="QDoubleSpinBox" name="editMaxSpinBox">
<property name="prefix">
<string>MAX: </string>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
......@@ -236,54 +263,37 @@
</property>
</widget>
</item>
<item row="1" column="1" rowspan="6">
<widget class="QTextBrowser" name="infoLabel"/>
</item>
<item row="0" column="0" colspan="10">
<widget class="Line" name="editLine1">
<item row="2" column="2">
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>0</width>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="9">
<widget class="QPushButton" name="editRefreshParamsButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Refresh</string>
<string>Name</string>
</property>
</widget>
</item>
<item row="5" column="9">
<widget class="QPushButton" name="editDoneButton">
<property name="text">
<string>Done</string>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="2" colspan="8">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="2" column="3">
<widget class="QToolButton" name="infoLabel">
<property name="text">
<string/>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/status/dialog-information.svg</normaloff>:/files/images/status/dialog-information.svg</iconset>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
......@@ -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