Commit de0731a4 authored by Thomas Gubler's avatar Thomas Gubler

Merge branch 'master' of https://github.com/mavlink/qgroundcontrol into hil_flightgear_dev

parents 11874ee9 b3e21a8b
......@@ -47,6 +47,8 @@ user_config.pri
*.cproject
*.sln
*.suo
*.uhf.txt
*.opensdf
thirdParty/qserialport-build-desktop/
thirdParty/qserialport/bin/
......
[PX4%20Multirotor%20Attitude%20Control]
QGC_TOOL_WIDGET_ITEMS\1\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_DESCRIPTION=Attitude P Gain
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_PARAMID=MC_ATT_P
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_MAX=1.5
QGC_TOOL_WIDGET_ITEMS\2\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_DESCRIPTION=Attitude I Gain
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_PARAMID=MC_ATT_I
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_MAX=1
QGC_TOOL_WIDGET_ITEMS\3\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_DESCRIPTION=Attitude D Gain
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_PARAMID=MC_ATT_D
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_MAX=1
QGC_TOOL_WIDGET_ITEMS\4\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_DESCRIPTION=Attitude Anti-Windup
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_PARAMID=MC_ATT_AWU
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_MAX=1
QGC_TOOL_WIDGET_ITEMS\5\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_DESCRIPTION=Attitude Output Limit
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_PARAMID=MC_ATT_LIM
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_MAX=3
QGC_TOOL_WIDGET_ITEMS\6\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_DESCRIPTION=Heading / Yaw P Gain
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_PARAMID=MC_YAWPOS_P
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_MAX=1.2
QGC_TOOL_WIDGET_ITEMS\7\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_DESCRIPTION=Heading / Yaw D Gain
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_PARAMID=MC_YAWPOS_D
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_MAX=1
QGC_TOOL_WIDGET_ITEMS\8\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_DESCRIPTION=Roll / Pitch Rate P Gain
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_PARAMID=MC_ATTRATE_P
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_MAX=1.5
QGC_TOOL_WIDGET_ITEMS\9\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_DESCRIPTION=Roll / Pitch Rate D Gain
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_PARAMID=MC_ATTRATE_D
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_MAX=0.3
QGC_TOOL_WIDGET_ITEMS\10\TYPE=SLIDER
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_DESCRIPTION=Yaw Rate P Gain
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_PARAMID=MC_YAWRATE_P
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_COMPONENTID=50
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_MIN=0
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_MAX=1
QGC_TOOL_WIDGET_ITEMS\1\QGC_PARAM_SLIDER_DISPLAY_INFO=false
QGC_TOOL_WIDGET_ITEMS\2\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\3\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\4\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\5\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\6\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\7\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\8\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\9\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\10\QGC_PARAM_SLIDER_DISPLAY_INFO=true
QGC_TOOL_WIDGET_ITEMS\size=10
#ifndef I3D_MOUSE_PARAMS_H
#define I3D_MOUSE_PARAMS_H
/*
Parameters for the 3D mouse based on the SDK from 3Dconnexion
*/
class I3dMouseSensor
{
public:
enum ESpeed {
kLowSpeed = 0,
kMidSpeed,
kHighSpeed
};
virtual bool IsPanZoom() const = 0;
virtual bool IsRotate() const = 0;
virtual ESpeed GetSpeed() const = 0;
virtual void SetPanZoom(bool isPanZoom) = 0;
virtual void SetRotate(bool isRotate) = 0;
virtual void SetSpeed(ESpeed speed) = 0;
protected:
virtual ~I3dMouseSensor() {}
};
class I3dMouseNavigation
{
public:
enum EPivot {
kManualPivot = 0,
kAutoPivot,
kAutoPivotOverride
};
enum ENavigation {
kObjectMode = 0,
kCameraMode,
kFlyMode,
kWalkMode,
kHelicopterMode
};
enum EPivotVisibility {
kHidePivot = 0,
kShowPivot,
kShowMovingPivot
};
virtual ENavigation GetNavigationMode() const = 0;
virtual EPivot GetPivotMode() const = 0;
virtual EPivotVisibility GetPivotVisibility() const = 0;
virtual bool IsLockHorizon() const = 0;
virtual void SetLockHorizon(bool bOn) = 0;
virtual void SetNavigationMode(ENavigation navigation) = 0;
virtual void SetPivotMode(EPivot pivot) = 0;
virtual void SetPivotVisibility(EPivotVisibility visibility) = 0;
protected:
virtual ~I3dMouseNavigation(){}
};
class I3dMouseParam : public I3dMouseSensor, public I3dMouseNavigation
{
public:
virtual ~I3dMouseParam() {}
};
#endif
This diff is collapsed.
#ifndef T3DMOUSE_INPUT_H
#define T3DMOUSE_INPUT_H
#include "MouseParameters.h"
#include <QWidget>
#include <vector>
#include <map>
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 //target at least windows XP
#endif
#include <windows.h>
/*
A class for connecting to and receiving data from a 3D Connexion 3D mouse
This helper class manages the connection to a 3D mouse, collecting WM_INPUT
messages from Windows and converting the data into 3D motion data.
This class is based on the SDK from 3D Connexion but is modified to work with Qt.
It is Windows only since it uses the WM_INPUT messages from windows directly
rather than Qt events.
Note that it needs to be compiled with _WIN32_WINNT defined as 0x0501 (windows XP)
or later because the raw input API was added in Windows XP. This also means that
Qt needs to be compiled with this enabled otherwise the QEventDispatcherWin32 blocks
in processEvents because the raw input messages do not cause the thread to be woken if
Qt is compiled for Win 2000 targets.
*/
class Mouse3DInput : public QObject
{
Q_OBJECT
public:
Mouse3DInput(QWidget* widget);
~Mouse3DInput();
static bool Is3dmouseAttached();
I3dMouseParam& MouseParams();
const I3dMouseParam& MouseParams() const;
virtual void Move3d(HANDLE device, std::vector<float>& motionData);
virtual void On3dmouseKeyDown(HANDLE device, int virtualKeyCode);
virtual void On3dmouseKeyUp(HANDLE device, int virtualKeyCode);
signals:
void Move3d(std::vector<float>& motionData);
void On3dmouseKeyDown(int virtualKeyCode);
void On3dmouseKeyUp(int virtualKeyCode);
private:
bool InitializeRawInput(HWND hwndTarget);
static bool RawInputEventFilter(void* msg, long* result);
void OnRawInput(UINT nInputCode, HRAWINPUT hRawInput);
UINT GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
bool TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput);
void On3dmouseInput();
class TInputData
{
public:
TInputData() : fAxes(6) {}
bool IsZero() {
return (0.==fAxes[0] && 0.==fAxes[1] && 0.==fAxes[2] &&
0.==fAxes[3] && 0.==fAxes[4] && 0.==fAxes[5]);
}
int fTimeToLive; // For telling if the device was unplugged while sending data
bool fIsDirty;
std::vector<float> fAxes;
};
HWND fWindow;
// Data cache to handle multiple rawinput devices
std::map< HANDLE, TInputData> fDevice2Data;
std::map< HANDLE, unsigned long> fDevice2Keystate;
// 3dmouse parameters
MouseParameters f3dMouseParams; // Rotate, Pan Zoom etc.
// use to calculate distance traveled since last event
DWORD fLast3dmouseInputTime;
};
#endif
#include "MouseParameters.h"
MouseParameters::MouseParameters(): fNavigation(kObjectMode)
, fPivot(kAutoPivot)
, fPivotVisibility(kShowPivot)
, fIsLockHorizon(true)
, fIsPanZoom(true)
, fIsRotate(true)
, fSpeed(kLowSpeed)
{
}
MouseParameters::~MouseParameters()
{
}
bool MouseParameters::IsPanZoom() const
{
return fIsPanZoom;
}
bool MouseParameters::IsRotate() const
{
return fIsRotate;
}
MouseParameters::ESpeed MouseParameters::GetSpeed() const
{
return fSpeed;
}
void MouseParameters::SetPanZoom(bool isPanZoom)
{
fIsPanZoom=isPanZoom;
}
void MouseParameters::SetRotate(bool isRotate)
{
fIsRotate=isRotate;
}
void MouseParameters::SetSpeed(ESpeed speed)
{
fSpeed=speed;
}
MouseParameters::ENavigation MouseParameters::GetNavigationMode() const
{
return fNavigation;
}
MouseParameters::EPivot MouseParameters::GetPivotMode() const
{
return fPivot;
}
MouseParameters::EPivotVisibility MouseParameters::GetPivotVisibility() const
{
return fPivotVisibility;
}
bool MouseParameters::IsLockHorizon() const
{
return fIsLockHorizon;
}
void MouseParameters::SetLockHorizon(bool bOn)
{
fIsLockHorizon=bOn;
}
void MouseParameters::SetNavigationMode(ENavigation navigation)
{
fNavigation=navigation;
}
void MouseParameters::SetPivotMode(EPivot pivot)
{
if (fPivot!=kManualPivot || pivot!=kAutoPivotOverride)
fPivot = pivot;
}
void MouseParameters::SetPivotVisibility(EPivotVisibility visibility)
{
fPivotVisibility = visibility;
}
#ifndef T3D_MOUSE_PARAMS_H
#define T3D_MOUSE_PARAMS_H
#include "I3dMouseParams.h"
class MouseParameters : public I3dMouseParam
{
public:
MouseParameters();
~MouseParameters();
// I3dmouseSensor interface
bool IsPanZoom() const;
bool IsRotate() const;
ESpeed GetSpeed() const;
void SetPanZoom(bool isPanZoom);
void SetRotate(bool isRotate);
void SetSpeed(ESpeed speed);
// I3dmouseNavigation interface
ENavigation GetNavigationMode() const;
EPivot GetPivotMode() const;
EPivotVisibility GetPivotVisibility() const;
bool IsLockHorizon() const;
void SetLockHorizon(bool bOn);
void SetNavigationMode(ENavigation navigation);
void SetPivotMode(EPivot pivot);
void SetPivotVisibility(EPivotVisibility visibility);
private:
MouseParameters (const MouseParameters&);
const MouseParameters& operator =(const MouseParameters&);
ENavigation fNavigation;
EPivot fPivot;
EPivotVisibility fPivotVisibility;
bool fIsLockHorizon;
bool fIsPanZoom;
bool fIsRotate;
ESpeed fSpeed;
};
#endif
This diff is collapsed.
#include <QJsonDocument>
#include <QFile>
#include "PX4FirmwareUpgradeWorker.h"
#include <SerialLink.h>
......@@ -49,21 +52,28 @@ PX4FirmwareUpgradeWorker* PX4FirmwareUpgradeWorker::putWorkerInThread(QObject *p
// Starts an event loop, and emits workerThread->started()
workerThread->start();
return worker;
}
bool PX4FirmwareUpgradeWorker::startContinousScan()
void PX4FirmwareUpgradeWorker::startContinousScan()
{
while (true) {
if (detect()) {
break;
}
exitThread = false;
while (!exitThread) {
// if (detect()) {
// break;
// }
QGC::SLEEP::msleep(20);
}
return true;
if (exitThread) {
link->disconnect();
delete link;
exit(0);
}
}
bool PX4FirmwareUpgradeWorker::detect()
void PX4FirmwareUpgradeWorker::detect()
{
if (!link)
{
......@@ -80,7 +90,7 @@ bool PX4FirmwareUpgradeWorker::detect()
// Ignore known wrong link names
if (ports->at(i).contains("Bluetooth")) {
continue;
//continue;
}
link->setPortName(ports->at(i));
......@@ -101,12 +111,6 @@ bool PX4FirmwareUpgradeWorker::detect()
break;
}
if (insync) {
return true;
} else {
return false;
}
//ui.portName->setCurrentIndex(ui.baudRate->findText(QString("%1").arg(this->link->getPortName())));
// Set port
......@@ -119,11 +123,15 @@ void PX4FirmwareUpgradeWorker::receiveBytes(LinkInterface* link, QByteArray b)
{
for (int position = 0; position < b.size(); position++) {
qDebug() << "BYTES";
qDebug() << std::hex << (char)(b[position]);
qDebug() << (char)(b[position]);
if (((const char)b[position]) == INSYNC)
{
qDebug() << "SYNC";
insync = true;
}
if (insync && ((const char)b[position]) == OK)
{
emit detectionStatusChanged("Found PX4 board");
}
}
......@@ -131,7 +139,31 @@ void PX4FirmwareUpgradeWorker::receiveBytes(LinkInterface* link, QByteArray b)
printf("\n");
}
bool PX4FirmwareUpgradeWorker::upgrade(const QString &filename)
void PX4FirmwareUpgradeWorker::loadFirmware(const QString &filename)
{
qDebug() << __FILE__ << __LINE__ << "LOADING FW";
QFile f(filename);
if (f.open(QIODevice::ReadOnly))
{
QByteArray buf = f.readAll();
f.close();
firmware = QJsonDocument::fromBinaryData(buf);
if (firmware.isNull()) {
emit upgradeStatusChanged(tr("Failed decoding file %1").arg(filename));
} else {
emit upgradeStatusChanged(tr("Ready to flash %1").arg(filename));
}
} else {
emit upgradeStatusChanged(tr("Failed opening file %1").arg(filename));
}
}
void PX4FirmwareUpgradeWorker::upgrade()
{
emit upgradeStatusChanged(tr("Starting firmware upgrade.."));
}
void PX4FirmwareUpgradeWorker::abort()
{
exitThread = true;
}
......@@ -2,6 +2,7 @@
#define PX4FIRMWAREUPGRADEWORKER_H
#include <QObject>
#include <QJsonDocument>
#include <SerialLink.h>
......@@ -24,7 +25,7 @@ public slots:
* @brief Continously scan for bootloaders
* @return
*/
bool startContinousScan();
void startContinousScan();
/**
* @brief Detect connected PX4 bootloaders
......@@ -34,14 +35,19 @@ public slots:
*
* @return true if found on one link, false else
*/
bool detect();
void detect();
/**
* @brief Upgrade the firmware using the currently connected link
* @param filename file name / path of the firmware file
* @return true if upgrade succeeds, false else
*/
bool upgrade(const QString &filename);
void upgrade();
/**
* @brief Load firmware from disk into memory
* @param filename
*/
void loadFirmware(const QString &filename);
/**
* @brief Receive bytes from a link
......@@ -50,9 +56,18 @@ public slots:
*/
void receiveBytes(LinkInterface* link, QByteArray b);
/**
* @brief Abort upgrade worker
*/
void abort();
protected:
bool exitThread;
private:
SerialLink *link;
bool insync;
QJsonDocument firmware;
};
#endif // PX4FIRMWAREUPGRADEWORKER_H
......@@ -72,13 +72,21 @@ QUpgradeApp::QUpgradeApp(int &argc, char* argv[]) : QApplication(argc, argv)
// Create main window
QUpgradeMainWindow* window = new QUpgradeMainWindow();
PX4FirmwareUpgrader *upgrader = new PX4FirmwareUpgrader(window);
window->setCentralWidget(upgrader);
// Get PX4 upgrade widget and instantiate worker thread
PX4FirmwareUpgradeWorker* worker = PX4FirmwareUpgradeWorker::putWorkerInThread(this);
connect(worker, SIGNAL(detectionStatusChanged(QString)), window->firmwareUpgrader(), SLOT(setDetectionStatusText(QString)));
connect(worker, SIGNAL(upgradeStatusChanged(QString)), window->firmwareUpgrader(), SLOT(setFlashStatusText(QString)));
connect(worker, SIGNAL(upgradeProgressChanged(int)), window->firmwareUpgrader(), SLOT(setFlashProgress(int)));
connect(worker, SIGNAL(validPortFound(QString)), window->firmwareUpgrader(), SLOT(setPortName(QString)));
connect(worker, SIGNAL(detectionStatusChanged(QString)), upgrader, SLOT(setDetectionStatusText(QString)), Qt::QueuedConnection);
connect(worker, SIGNAL(upgradeStatusChanged(QString)), upgrader, SLOT(setFlashStatusText(QString)), Qt::QueuedConnection);
connect(worker, SIGNAL(upgradeProgressChanged(int)), upgrader, SLOT(setFlashProgress(int)), Qt::QueuedConnection);
connect(worker, SIGNAL(validPortFound(QString)), upgrader, SLOT(setPortName(QString)));
connect(upgrader, SIGNAL(firmwareFileNameSet(QString)), worker, SLOT(loadFirmware(QString)), Qt::QueuedConnection);
connect(upgrader, SIGNAL(upgrade()), worker, SLOT(upgrade()), Qt::QueuedConnection);
connect(this, SIGNAL(lastWindowClosed()), worker, SLOT(abort()), Qt::QueuedConnection);
worker->loadFirmware("abc");
window->setWindowTitle(applicationName() + " " + applicationVersion());
window->show();
......
......@@ -42,10 +42,6 @@ QUpgradeMainWindow::QUpgradeMainWindow(QWidget *parent) :
ui->setupUi(this);
}
PX4FirmwareUpgrader* QUpgradeMainWindow::firmwareUpgrader() {
return ui->centralwidget;
}
QUpgradeMainWindow::~QUpgradeMainWindow()
{
delete ui;
......
......@@ -48,8 +48,6 @@ public:
explicit QUpgradeMainWindow(QWidget *parent = 0);
~QUpgradeMainWindow();
PX4FirmwareUpgrader* firmwareUpgrader();
public slots:
protected:
......
......@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="PX4FirmwareUpgrader" name="centralwidget">
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout" rowstretch="0"/>
</widget>
<widget class="QMenuBar" name="menubar">
......@@ -28,14 +28,6 @@
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>PX4FirmwareUpgrader</class>
<extends>QWidget</extends>
<header location="global">PX4FirmwareUpgrader.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#include "QGCHilLink.h"
//QGCHilLink::QGCHilLink(QObject *parent) :
// QThread(parent)
//{
//}
......@@ -49,7 +49,10 @@ QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress
terraSync(NULL),
airframeID(QGCXPlaneLink::AIRFRAME_UNKNOWN),
xPlaneConnected(false),
xPlaneVersion(0)
xPlaneVersion(0),
simUpdateLast(QGC::groundTimeMilliseconds()),
simUpdateLastText(QGC::groundTimeMilliseconds()),
simUpdateHz(0)
{
this->localHost = localHost;
this->localPort = localPort/*+mav->getUASID()*/;
......@@ -223,10 +226,12 @@ void QGCXPlaneLink::setRemoteHost(const QString& newHost)
void QGCXPlaneLink::updateActuators(uint64_t time, float act1, float act2, float act3, float act4, float act5, float act6, float act7, float act8)
{
// XXX Control this via the onboard system type exclusively
if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
// Only update this for multirotors
if (airframeID == AIRFRAME_QUAD_X_MK_10INCH_I2C ||
airframeID == AIRFRAME_QUAD_X_ARDRONE ||
airframeID == AIRFRAME_QUAD_DJI_F450_PWM)
// if (airframeID == AIRFRAME_QUAD_X_MK_10INCH_I2C ||
// airframeID == AIRFRAME_QUAD_X_ARDRONE ||
// airframeID == AIRFRAME_QUAD_DJI_F450_PWM)
{
Q_UNUSED(time);
......@@ -252,27 +257,34 @@ void QGCXPlaneLink::updateActuators(uint64_t time, float act1, float act2, float
p.index = 25;
memset(p.f, 0, sizeof(p.f));
if (airframeID == AIRFRAME_QUAD_X_MK_10INCH_I2C)
{
p.f[0] = act1 / 255.0f;
p.f[1] = act2 / 255.0f;
p.f[2] = act3 / 255.0f;
p.f[3] = act4 / 255.0f;
}
else if (airframeID == AIRFRAME_QUAD_X_ARDRONE)
{
p.f[0] = act1 / 500.0f;
p.f[1] = act2 / 500.0f;
p.f[2] = act3 / 500.0f;
p.f[3] = act4 / 500.0f;
}
else
{
p.f[0] = (act1 - 1000.0f) / 1000.0f;
p.f[1] = (act2 - 1000.0f) / 1000.0f;
p.f[2] = (act3 - 1000.0f) / 1000.0f;
p.f[3] = (act4 - 1000.0f) / 1000.0f;
}
p.f[0] = act1;
p.f[1] = act2;
p.f[2] = act3;
p.f[3] = act4;
// XXX the system corrects for the scale onboard, do not scale again
// if (airframeID == AIRFRAME_QUAD_X_MK_10INCH_I2C)
// {
// p.f[0] = act1 / 255.0f;
// p.f[1] = act2 / 255.0f;
// p.f[2] = act3 / 255.0f;
// p.f[3] = act4 / 255.0f;
// }
// else if (airframeID == AIRFRAME_QUAD_X_ARDRONE)
// {
// p.f[0] = act1 / 500.0f;
// p.f[1] = act2 / 500.0f;
// p.f[2] = act3 / 500.0f;
// p.f[3] = act4 / 500.0f;
// }
// else
// {
// p.f[0] = (act1 - 1000.0f) / 1000.0f;
// p.f[1] = (act2 - 1000.0f) / 1000.0f;
// p.f[2] = (act3 - 1000.0f) / 1000.0f;
// p.f[3] = (act4 - 1000.0f) / 1000.0f;
// }
// Throttle
writeBytes((const char*)&p, sizeof(p));
}
......@@ -282,7 +294,6 @@ void QGCXPlaneLink::updateControls(uint64_t time, float rollAilerons, float pitc
{
// Do not update this control type for
// all multirotors
if (airframeID == AIRFRAME_QUAD_X_MK_10INCH_I2C ||
airframeID == AIRFRAME_QUAD_X_ARDRONE ||
airframeID == AIRFRAME_QUAD_DJI_F450_PWM)
......@@ -366,7 +377,7 @@ void QGCXPlaneLink::readBytes()
// Only emit updates on attitude message
bool emitUpdate = false;
const qint64 maxLength = 65536;
const qint64 maxLength = 1000;
char data[maxLength];
QHostAddress sender;
quint16 senderPort;
......@@ -501,8 +512,18 @@ void QGCXPlaneLink::readBytes()
}
// Send updated state
if (emitUpdate)
if (emitUpdate && (QGC::groundTimeMilliseconds() - simUpdateLast) > 3)
{
simUpdateHz = simUpdateHz * 0.9f + 0.1f * (1000.0f / (QGC::groundTimeMilliseconds() - simUpdateLast));
if (QGC::groundTimeMilliseconds() - simUpdateLastText > 2000) {
emit statusMessage(tr("Receiving from XPlane at %1 Hz").arg(static_cast<int>(simUpdateHz)));
// Reset lowpass with current value
simUpdateHz = (1000.0f / (QGC::groundTimeMilliseconds() - simUpdateLast));
// Set state
simUpdateLastText = QGC::groundTimeMilliseconds();
}
simUpdateLast = QGC::groundTimeMilliseconds();
emit hilStateChanged(QGC::groundTimeUsecs(), roll, pitch, yaw, rollspeed,
pitchspeed, yawspeed, lat*1E7, lon*1E7, alt*1E3,
vx, vy, vz, xacc*1000, yacc*1000, zacc*1000);
......@@ -510,7 +531,7 @@ void QGCXPlaneLink::readBytes()
if (!oldConnectionState && xPlaneConnected)
{
emit statusMessage("Receiving from XPlane.");
emit statusMessage(tr("Receiving from XPlane."));
}
// // Echo data for debugging purposes
......
......@@ -190,6 +190,9 @@ protected:
enum AIRFRAME airframeID;
bool xPlaneConnected;
unsigned int xPlaneVersion;
quint64 simUpdateLast;
quint64 simUpdateLastText;
float simUpdateHz;
void setName(QString name);
......
This diff is collapsed.
/**
* @file
* @brief Definition of 3dConnexion 3dMouse interface for QGroundControl
*
* @author Matthias Krebs <makrebs@student.ethz.ch>
*
*/
#ifndef MOUSE6DOFINPUT_H
#define MOUSE6DOFINPUT_H
#include <QThread>
#ifdef MOUSE_ENABLED_WIN
#include "Mouse3DInput.h"
#endif //MOUSE_ENABLED_WIN
#include "UASInterface.h"
class Mouse6dofInput : public QThread
{
Q_OBJECT
public:
#ifdef MOUSE_ENABLED_WIN
Mouse6dofInput(Mouse3DInput* mouseInput);
#endif //MOUSE_ENABLED_WIN
#ifdef MOUSE_ENABLED_LINUX
Mouse6dofInput(QWidget* parent);
#endif //MOUSE_ENABLED_LINUX
~Mouse6dofInput();
void run();
const double mouse3DMax;
protected:
void init();
UASInterface* uas;
bool done;
bool mouseActive;
bool translationActive;
bool rotationActive;
double xValue;
double yValue;
double zValue;
double aValue;
double bValue;
double cValue;
signals:
/**
* @brief Input of the 3d mouse has changed
*
* @param x Input x direction, range [-1, 1]
* @param y Input y direction, range [-1, 1]
* @param z Input z direction, range [-1, 1]
* @param a Input x rotation, range [-1, 1]
* @param b Input y rotation, range [-1, 1]
* @param c Input z rotation, range [-1, 1]
*/
void mouse6dofChanged(double x, double y, double z, double a, double b, double c);
/**
* @brief Activity of translational 3DMouse inputs changed
* @param translationEnable, true: translational inputs active; false: translational inputs ingored
*/
void mouseTranslationActiveChanged(bool translationEnable);
/**
* @brief Activity of rotational 3DMouse inputs changed
* @param rotationEnable, true: rotational inputs active; false: rotational inputs ingored
*/
void mouseRotationActiveChanged(bool rotationEnable);
public slots:
void setActiveUAS(UASInterface* uas);
#ifdef MOUSE_ENABLED_WIN
/** @brief Get a motion input from 3DMouse */
void motion3DMouse(std::vector<float> &motionData);
/** @brief Get a button input from 3DMouse */
void button3DMouseDown(int button);
#endif //MOUSE_ENABLED_WIN
#ifdef MOUSE_ENABLED_LINUX
/** @brief Get an XEvent to check it for an 3DMouse event (motion or button) */
void handleX11Event(XEvent* event);
#endif //MOUSE_ENABLED_LINUX
};
#endif // MOUSE6DOFINPUT_H
......@@ -32,6 +32,8 @@ ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id) :
UAS(mavlink, id)//,
// place other initializers here
{
// Ask for all streams at 4 Hz
enableAllDataTransmission(4);
}
/**
......
This diff is collapsed.
This diff is collapsed.
......@@ -475,6 +475,7 @@ signals:
void imageDataReceived(int imgid, const unsigned char* imageData, int length, int startIndex);
/** @brief Emit the new system type */
void systemTypeSet(UASInterface* uas, unsigned int type);
/** @brief Attitude control enabled/disabled */
void attitudeControlEnabled(bool enabled);
/** @brief Position 2D control enabled/disabled */
......@@ -483,6 +484,30 @@ signals:
void positionZControlEnabled(bool enabled);
/** @brief Heading control enabled/disabled */
void positionYawControlEnabled(bool enabled);
/** @brief Optical flow status changed */
void opticalFlowStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Vision based localization status changed */
void visionLocalizationStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Infrared / Ultrasound status changed */
void distanceSensorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Gyroscope status changed */
void gyroStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Accelerometer status changed */
void accelStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Magnetometer status changed */
void magSensorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Barometer status changed */
void baroStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Differential pressure / airspeed status changed */
void airspeedStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Actuator status changed */
void actuatorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Laser scanner status changed */
void laserStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Vicon / Leica Geotracker status changed */
void groundTruthSensorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Value of a remote control channel (raw) */
void remoteControlChannelRawChanged(int channelId, float raw);
/** @brief Value of a remote control channel (scaled)*/
......
......@@ -123,7 +123,34 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
userSetPointSet(false),
userXYSetPointSet(false),
userZSetPointSet(false),
userYawSetPointSet(false)
userYawSetPointSet(false),
gyroKnown(false),
gyroON(false),
gyroOK(false),
accelKnown(false),
accelON(false),
accelOK(false),
magKnown(false),
magON(false),
magOK(false),
pressureKnown(false),
pressureON(false),
pressureOK(false),
diffPressureKnown(false),
diffPressureON(false),
diffPressureOK(false),
flowKnown(false),
flowON(false),
flowOK(false),
laserKnown(false),
laserON(false),
laserOK(false),
viconKnown(false),
viconON(false),
viconOK(false),
actuatorsKnown(false),
actuatorsON(false),
actuatorsOK(false)
{
refreshTimer->setInterval(updateInterval);
......@@ -845,6 +872,16 @@ void HSIDisplay::setActiveUAS(UASInterface* uas)
disconnect(this->uas, SIGNAL(gpsLocalizationChanged(UASInterface*,int)), this, SLOT(updateGpsLocalization(UASInterface*,int)));
disconnect(this->uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)), this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int)));
disconnect(this->uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)), this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float)));
disconnect(this->uas, SIGNAL(gyroStatusChanged(bool,bool,bool)), this, SLOT(updateGyroStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(accelStatusChanged(bool,bool,bool)), this, SLOT(updateAccelStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)), this, SLOT(updateMagSensorStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(baroStatusChanged(bool,bool,bool)), this, SLOT(updateBaroStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)), this, SLOT(updateAirspeedStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)), this, SLOT(updateOpticalFlowStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(laserStatusChanged(bool,bool,bool)), this, SLOT(updateLaserStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)), this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool)));
disconnect(this->uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool)));
}
connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool)));
......@@ -867,6 +904,16 @@ void HSIDisplay::setActiveUAS(UASInterface* uas)
connect(uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)), this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int)));
connect(uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)), this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float)));
connect(uas, SIGNAL(gyroStatusChanged(bool,bool,bool)), this, SLOT(updateGyroStatus(bool,bool,bool)));
connect(uas, SIGNAL(accelStatusChanged(bool,bool,bool)), this, SLOT(updateAccelStatus(bool,bool,bool)));
connect(uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)), this, SLOT(updateMagSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(baroStatusChanged(bool,bool,bool)), this, SLOT(updateBaroStatus(bool,bool,bool)));
connect(uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)), this, SLOT(updateAirspeedStatus(bool,bool,bool)));
connect(uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)), this, SLOT(updateOpticalFlowStatus(bool,bool,bool)));
connect(uas, SIGNAL(laserStatusChanged(bool,bool,bool)), this, SLOT(updateLaserStatus(bool,bool,bool)));
connect(uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)), this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool)));
this->uas = uas;
resetMAVState();
......
......@@ -66,6 +66,83 @@ public slots:
void updateAttitudeControllerEnabled(bool enabled);
void updatePositionXYControllerEnabled(bool enabled);
void updatePositionZControllerEnabled(bool enabled);
/** @brief Optical flow status changed */
void updateOpticalFlowStatus(bool supported, bool enabled, bool ok) {
if (supported && enabled && ok) {
visionFix = true;
} else {
visionFix = false;
}
}
/** @brief Vision based localization status changed */
void updateVisionLocalizationStatus(bool supported, bool enabled, bool ok) {
if (enabled && ok) {
visionFix = true;
} else {
visionFix = false;
}
visionFixKnown = supported;
}
/** @brief Infrared / Ultrasound status changed */
void updateDistanceSensorStatus(bool supported, bool enabled, bool ok) {
if (enabled && ok) {
iruFix = true;
} else {
iruFix = false;
}
iruFixKnown = supported;
}
/** @brief Gyroscope status changed */
void updateGyroStatus(bool supported, bool enabled, bool ok) {
gyroKnown = supported;
gyroON = enabled;
gyroOK = ok;
}
/** @brief Accelerometer status changed */
void updateAccelStatus(bool supported, bool enabled, bool ok) {
accelKnown = supported;
accelON = enabled;
accelOK = ok;
}
/** @brief Magnetometer status changed */
void updateMagSensorStatus(bool supported, bool enabled, bool ok) {
magKnown = supported;
magON = enabled;
magOK = ok;
}
/** @brief Barometer status changed */
void updateBaroStatus(bool supported, bool enabled, bool ok) {
pressureKnown = supported;
pressureON = enabled;
pressureOK = ok;
}
/** @brief Differential pressure / airspeed status changed */
void updateAirspeedStatus(bool supported, bool enabled, bool ok) {
diffPressureKnown = supported;
diffPressureON = enabled;
diffPressureOK = ok;
}
/** @brief Actuator status changed */
void updateActuatorStatus(bool supported, bool enabled, bool ok) {
actuatorsKnown = supported;
actuatorsON = enabled;
actuatorsOK = ok;
}
/** @brief Laser scanner status changed */
void updateLaserStatus(bool supported, bool enabled, bool ok) {
laserKnown = supported;
laserON = enabled;
laserOK = ok;
}
/** @brief Vicon / Leica Geotracker status changed */
void updateGroundTruthSensorStatus(bool supported, bool enabled, bool ok) {
viconKnown = supported;
viconON = enabled;
viconOK = ok;
}
void updateObjectPosition(unsigned int time, int id, int type, const QString& name, int quality, float bearing, float distance);
/** @brief Heading control enabled/disabled */
void updatePositionYawControllerEnabled(bool enabled);
......
This diff is collapsed.
This diff is collapsed.
#include <QFileDialog>
#include <QDesktopServices>
#include <QSettings>
#include "PX4FirmwareUpgrader.h"
#include "ui_PX4FirmwareUpgrader.h"
#include <QGC.h>
#include <QDebug>
PX4FirmwareUpgrader::PX4FirmwareUpgrader(QWidget *parent) :
QWidget(parent),
ui(new Ui::PX4FirmwareUpgrader)
......@@ -21,7 +26,16 @@ PX4FirmwareUpgrader::~PX4FirmwareUpgrader()
void PX4FirmwareUpgrader::selectFirmwareFile()
{
QSettings settings;
QString path = settings.value("PX4_FIRMWARE_PATH",
QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)).toString();
const QString widgetFileExtension(".px4");
QString fileName = QFileDialog::getOpenFileName(this, tr("Specify File Name"),
path,
tr("PX4 Firmware (*%1);;").arg(widgetFileExtension));
settings.setValue("PX4_FIRMWARE_PATH", fileName);
qDebug() << "EMITTING SIGNAL";
emit firmwareFileNameSet(fileName);
}
void PX4FirmwareUpgrader::setDetectionStatusText(const QString &text)
......@@ -32,6 +46,7 @@ void PX4FirmwareUpgrader::setDetectionStatusText(const QString &text)
void PX4FirmwareUpgrader::setFlashStatusText(const QString &text)
{
ui->flashProgressLabel->setText(text);
qDebug() << __FILE__ << __LINE__ << "LABEL" << text;
}
void PX4FirmwareUpgrader::setFlashProgress(int percent)
......
......@@ -30,7 +30,12 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
mav->enableHilFlightGear(false, "");
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this);
hfgconf->show();
ui->simulatorConfigurationDockWidget->setWidget(hfgconf);
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(mav->getHILSimulation());
if (fg)
{
connect(fg, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
}
}
else if(2 == index || 3 == index)
......@@ -39,13 +44,14 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
mav->enableHilXPlane(false);
QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(mav->getHILSimulation(), this);
hxpconf->show();
ui->simulatorConfigurationDockWidget->setWidget(hxpconf);
ui->simulatorConfigurationLayout->addWidget(hxpconf);
// Select correct version of XPlane
QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(mav->getHILSimulation());
if (xplane)
{
xplane->setVersion((index == 2) ? 10 : 9);
connect(xplane, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
}
}
}
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>355</height>
<width>366</width>
<height>301</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -19,22 +19,22 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="40,0,0">
<item row="0" column="0">
<widget class="QLabel" name="simLabel">
<layout class="QGridLayout" name="gridLayout" rowstretch="1,100,1" columnstretch="40,0">
<item row="2" column="0">
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Simulator</string>
<string>Status</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="statusLabel">
<item row="0" column="0">
<widget class="QLabel" name="simLabel">
<property name="text">
<string>Status</string>
<string>Simulator</string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="1">
<widget class="QComboBox" name="simComboBox">
<property name="editable">
<bool>true</bool>
......@@ -61,35 +61,12 @@
</item>
</widget>
</item>
<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="minimumSize">
<size>
<width>20</width>
<height>150</height>
</size>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
<item row="1" column="0" colspan="2">
<layout class="QVBoxLayout" name="simulatorConfigurationLayout">
<property name="spacing">
<number>0</number>
</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>
</layout>
</item>
</layout>
</widget>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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