Commit a347a659 authored by LM's avatar LM

Formatting, fixing audio alarms

parent 24560f76
...@@ -22,7 +22,6 @@ debug ...@@ -22,7 +22,6 @@ debug
release release
qgroundcontrol qgroundcontrol
mavlinkgen-build-desktop mavlinkgen-build-desktop
*.wav
qgroundcontrol.xcodeproj/** qgroundcontrol.xcodeproj/**
doc/html doc/html
doc/doxy.log doc/doxy.log
......
...@@ -81,8 +81,6 @@ macx|macx-g++42|macx-g++: { ...@@ -81,8 +81,6 @@ macx|macx-g++42|macx-g++: {
ICON = $$BASEDIR/images/icons/macx.icns ICON = $$BASEDIR/images/icons/macx.icns
# Copy audio files if needed
QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOS
# Copy contributed files # Copy contributed files
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/qgroundcontrol.app/Contents/MacOS QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/qgroundcontrol.app/Contents/MacOS
# Copy google earth starter file # Copy google earth starter file
...@@ -274,7 +272,6 @@ message("Compiling for linux 32") ...@@ -274,7 +272,6 @@ message("Compiling for linux 32")
} }
# Validated copy commands # Validated copy commands
QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR
QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR
...@@ -367,7 +364,6 @@ linux-g++-64 { ...@@ -367,7 +364,6 @@ linux-g++-64 {
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/debug QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/debug
} }
DESTDIR = $$TARGETDIR/debug DESTDIR = $$TARGETDIR/debug
QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/debug
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/debug QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/debug
QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/debug QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/debug
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/debug/images QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/debug/images
...@@ -378,7 +374,6 @@ linux-g++-64 { ...@@ -378,7 +374,6 @@ linux-g++-64 {
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/release QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/release
} }
DESTDIR = $$TARGETDIR/release DESTDIR = $$TARGETDIR/release
QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/release
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/release QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/release
QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/release QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/release
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/release/images QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/release/images
...@@ -455,7 +450,6 @@ DEFINES += QGC_OSG_ENABLED ...@@ -455,7 +450,6 @@ DEFINES += QGC_OSG_ENABLED
exists($$TARGETDIR/debug) { exists($$TARGETDIR/debug) {
QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\audio" "$$TARGETDIR_WIN\\debug\\audio" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\debug\\files" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\debug\\files" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\debug\\models" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\debug\\models" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n))
...@@ -476,7 +470,6 @@ DEFINES += QGC_OSG_ENABLED ...@@ -476,7 +470,6 @@ DEFINES += QGC_OSG_ENABLED
exists($$TARGETDIR/release) { exists($$TARGETDIR/release) {
QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\release"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\release"$$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\audio" "$$TARGETDIR_WIN\\release\\audio" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\release\\files" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\release\\files" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\release\\models" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\release\\models" /E /I $$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\release\\earth.html" $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\release\\earth.html" $$escape_expand(\\n))
...@@ -543,13 +536,13 @@ win32-g++ { ...@@ -543,13 +536,13 @@ win32-g++ {
message("Using cp to copy image and audio files to executable") message("Using cp to copy image and audio files to executable")
debug { debug {
QMAKE_POST_LINK += && cp $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/debug/SDL.dll QMAKE_POST_LINK += && cp $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/debug/SDL.dll
QMAKE_POST_LINK += && cp -r $$BASEDIR/audio $$TARGETDIR/debug/audio QMAKE_POST_LINK += && cp -r $$BASEDIR/files $$TARGETDIR/debug/files
QMAKE_POST_LINK += && cp -r $$BASEDIR/models $$TARGETDIR/debug/models QMAKE_POST_LINK += && cp -r $$BASEDIR/models $$TARGETDIR/debug/models
} }
release { release {
QMAKE_POST_LINK += && cp $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/release/SDL.dll QMAKE_POST_LINK += && cp $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/release/SDL.dll
QMAKE_POST_LINK += && cp -r $$BASEDIR/audio $$TARGETDIR/release/audio QMAKE_POST_LINK += && cp -r $$BASEDIR/files $$TARGETDIR/release/files
QMAKE_POST_LINK += && cp -r $$BASEDIR/models $$TARGETDIR/release/models QMAKE_POST_LINK += && cp -r $$BASEDIR/models $$TARGETDIR/release/models
} }
...@@ -561,14 +554,14 @@ win32-g++ { ...@@ -561,14 +554,14 @@ win32-g++ {
exists($$TARGETDIR/debug) { exists($$TARGETDIR/debug) {
QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll\" \"$$TARGETDIR_WIN\\debug\\SDL.dll\" QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll\" \"$$TARGETDIR_WIN\\debug\\SDL.dll\"
QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\audio\" \"$$TARGETDIR_WIN\\debug\\audio\\\" /S /E /Y QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\files\" \"$$TARGETDIR_WIN\\debug\\files\\\" /S /E /Y
QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\models\" \"$$TARGETDIR_WIN\\debug\\models\\\" /S /E /Y QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\models\" \"$$TARGETDIR_WIN\\debug\\models\\\" /S /E /Y
QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\images\\earth.html\" \"$$TARGETDIR_WIN\\debug\\earth.html\" QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\images\\earth.html\" \"$$TARGETDIR_WIN\\debug\\earth.html\"
} }
exists($$TARGETDIR/release) { exists($$TARGETDIR/release) {
QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll\" \"$$TARGETDIR_WIN\\release\\SDL.dll\" QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll\" \"$$TARGETDIR_WIN\\release\\SDL.dll\"
QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\audio\" \"$$TARGETDIR_WIN\\release\\audio\\\" /S /E /Y QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\files\" \"$$TARGETDIR_WIN\\release\\files\\\" /S /E /Y
QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\models\" \"$$TARGETDIR_WIN\\release\\models\\\" /S /E /Y QMAKE_POST_LINK += && xcopy \"$$BASEDIR_WIN\\models\" \"$$TARGETDIR_WIN\\release\\models\\\" /S /E /Y
QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\images\\earth.html\" \"$$TARGETDIR_WIN\\release\\earth.html\" QMAKE_POST_LINK += && copy /Y \"$$BASEDIR_WIN\\images\\earth.html\" \"$$TARGETDIR_WIN\\release\\earth.html\"
} }
......
...@@ -77,7 +77,8 @@ extern "C" { ...@@ -77,7 +77,8 @@ extern "C" {
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
...@@ -106,12 +107,16 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), ...@@ -106,12 +107,16 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent),
#if _MSC_VER2 #if _MSC_VER2
ISpVoice * 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"Hello world", 0, NULL);
pVoice->Release(); pVoice->Release();
pVoice = NULL; pVoice = NULL;
...@@ -146,7 +151,8 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), ...@@ -146,7 +151,8 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent),
void GAudioOutput::mute(bool mute) void GAudioOutput::mute(bool mute)
{ {
if (mute != muted) { if (mute != muted)
{
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);
...@@ -162,11 +168,13 @@ bool GAudioOutput::isMuted() ...@@ -162,11 +168,13 @@ bool GAudioOutput::isMuted()
bool GAudioOutput::say(QString text, int severity) bool GAudioOutput::say(QString text, int severity)
{ {
if (!muted) { if (!muted)
{
// 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_VER2
...@@ -202,7 +210,9 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -202,7 +210,9 @@ bool GAudioOutput::say(QString text, int severity)
#endif #endif
} }
return res; return res;
} else { }
else
{
return false; return false;
} }
} }
...@@ -212,22 +222,26 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -212,22 +222,26 @@ bool GAudioOutput::say(QString text, int severity)
*/ */
bool GAudioOutput::alert(QString text) bool GAudioOutput::alert(QString text)
{ {
if (!emergency || !muted) { if (!emergency || !muted)
{
// Play alert sound // Play alert sound
beep(); beep();
// Say alert message // Say alert message
say(text, 2); say(text, 2);
return true; return true;
} else { }
else
{
return false; return false;
} }
} }
void GAudioOutput::notifyPositive() 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("/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();
} }
...@@ -235,9 +249,10 @@ void GAudioOutput::notifyPositive() ...@@ -235,9 +249,10 @@ void GAudioOutput::notifyPositive()
void GAudioOutput::notifyNegative() 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("/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();
} }
...@@ -252,7 +267,8 @@ void GAudioOutput::notifyNegative() ...@@ -252,7 +267,8 @@ void GAudioOutput::notifyNegative()
*/ */
bool GAudioOutput::startEmergency() 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();
...@@ -279,9 +295,10 @@ bool GAudioOutput::stopEmergency() ...@@ -279,9 +295,10 @@ bool GAudioOutput::stopEmergency()
void GAudioOutput::beep() 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("/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();
......
...@@ -678,8 +678,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -678,8 +678,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
int bufferlength = 0; int bufferlength = 0;
// Output all bytes as hex digits // Output all bytes as hex digits
int i; for (int i=0; i<size; i++)
for (i=0; i<size; i++)
{ {
if (mavlink_parse_char(this->id, data[i], &msg, &comm)) if (mavlink_parse_char(this->id, data[i], &msg, &comm))
{ {
...@@ -687,16 +686,19 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -687,16 +686,19 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
qDebug() << "SIMULATION LINK RECEIVED MESSAGE!"; qDebug() << "SIMULATION LINK RECEIVED MESSAGE!";
emit messageReceived(msg); emit messageReceived(msg);
switch (msg.msgid) { switch (msg.msgid)
{
// SET THE SYSTEM MODE // SET THE SYSTEM MODE
case MAVLINK_MSG_ID_SET_MODE: { case MAVLINK_MSG_ID_SET_MODE:
{
mavlink_set_mode_t mode; mavlink_set_mode_t mode;
mavlink_msg_set_mode_decode(&msg, &mode); mavlink_msg_set_mode_decode(&msg, &mode);
// Set mode indepent of mode.target // Set mode indepent of mode.target
system.base_mode = mode.base_mode; system.base_mode = mode.base_mode;
} }
break; break;
case MAVLINK_MSG_ID_SET_LOCAL_POSITION_SETPOINT: { case MAVLINK_MSG_ID_SET_LOCAL_POSITION_SETPOINT:
{
mavlink_set_local_position_setpoint_t set; mavlink_set_local_position_setpoint_t set;
mavlink_msg_set_local_position_setpoint_decode(&msg, &set); mavlink_msg_set_local_position_setpoint_decode(&msg, &set);
spX = set.x; spX = set.x;
...@@ -714,7 +716,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -714,7 +716,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
} }
break; break;
// EXECUTE OPERATOR ACTIONS // EXECUTE OPERATOR ACTIONS
case MAVLINK_MSG_ID_COMMAND_LONG: { case MAVLINK_MSG_ID_COMMAND_LONG:
{
mavlink_command_long_t action; mavlink_command_long_t action;
mavlink_msg_command_long_decode(&msg, &action); mavlink_msg_command_long_decode(&msg, &action);
...@@ -756,44 +759,48 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -756,44 +759,48 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
} }
break; break;
#endif #endif
case MAVLINK_MSG_ID_PARAM_REQUEST_LIST: { case MAVLINK_MSG_ID_PARAM_REQUEST_LIST:
{
qDebug() << "GCS REQUESTED PARAM LIST FROM SIMULATION"; qDebug() << "GCS REQUESTED PARAM LIST FROM SIMULATION";
mavlink_param_request_list_t read; mavlink_param_request_list_t read;
mavlink_msg_param_request_list_decode(&msg, &read); mavlink_msg_param_request_list_decode(&msg, &read);
// if (read.target_system == systemId) if (read.target_system == systemId)
// { {
// Output all params // Output all params
// Iterate through all components, through all parameters and emit them // Iterate through all components, through all parameters and emit them
QMap<QString, float>::iterator i; QMap<QString, float>::iterator i;
// Iterate through all components / subsystems // Iterate through all components / subsystems
int j = 0; int j = 0;
for (i = onboardParams.begin(); i != onboardParams.end(); ++i) { for (i = onboardParams.begin(); i != onboardParams.end(); ++i) {
if (j != 5) { if (j != 5) {
// Pack message and get size of encoded byte string // Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(read.target_system, componentId, &msg, i.key().toStdString().c_str(), i.value(), MAVLINK_TYPE_FLOAT, onboardParams.size(), j); mavlink_msg_param_value_pack(read.target_system, componentId, &msg, i.key().toStdString().c_str(), i.value(), MAVLINK_TYPE_FLOAT, onboardParams.size(), j);
// Allocate buffer with packet data // Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg); bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream //add data into datastream
memcpy(stream+streampointer,buffer, bufferlength); memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength; streampointer+=bufferlength;
}
j++;
} }
j++;
}
qDebug() << "SIMULATION SENT PARAMETERS TO GCS"; qDebug() << "SIMULATION SENT PARAMETERS TO GCS";
// } }
} }
break; break;
case MAVLINK_MSG_ID_PARAM_SET: { case MAVLINK_MSG_ID_PARAM_SET:
{
// Drop on even milliseconds // Drop on even milliseconds
if (QGC::groundTimeMilliseconds() % 2 == 0) { if (QGC::groundTimeMilliseconds() % 2 == 0)
{
qDebug() << "SIMULATION RECEIVED COMMAND TO SET PARAMETER"; qDebug() << "SIMULATION RECEIVED COMMAND TO SET PARAMETER";
mavlink_param_set_t set; mavlink_param_set_t set;
mavlink_msg_param_set_decode(&msg, &set); mavlink_msg_param_set_decode(&msg, &set);
// if (set.target_system == systemId) // if (set.target_system == systemId)
// { // {
QString key = QString((char*)set.param_id); QString key = QString((char*)set.param_id);
if (onboardParams.contains(key)) { if (onboardParams.contains(key))
{
onboardParams.remove(key); onboardParams.remove(key);
onboardParams.insert(key, set.param_value); onboardParams.insert(key, set.param_value);
...@@ -809,13 +816,15 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -809,13 +816,15 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
} }
} }
break; break;
case MAVLINK_MSG_ID_PARAM_REQUEST_READ: { case MAVLINK_MSG_ID_PARAM_REQUEST_READ:
{
qDebug() << "SIMULATION RECEIVED COMMAND TO SEND PARAMETER"; qDebug() << "SIMULATION RECEIVED COMMAND TO SEND PARAMETER";
mavlink_param_request_read_t read; mavlink_param_request_read_t read;
mavlink_msg_param_request_read_decode(&msg, &read); mavlink_msg_param_request_read_decode(&msg, &read);
QByteArray bytes((char*)read.param_id, MAVLINK_MSG_PARAM_REQUEST_READ_FIELD_PARAM_ID_LEN); QByteArray bytes((char*)read.param_id, MAVLINK_MSG_PARAM_REQUEST_READ_FIELD_PARAM_ID_LEN);
QString key = QString(bytes); QString key = QString(bytes);
if (onboardParams.contains(key)) { if (onboardParams.contains(key))
{
float paramValue = onboardParams.value(key); float paramValue = onboardParams.value(key);
// Pack message and get size of encoded byte string // Pack message and get size of encoded byte string
...@@ -826,7 +835,9 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -826,7 +835,9 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
memcpy(stream+streampointer,buffer, bufferlength); memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength; streampointer+=bufferlength;
//qDebug() << "Sending PARAM" << key; //qDebug() << "Sending PARAM" << key;
} else if (read.param_index < onboardParams.size()) { }
else if (read.param_index < onboardParams.size())
{
key = onboardParams.keys().at(read.param_index); key = onboardParams.keys().at(read.param_index);
float paramValue = onboardParams.value(key); float paramValue = onboardParams.value(key);
...@@ -842,8 +853,6 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -842,8 +853,6 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
} }
break; break;
} }
} }
unsigned char v=data[i]; unsigned char v=data[i];
fprintf(stderr,"%02x ", v); fprintf(stderr,"%02x ", v);
...@@ -851,7 +860,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -851,7 +860,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
fprintf(stderr,"\n"); fprintf(stderr,"\n");
readyBufferMutex.lock(); readyBufferMutex.lock();
for (int i = 0; i < streampointer; i++) { for (int i = 0; i < streampointer; i++)
{
readyBuffer.enqueue(*(stream + i)); readyBuffer.enqueue(*(stream + i));
} }
readyBufferMutex.unlock(); readyBufferMutex.unlock();
......
This diff is collapsed.
...@@ -218,7 +218,8 @@ protected: //COMMENTS FOR TEST UNIT ...@@ -218,7 +218,8 @@ protected: //COMMENTS FOR TEST UNIT
bool batteryRemainingEstimateEnabled; ///< If the estimate is enabled, QGC will try to estimate the remaining battery life bool batteryRemainingEstimateEnabled; ///< If the estimate is enabled, QGC will try to estimate the remaining battery life
float chargeLevel; ///< Charge level of battery, in percent float chargeLevel; ///< Charge level of battery, in percent
int timeRemaining; ///< Remaining time calculated based on previous and current int timeRemaining; ///< Remaining time calculated based on previous and current
uint8_t mode; ///< The current mode of the MAV uint8_t mode; ///< The current mode of the MAV
uint32_t custom_mode; ///< The current mode of the MAV
int status; ///< The current status of the MAV int status; ///< The current status of the MAV
uint32_t navMode; ///< The current navigation mode of the MAV uint32_t navMode; ///< The current navigation mode of the MAV
quint64 onboardTimeOffset; quint64 onboardTimeOffset;
......
...@@ -104,6 +104,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) : ...@@ -104,6 +104,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
leftDragStarted(false), leftDragStarted(false),
mouseHasMoved(false), mouseHasMoved(false),
actionPending(false), actionPending(false),
directSending(false),
userSetPointSet(false), userSetPointSet(false),
userXYSetPointSet(false) userXYSetPointSet(false)
{ {
...@@ -637,37 +638,53 @@ void HSIDisplay::keyPressEvent(QKeyEvent* event) ...@@ -637,37 +638,53 @@ void HSIDisplay::keyPressEvent(QKeyEvent* event)
statusClearTimer.start(); statusClearTimer.start();
sendBodySetPointCoordinates(); sendBodySetPointCoordinates();
} }
else if ((event->key() == Qt::Key_Up)) else if ((event->key() == Qt::Key_W))
{ {
setBodySetpointCoordinateXY(0.5, 0); setBodySetpointCoordinateXY(1.0, 0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_Down)) else if ((event->key() == Qt::Key_S))
{ {
setBodySetpointCoordinateXY(-0.5, 0); setBodySetpointCoordinateXY(-1.0, 0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_Left)) else if ((event->key() == Qt::Key_A))
{ {
setBodySetpointCoordinateXY(0, -0.5); setBodySetpointCoordinateXY(0, -1.0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_Right)) else if ((event->key() == Qt::Key_D))
{ {
setBodySetpointCoordinateXY(0, 0.5); setBodySetpointCoordinateXY(0, 1.0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_Plus)) else if ((event->key() == Qt::Key_Up))
{ {
setBodySetpointCoordinateZ(-0.2); setBodySetpointCoordinateXY(0, 0);
setBodySetpointCoordinateZ(-0.5+uas->getLocalZ());
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_Minus)) else if ((event->key() == Qt::Key_Down))
{ {
setBodySetpointCoordinateZ(+0.2); setBodySetpointCoordinateZ(+0.5+uas->getLocalZ());
setBodySetpointCoordinateXY(0, 0);
setBodySetpointCoordinateYaw(uas->getYaw());
} }
else if ((event->key() == Qt::Key_L)) else if ((event->key() == Qt::Key_Left))
{ {
setBodySetpointCoordinateYaw(-0.1); setBodySetpointCoordinateXY(0, 0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(-0.2+uas->getYaw());
} }
else if ((event->key() == Qt::Key_R)) else if ((event->key() == Qt::Key_Right))
{ {
setBodySetpointCoordinateYaw(0.1); setBodySetpointCoordinateXY(0, 0);
setBodySetpointCoordinateZ(uas->getLocalZ());
setBodySetpointCoordinateYaw(0.2+uas->getYaw());
} }
HDDisplay::keyPressEvent(event); HDDisplay::keyPressEvent(event);
} }
...@@ -811,7 +828,7 @@ void HSIDisplay::sendBodySetPointCoordinates() ...@@ -811,7 +828,7 @@ void HSIDisplay::sendBodySetPointCoordinates()
double dx = uiXSetCoordinate - uas->getLocalX(); double dx = uiXSetCoordinate - uas->getLocalX();
double dy = uiYSetCoordinate - uas->getLocalY(); double dy = uiYSetCoordinate - uas->getLocalY();
double dz = uiZSetCoordinate - uas->getLocalZ(); double dz = uiZSetCoordinate - uas->getLocalZ();
bool valid = (sqrt(dx*dx + dy*dy + dz*dz) < 1.0);//UASManager::instance()->isInLocalNEDSafetyLimits(uiXSetCoordinate, uiYSetCoordinate, uiZSetCoordinate); bool valid = (sqrt(dx*dx + dy*dy + dz*dz) < 3.0);//UASManager::instance()->isInLocalNEDSafetyLimits(uiXSetCoordinate, uiYSetCoordinate, uiZSetCoordinate);
if (valid) if (valid)
{ {
uas->setLocalPositionSetpoint(uiXSetCoordinate, uiYSetCoordinate, uiZSetCoordinate, uiYawSet); uas->setLocalPositionSetpoint(uiXSetCoordinate, uiYSetCoordinate, uiZSetCoordinate, uiYawSet);
......
...@@ -175,6 +175,7 @@ protected: ...@@ -175,6 +175,7 @@ protected:
QTimer statusClearTimer; QTimer statusClearTimer;
QString statusMessage; QString statusMessage;
bool actionPending; bool actionPending;
bool directSending;
/** /**
* @brief Private data container class to be used within the HSI widget * @brief Private data container class to be used within the HSI widget
......
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