Commit a5f7a9e8 authored by Lorenz Meier's avatar Lorenz Meier

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

parents 18149033 d36eca90
...@@ -42,7 +42,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -42,7 +42,7 @@ This file is part of the QGROUNDCONTROL project
#endif #endif
// Speech synthesis is only supported with MSVC compiler // Speech synthesis is only supported with MSVC compiler
#if _MSC_VER2 #if _MSC_VER
// Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx // Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx
#define _ATL_APARTMENT_THREADED #define _ATL_APARTMENT_THREADED
...@@ -61,11 +61,13 @@ extern CComModule _Module; ...@@ -61,11 +61,13 @@ extern CComModule _Module;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
extern "C" { extern "C" {
#include <flite/flite.h> #include <flite/flite.h>
cst_voice* register_cmu_us_kal(const char* voxdir); cst_voice *register_cmu_us_kal(const char *voxdir);
}; };
#endif #endif
#ifdef _MSC_VER
ISpVoice *GAudioOutput::pVoice = NULL;
#endif
/** /**
* This class follows the singleton design pattern * This class follows the singleton design pattern
...@@ -74,22 +76,24 @@ extern "C" { ...@@ -74,22 +76,24 @@ extern "C" {
* the call can occur at any place in the code, no reference to the * the call can occur at any place in the code, no reference to the
* GAudioOutput object has to be passed. * GAudioOutput object has to be passed.
*/ */
GAudioOutput* GAudioOutput::instance() GAudioOutput *GAudioOutput::instance()
{ {
static GAudioOutput* _instance = 0; static GAudioOutput *_instance = 0;
if(_instance == 0)
if (_instance == 0)
{ {
_instance = new GAudioOutput(); _instance = new GAudioOutput();
// Set the application as parent to ensure that this object // Set the application as parent to ensure that this object
// will be destroyed when the main application exits // will be destroyed when the main application exits
_instance->setParent(qApp); _instance->setParent(qApp);
} }
return _instance; return _instance;
} }
#define QGC_GAUDIOOUTPUT_KEY QString("QGC_AUDIOOUTPUT_") #define QGC_GAUDIOOUTPUT_KEY QString("QGC_AUDIOOUTPUT_")
GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent),
voiceIndex(0), voiceIndex(0),
emergency(false), emergency(false),
muted(false) muted(false)
...@@ -97,31 +101,34 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), ...@@ -97,31 +101,34 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent),
// Load settings // Load settings
QSettings settings; QSettings settings;
settings.sync(); settings.sync();
muted = settings.value(QGC_GAUDIOOUTPUT_KEY+"muted", muted).toBool(); muted = settings.value(QGC_GAUDIOOUTPUT_KEY + "muted", muted).toBool();
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
flite_init(); flite_init();
#endif #endif
#if _MSC_VER2 #if _MSC_VER
pVoice = NULL;
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL))) if (FAILED(::CoInitialize(NULL)))
{ {
qDebug("Creating COM object for audio output failed!"); qDebug("Creating COM object for audio output failed!");
} }
else else
{ {
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice;); HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
if (SUCCEEDED(hr))
{ {
hr = pVoice->Speak(L"Hello world", 0, NULL); hr = pVoice->Speak(L"QGC audio output active!", 0, NULL);
pVoice->Release(); //pVoice->Release();
pVoice = NULL; //pVoice = NULL;
} }
} }
#endif #endif
// Initialize audio output // Initialize audio output
//m_media = new Phonon::MediaObject(this); //m_media = new Phonon::MediaObject(this);
...@@ -132,22 +139,27 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), ...@@ -132,22 +139,27 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent),
emergencyTimer = new QTimer(); emergencyTimer = new QTimer();
connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep())); connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep()));
switch (voiceIndex) { switch (voiceIndex)
{
case 0: case 0:
selectFemaleVoice(); selectFemaleVoice();
break; break;
default: default:
selectMaleVoice(); selectMaleVoice();
break; break;
} }
} }
//GAudioOutput::~GAudioOutput() GAudioOutput::~GAudioOutput()
//{ {
//#ifdef _MSC_VER2 #ifdef _MSC_VER
// ::CoUninitialize(); pVoice->Release();
//#endif pVoice = NULL;
//} ::CoUninitialize();
#endif
}
void GAudioOutput::mute(bool mute) void GAudioOutput::mute(bool mute)
{ {
...@@ -155,7 +167,7 @@ void GAudioOutput::mute(bool mute) ...@@ -155,7 +167,7 @@ void GAudioOutput::mute(bool mute)
{ {
this->muted = mute; this->muted = mute;
QSettings settings; QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY+"muted", this->muted); settings.setValue(QGC_GAUDIOOUTPUT_KEY + "muted", this->muted);
settings.sync(); settings.sync();
emit mutedChanged(muted); emit mutedChanged(muted);
} }
...@@ -173,29 +185,49 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -173,29 +185,49 @@ bool GAudioOutput::say(QString text, int severity)
// TODO Add severity filter // TODO Add severity filter
Q_UNUSED(severity); Q_UNUSED(severity);
bool res = false; bool res = false;
if (!emergency) if (!emergency)
{ {
// Speech synthesis is only supported with MSVC compiler // Speech synthesis is only supported with MSVC compiler
#ifdef _MSC_VER2 #ifdef _MSC_VER
SpeechSynthesizer synth = new SpeechSynthesizer(); /*SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SelectVoice("Microsoft Anna"); synth.SelectVoice("Microsoft Anna");
synth.SpeakText(text.toStdString().c_str()); synth.SpeakText(text.toStdString().c_str());
res = true; res = true;*/
/*ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
{
qDebug("Creating COM object for audio output failed!");
}
else
{
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
hr = */pVoice->Speak(text.toStdWString().c_str(), SPF_ASYNC, NULL);
/*pVoice->WaitUntilDone(5000);
pVoice->Release();
pVoice = NULL;
}
}*/
#endif #endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QTemporaryFile file; QTemporaryFile file;
file.setFileTemplate("XXXXXX.wav"); file.setFileTemplate("XXXXXX.wav");
if (file.open()) {
cst_voice* v = register_cmu_us_kal(NULL); if (file.open())
cst_wave* wav = flite_text_to_wave(text.toStdString().c_str(), v); {
cst_voice *v = register_cmu_us_kal(NULL);
cst_wave *wav = flite_text_to_wave(text.toStdString().c_str(), v);
// file.fileName() returns the unique file name // file.fileName() returns the unique file name
cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff"); cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff");
//m_media->setCurrentSource(Phonon::MediaSource(file.fileName().toStdString().c_str())); //m_media->setCurrentSource(Phonon::MediaSource(file.fileName().toStdString().c_str()));
//m_media->play(); //m_media->play();
res = true; res = true;
} }
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
...@@ -209,8 +241,10 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -209,8 +241,10 @@ bool GAudioOutput::say(QString text, int severity)
res = true; res = true;
#endif #endif
} }
return res; return res;
} }
else else
{ {
return false; return false;
...@@ -230,6 +264,7 @@ bool GAudioOutput::alert(QString text) ...@@ -230,6 +264,7 @@ bool GAudioOutput::alert(QString text)
say(text, 2); say(text, 2);
return true; return true;
} }
else else
{ {
return false; return false;
...@@ -241,7 +276,7 @@ void GAudioOutput::notifyPositive() ...@@ -241,7 +276,7 @@ void GAudioOutput::notifyPositive()
if (!muted) if (!muted)
{ {
// Use QFile to transform path for all OS // Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/files/audio/double_notify.wav")); QFile f(QCoreApplication::applicationDirPath() + QString("/files/audio/double_notify.wav"));
//m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str())); //m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
//m_media->play(); //m_media->play();
} }
...@@ -252,7 +287,7 @@ void GAudioOutput::notifyNegative() ...@@ -252,7 +287,7 @@ void GAudioOutput::notifyNegative()
if (!muted) if (!muted)
{ {
// Use QFile to transform path for all OS // Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/files/audio/flat_notify.wav")); QFile f(QCoreApplication::applicationDirPath() + QString("/files/audio/flat_notify.wav"));
//m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str())); //m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
//m_media->play(); //m_media->play();
} }
...@@ -270,11 +305,14 @@ bool GAudioOutput::startEmergency() ...@@ -270,11 +305,14 @@ bool GAudioOutput::startEmergency()
if (!emergency) if (!emergency)
{ {
emergency = true; emergency = true;
// Beep immediately and then start timer // Beep immediately and then start timer
if (!muted) beep(); if (!muted) beep();
emergencyTimer->start(1500); emergencyTimer->start(1500);
QTimer::singleShot(5000, this, SLOT(stopEmergency())); QTimer::singleShot(5000, this, SLOT(stopEmergency()));
} }
return true; return true;
} }
...@@ -286,10 +324,12 @@ bool GAudioOutput::startEmergency() ...@@ -286,10 +324,12 @@ bool GAudioOutput::startEmergency()
*/ */
bool GAudioOutput::stopEmergency() bool GAudioOutput::stopEmergency()
{ {
if (emergency) { if (emergency)
{
emergency = false; emergency = false;
emergencyTimer->stop(); emergencyTimer->stop();
} }
return true; return true;
} }
...@@ -298,7 +338,7 @@ void GAudioOutput::beep() ...@@ -298,7 +338,7 @@ void GAudioOutput::beep()
if (!muted) if (!muted)
{ {
// Use QFile to transform path for all OS // Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/files/audio/alert.wav")); QFile f(QCoreApplication::applicationDirPath() + QString("/files/audio/alert.wav"));
qDebug() << "FILE:" << f.fileName(); qDebug() << "FILE:" << f.fileName();
//m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str())); //m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
//m_media->play(); //m_media->play();
...@@ -337,13 +377,16 @@ QStringList GAudioOutput::listVoices(void) ...@@ -337,13 +377,16 @@ QStringList GAudioOutput::listVoices(void)
printf("Voices available: "); printf("Voices available: ");
for (v=flite_voice_list; v; v=val_cdr(v)) {
for (v = flite_voice_list; v; v = val_cdr(v))
{
voice = val_voice(val_car(v)); voice = val_voice(val_car(v));
QString s; QString s;
s.sprintf("%s",voice->name); s.sprintf("%s", voice->name);
printf("%s",voice->name); printf("%s", voice->name);
l.append(s); l.append(s);
} }
printf("\n"); printf("\n");
#endif #endif
......
...@@ -59,10 +59,21 @@ This file is part of the PIXHAWK project ...@@ -59,10 +59,21 @@ This file is part of the PIXHAWK project
extern "C" { extern "C" {
cst_voice *REGISTER_VOX(const char *voxdir); cst_voice *REGISTER_VOX(const char *voxdir);
void UNREGISTER_VOX(cst_voice *vox); void UNREGISTER_VOX(cst_voice *vox);
cst_voice* register_cmu_us_kal16(const char *voxdir); cst_voice *register_cmu_us_kal16(const char *voxdir);
} }
#endif #endif
#if _MSC_VER
// Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <sapi.h>
#endif
/** /**
* @brief Audio Output (speech synthesizer and "beep" output) * @brief Audio Output (speech synthesizer and "beep" output)
* This class follows the singleton design pattern * This class follows the singleton design pattern
...@@ -73,10 +84,11 @@ class GAudioOutput : public QObject ...@@ -73,10 +84,11 @@ class GAudioOutput : public QObject
Q_OBJECT Q_OBJECT
public: public:
/** @brief Get the singleton instance */ /** @brief Get the singleton instance */
static GAudioOutput* instance(); static GAudioOutput *instance();
/** @brief List available voices */ /** @brief List available voices */
QStringList listVoices(void); QStringList listVoices(void);
enum { enum
{
VOICE_MALE = 0, VOICE_MALE = 0,
VOICE_FEMALE VOICE_FEMALE
} QGVoice; } QGVoice;
...@@ -86,7 +98,7 @@ public: ...@@ -86,7 +98,7 @@ public:
public slots: public slots:
/** @brief Say this text if current output priority matches */ /** @brief Say this text if current output priority matches */
bool say(QString text, int severity=1); bool say(QString text, int severity = 1);
/** @brief Play alert sound and say notification message */ /** @brief Play alert sound and say notification message */
bool alert(QString text); bool alert(QString text);
/** @brief Start emergency sound */ /** @brief Start emergency sound */
...@@ -115,16 +127,20 @@ protected: ...@@ -115,16 +127,20 @@ protected:
#endif #endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
//cst_voice* voice; ///< The flite voice object //cst_voice* voice; ///< The flite voice object
#endif
#ifdef _MSC_VER
static ISpVoice *pVoice;
#endif #endif
int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms) int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms)
Phonon::MediaObject* m_media; ///< The output object for audio Phonon::MediaObject *m_media; ///< The output object for audio
Phonon::AudioOutput* m_audioOutput; Phonon::AudioOutput *m_audioOutput;
bool emergency; ///< Emergency status flag bool emergency; ///< Emergency status flag
QTimer* emergencyTimer; QTimer *emergencyTimer;
bool muted; bool muted;
private: private:
GAudioOutput(QObject* parent=NULL); GAudioOutput(QObject *parent = NULL);
// ~GAudioOutput(); ~GAudioOutput();
}; };
#endif // AUDIOOUTPUT_H #endif // AUDIOOUTPUT_H
...@@ -268,6 +268,20 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -268,6 +268,20 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
if (decodeState == 1) if (decodeState == 1)
{ {
decodedFirstPacket = true; decodedFirstPacket = true;
if(message.msgid == MAVLINK_MSG_ID_PING)
{
// process ping requests (tgt_system and tgt_comp must be zero)
mavlink_ping_t ping;
mavlink_msg_ping_decode(&message, &ping);
if(!ping.target_system && !ping.target_component)
{
mavlink_message_t msg;
mavlink_msg_ping_pack(getSystemId(), getComponentId(), &msg, ping.time_usec, ping.seq, message.sysid, message.compid);
sendMessage(msg);
}
}
#if defined(QGC_PROTOBUF_ENABLED) #if defined(QGC_PROTOBUF_ENABLED)
if (message.msgid == MAVLINK_MSG_ID_EXTENDED_MESSAGE) if (message.msgid == MAVLINK_MSG_ID_EXTENDED_MESSAGE)
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
explicit QGCComboBox(QWidget *parent = 0); explicit QGCComboBox(QWidget *parent = 0);
~QGCComboBox(); ~QGCComboBox();
virtual void setEditMode(bool editMode) override; virtual void setEditMode(bool editMode);
public slots: public slots:
/** @brief Queue parameter for sending to the MAV (add to pending list)*/ /** @brief Queue parameter for sending to the MAV (add to pending list)*/
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
explicit QGCCommandButton(QWidget *parent = 0); explicit QGCCommandButton(QWidget *parent = 0);
~QGCCommandButton(); ~QGCCommandButton();
virtual void setEditMode(bool editMode) override; virtual void setEditMode(bool editMode);
public slots: public slots:
void sendCommand(); void sendCommand();
......
...@@ -20,7 +20,7 @@ public: ...@@ -20,7 +20,7 @@ public:
explicit QGCParamSlider(QWidget *parent = 0); explicit QGCParamSlider(QWidget *parent = 0);
~QGCParamSlider(); ~QGCParamSlider();
virtual void setEditMode(bool editMode) override; virtual void setEditMode(bool editMode);
public slots: public slots:
/** @brief Queue parameter for sending to the MAV (add to pending list)*/ /** @brief Queue parameter for sending to the MAV (add to pending list)*/
......
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
~QGCTextLabel(); ~QGCTextLabel();
void setActiveUAS(UASInterface *uas); void setActiveUAS(UASInterface *uas);
void enableText(int num); void enableText(int num);
virtual void setEditMode(bool editMode) override; virtual void setEditMode(bool editMode);
public slots: public slots:
void writeSettings(QSettings& settings); void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings); void readSettings(const QSettings& settings);
......
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