Commit 3b928588 authored by Alejandro's avatar Alejandro

Resolved assignament and reading mode from UAS

parents ed323bbe a3db5ec5
......@@ -380,7 +380,8 @@ win32-g++ {
message(Building for Windows Platform (32bit))
# Special settings for debug
#CONFIG += CONSOLE
CONFIG += CONSOLE
OUTPUT += CONSOLE
INCLUDEPATH += $$BASEDIR/lib/sdl/include \
$$BASEDIR/lib/opal/include #\ #\
......
......@@ -65,8 +65,11 @@ This file is part of the QGROUNDCONTROL project
* @param argv The string array of parameters
**/
Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
{
// Set application name
this->setApplicationName(QGC_APPLICATION_NAME);
this->setApplicationVersion(QGC_APPLICATION_VERSION);
......
......@@ -39,6 +39,21 @@ This file is part of the QGROUNDCONTROL project
#undef main
#endif
// Install a message handler so you do not need
// the MSFT debug tools installed to se
// qDebug(), qWarning(), qCritical and qAbort
#ifdef Q_OS_WIN
void msgHandler( QtMsgType type, const char* msg )
{
const char symbols[] = { 'I', 'E', '!', 'X' };
QString output = QString("[%1] %2").arg( symbols[type] ).arg( msg );
std::cerr << output.toStdString() << std::endl;
if( type == QtFatalMsg ) abort();
}
#endif
/**
* @brief Starts the application
*
......@@ -46,9 +61,15 @@ This file is part of the QGROUNDCONTROL project
* @param argv Commandline arguments
* @return exit code, 0 for normal exit and !=0 for error cases
*/
int main(int argc, char *argv[])
{
// install the message handler
#ifdef Q_OS_WIN
qInstallMsgHandler( msgHandler );
#endif
Core core(argc, argv);
return core.exec();
}
......@@ -244,7 +244,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
mavlink_msg_sys_status_decode(&message, &state);
// FIXME
//qDebug() << "SYSTEM NAV MODE:" << state.nav_mode;
qDebug() << "1 SYSTEM STATUS:" << state.status;
QString audiostring = "System " + QString::number(this->getUASID());
QString stateAudio = "";
......@@ -264,6 +264,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
stateAudio = " changed status to " + uasState;
}
qDebug() << "1 SYSTEM MODE:" << state.mode;
qDebug() << "1 THIS MODE:" << this->mode;
if (this->mode != static_cast<unsigned int>(state.mode))
{
modechanged = true;
......@@ -305,6 +307,9 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
}
emit modeChanged(this->getUASID(), mode, "");
qDebug() << "2 SYSTEM MODE:" << mode;
modeAudio = " is now in " + mode;
}
currentVoltage = state.vbat/1000.0f;
......@@ -984,12 +989,16 @@ void UAS::setMode(int mode)
{
if ((uint8_t)mode >= MAV_MODE_LOCKED && (uint8_t)mode <= MAV_MODE_RC_TRAINING)
{
this->mode = mode;
//this->mode = mode; //no call assignament, update receive message from UAS
mavlink_message_t msg;
mavlink_msg_set_mode_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, (uint8_t)uasId, (uint8_t)mode);
sendMessage(msg);
qDebug() << "SENDING REQUEST TO SET MODE TO SYSTEM" << uasId << ", REQUEST TO SET MODE " << (uint8_t)mode;
}
else
{
qDebug() << "uas Mode not assign: " << mode;
}
}
void UAS::sendMessage(mavlink_message_t message)
......
......@@ -126,7 +126,7 @@ protected: //COMMENTS FOR TEST UNIT
double currentVoltage; ///< Voltage currently measured
float lpVoltage; ///< Low-pass filtered voltage
int timeRemaining; ///< Remaining time calculated based on previous and current
unsigned int mode; ///< The current mode of the MAV
//unsigned int mode; ///< The current mode of the MAV
int status; ///< The current status of the MAV
quint64 onboardTimeOffset;
......@@ -324,6 +324,9 @@ protected slots:
// MESSAGE RECEPTION
/** @brief Receive a named value message */
void receiveMessageNamedValue(const mavlink_message_t& message);
private:
unsigned int mode; ///< The current mode of the MAV
};
......
......@@ -41,6 +41,7 @@ This file is part of the PIXHAWK project
#include "UASControlWidget.h"
#include <UASManager.h>
#include <UAS.h>
#include "QGC.h"
#define CONTROL_MODE_LOCKED "MODE LOCKED"
#define CONTROL_MODE_MANUAL "MODE MANUAL"
......
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