Commit c51815fa authored by Bryant Mairs's avatar Bryant Mairs

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

parents 6ba95152 a88e7546
......@@ -14,6 +14,7 @@ bin/*.exe
bin/*.txt
bin/mac
*pro.user*
.qmake.stash
qrc_*.cpp
*.Debug
*.Release
......
......@@ -269,9 +269,6 @@ FORMS += \
src/ui/QMap3D.ui \
src/ui/QGCWebView.ui \
src/ui/map3D/QGCGoogleEarthView.ui \
src/ui/SlugsDataSensorView.ui \
src/ui/SlugsHilSim.ui \
src/ui/SlugsPadCameraControl.ui \
src/ui/uas/QGCUnconnectedInfoWidget.ui \
src/ui/designer/QGCToolWidget.ui \
src/ui/designer/QGCParamSlider.ui \
......@@ -407,7 +404,6 @@ HEADERS += \
src/ui/QGCParamWidget.h \
src/ui/QGCSensorSettingsWidget.h \
src/ui/linechart/Linecharts.h \
src/uas/SlugsMAV.h \
src/uas/PxQuadMAV.h \
src/uas/ArduPilotMegaMAV.h \
src/uas/senseSoarMAV.h \
......@@ -431,9 +427,6 @@ HEADERS += \
src/comm/QGCMAVLink.h \
src/ui/QGCWebView.h \
src/ui/map3D/QGCWebPage.h \
src/ui/SlugsDataSensorView.h \
src/ui/SlugsHilSim.h \
src/ui/SlugsPadCameraControl.h \
src/ui/QGCMainWindowAPConfigurator.h \
src/comm/MAVLinkSwarmSimulationLink.h \
src/ui/uas/QGCUnconnectedInfoWidget.h \
......@@ -601,7 +594,6 @@ SOURCES += \
src/ui/QGCParamWidget.cc \
src/ui/QGCSensorSettingsWidget.cc \
src/ui/linechart/Linecharts.cc \
src/uas/SlugsMAV.cc \
src/uas/PxQuadMAV.cc \
src/uas/ArduPilotMegaMAV.cc \
src/uas/senseSoarMAV.cpp \
......@@ -624,9 +616,6 @@ SOURCES += \
src/ui/RadioCalibration/RadioCalibrationData.cc \
src/ui/QGCWebView.cc \
src/ui/map3D/QGCWebPage.cc \
src/ui/SlugsDataSensorView.cc \
src/ui/SlugsHilSim.cc \
src/ui/SlugsPadCameraControl.cpp \
src/ui/QGCMainWindowAPConfigurator.cc \
src/comm/MAVLinkSwarmSimulationLink.cc \
src/ui/uas/QGCUnconnectedInfoWidget.cc \
......@@ -767,7 +756,8 @@ HEADERS += \
src/qgcunittest/FlightModeConfigTest.h \
src/qgcunittest/FlightGearTest.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h
src/qgcunittest/TCPLoopBackServer.h \
src/qgcunittest/QGCUASFileManagerTest.h
SOURCES += \
src/qgcunittest/UASUnitTest.cc \
......@@ -779,4 +769,5 @@ SOURCES += \
src/qgcunittest/FlightModeConfigTest.cc \
src/qgcunittest/FlightGearTest.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc
src/qgcunittest/TCPLoopBackServer.cc \
src/qgcunittest/QGCUASFileManagerTest.cc
......@@ -24,7 +24,6 @@
#include "UASManager.h"
#include "UASInterface.h"
#include "UAS.h"
#include "SlugsMAV.h"
#include "PxQuadMAV.h"
#include "ArduPilotMegaMAV.h"
#include "configuration.h"
......
......@@ -281,7 +281,7 @@ void MockMavlinkFileServer::_emitResponse(QGCUASFileManager::Request* request)
request->hdr.crc32 = QGCUASFileManager::crc32(request);
mavlink_msg_encapsulated_data_pack(250, 0, &mavlinkMessage, 0 /*_encdata_seq*/, (uint8_t*)request);
mavlink_msg_encapsulated_data_pack(250, MAV_COMP_ID_IMU, &mavlinkMessage, 0 /*_encdata_seq*/, (uint8_t*)request);
emit messageReceived(NULL, mavlinkMessage);
}
......@@ -96,6 +96,7 @@ bool MultiSignalSpy::checkSignalByMask(quint16 mask)
Q_ASSERT(spy != NULL);
if (spy->count() != 1) {
_printSignalState();
return false;
}
}
......@@ -114,10 +115,12 @@ bool MultiSignalSpy::checkOnlySignalByMask(quint16 mask)
if ((1 << i) & mask) {
if (spy->count() != 1) {
_printSignalState();
return false;
}
} else {
if (spy->count() != 0) {
_printSignalState();
return false;
}
}
......@@ -135,6 +138,7 @@ bool MultiSignalSpy::checkNoSignalByMask(quint16 mask)
Q_ASSERT(spy != NULL);
if (spy->count() != 0) {
_printSignalState();
return false;
}
}
......@@ -232,3 +236,12 @@ bool MultiSignalSpy::waitForSignalByIndex(
return spy->count() != 0;
}
void MultiSignalSpy::_printSignalState(void)
{
for (size_t i=0; i<_cSignals; i++) {
QSignalSpy* spy = _rgSpys[i];
Q_ASSERT(spy != NULL);
qDebug() << "Signal index:" << i << "count:" << spy->count();
}
}
......@@ -59,6 +59,8 @@ public:
private:
// QObject overrides
void timerEvent(QTimerEvent * event);
void _printSignalState(void);
QObject* _signalEmitter;
const char** _rgSignals;
......
......@@ -53,6 +53,7 @@ void QGCUASFileManagerUnitTest::init(void)
bool connected = connect(&_mockFileServer, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), _fileManager, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
Q_ASSERT(connected);
Q_UNUSED(connected); // Silent release build compiler warning
connected = connect(_fileManager, SIGNAL(statusMessage(const QString&)), this, SLOT(statusMessage(const QString&)));
Q_ASSERT(connected);
......
......@@ -150,7 +150,7 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
QCOMPARE(_link->connect(), true);
// Make sure we get the two different connected signals
QCOMPARE(_multiSpy->waitForSignalByIndex(connectedSignalIndex, 1000), true);
QCOMPARE(_multiSpy->waitForSignalByIndex(connectedSignalIndex, 10000), true);
QCOMPARE(_multiSpy->checkOnlySignalByMask(connectedSignalMask | connected2SignalMask), true);
QList<QVariant> arguments = _multiSpy->getSpyByIndex(connected2SignalIndex)->takeFirst();
QCOMPARE(arguments.at(0).toBool(), true);
......
......@@ -67,20 +67,6 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte
uas = px4;
}
break;
case MAV_AUTOPILOT_SLUGS:
{
SlugsMAV* mav = new SlugsMAV(mavlink, worker, sysid);
// Set the system type
mav->setSystemType((int)heartbeat->type);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
// packets never reach their goal)
connect(mavlink, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), mav, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
uas = mav;
}
break;
case MAV_AUTOPILOT_ARDUPILOTMEGA:
{
ArduPilotMegaMAV* mav = new ArduPilotMegaMAV(mavlink, worker, sysid);
......
......@@ -10,7 +10,6 @@
// INCLUDE ALL MAV/UAS CLASSES USING MAVLINK
#include "UAS.h"
#include "SlugsMAV.h"
#include "PxQuadMAV.h"
#include "senseSoarMAV.h"
#include "ArduPilotMegaMAV.h"
......
#include "SlugsMAV.h"
#include <QDebug>
SlugsMAV::SlugsMAV(MAVLinkProtocol* mavlink, QThread* thread, int id) :
UAS(mavlink, thread, id)
{
widgetTimer = new QTimer (this);
widgetTimer->setInterval(SLUGS_UPDATE_RATE);
connect (widgetTimer, SIGNAL(timeout()), this, SLOT(emitSignals()));
widgetTimer->start();
memset(&mlRawImuData ,0, sizeof(mavlink_raw_imu_t));// clear all the state structures
#ifdef MAVLINK_ENABLED_SLUGS
memset(&mlGpsData, 0, sizeof(mavlink_gps_raw_t));
memset(&mlCpuLoadData, 0, sizeof(mavlink_cpu_load_t));
memset(&mlAirData, 0, sizeof(mavlink_air_data_t));
memset(&mlSensorBiasData, 0, sizeof(mavlink_sensor_bias_t));
memset(&mlDiagnosticData, 0, sizeof(mavlink_diagnostic_t));
memset(&mlBoot ,0, sizeof(mavlink_boot_t));
memset(&mlGpsDateTime ,0, sizeof(mavlink_gps_date_time_t));
memset(&mlApMode ,0, sizeof(mavlink_set_mode_t));
memset(&mlNavigation ,0, sizeof(mavlink_slugs_navigation_t));
memset(&mlDataLog ,0, sizeof(mavlink_data_log_t));
memset(&mlPassthrough ,0, sizeof(mavlink_ctrl_srfc_pt_t));
memset(&mlActionAck,0, sizeof(mavlink_action_ack_t));
memset(&mlAction ,0, sizeof(mavlink_slugs_action_t));
memset(&mlScaled ,0, sizeof(mavlink_scaled_imu_t));
memset(&mlServo ,0, sizeof(mavlink_servo_output_raw_t));
memset(&mlChannels ,0, sizeof(mavlink_rc_channels_raw_t));
updateRoundRobin = 0;
uasId = id;
#endif
}
/**
* This function is called by MAVLink once a complete, uncorrupted (CRC check valid)
* mavlink packet is received.
*
* @param link Hardware link the message came from (e.g. /dev/ttyUSB0 or UDP port).
* messages can be sent back to the system via this link
* @param message MAVLink message, as received from the MAVLink protocol stack
*/
void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
{
UAS::receiveMessage(link, message);// Let UAS handle the default message set
if (message.sysid == uasId) {
#ifdef MAVLINK_ENABLED_SLUGS// Handle your special messages mavlink_message_t* msg = &message;
switch (message.msgid) {
case MAVLINK_MSG_ID_RAW_IMU:
mavlink_msg_raw_imu_decode(&message, &mlRawImuData);
break;
case MAVLINK_MSG_ID_BOOT:
mavlink_msg_boot_decode(&message,&mlBoot);
emit slugsBootMsg(uasId, mlBoot);
break;
case MAVLINK_MSG_ID_ATTITUDE:
mavlink_msg_attitude_decode(&message, &mlAttitude);
break;
case MAVLINK_MSG_ID_GPS_RAW:
mavlink_msg_gps_raw_decode(&message, &mlGpsData);
break;
case MAVLINK_MSG_ID_CPU_LOAD: //170
mavlink_msg_cpu_load_decode(&message,&mlCpuLoadData);
break;
case MAVLINK_MSG_ID_AIR_DATA: //171
mavlink_msg_air_data_decode(&message,&mlAirData);
break;
case MAVLINK_MSG_ID_SENSOR_BIAS: //172
mavlink_msg_sensor_bias_decode(&message,&mlSensorBiasData);
break;
case MAVLINK_MSG_ID_DIAGNOSTIC: //173
mavlink_msg_diagnostic_decode(&message,&mlDiagnosticData);
break;
case MAVLINK_MSG_ID_SLUGS_NAVIGATION://176
mavlink_msg_slugs_navigation_decode(&message,&mlNavigation);
break;
case MAVLINK_MSG_ID_DATA_LOG: //177
mavlink_msg_data_log_decode(&message,&mlDataLog);
break;
case MAVLINK_MSG_ID_GPS_DATE_TIME: //179
mavlink_msg_gps_date_time_decode(&message,&mlGpsDateTime);
break;
case MAVLINK_MSG_ID_MID_LVL_CMDS: //180
mavlink_msg_mid_lvl_cmds_decode(&message, &mlMidLevelCommands);
break;
case MAVLINK_MSG_ID_CTRL_SRFC_PT: //181
mavlink_msg_ctrl_srfc_pt_decode(&message, &mlPassthrough);
break;
case MAVLINK_MSG_ID_SLUGS_ACTION: //183
mavlink_msg_slugs_action_decode(&message, &mlAction);
break;
case MAVLINK_MSG_ID_SCALED_IMU:
mavlink_msg_scaled_imu_decode(&message, &mlScaled);
break;
case MAVLINK_MSG_ID_SERVO_OUTPUT_RAW:
mavlink_msg_servo_output_raw_decode(&message, &mlServo);
break;
case MAVLINK_MSG_ID_RC_CHANNELS_RAW:
mavlink_msg_rc_channels_raw_decode(&message, &mlChannels);
break;
switch (mlAction.actionId) {
case SLUGS_ACTION_EEPROM:
if (mlAction.actionVal == SLUGS_ACTION_FAIL) {
emit textMessageReceived(message.sysid, message.compid, MAV_SEVERITY_ERROR, "EEPROM Write Fail, Data was not saved in Memory!");
}
break;
case SLUGS_ACTION_PT_CHANGE:
if (mlAction.actionVal == SLUGS_ACTION_SUCCESS) {
emit textMessageReceived(message.sysid, message.compid, MAV_SEVERITY_INFO, "Passthrough Succesfully Changed");
}
break;
case SLUGS_ACTION_MLC_CHANGE:
if (mlAction.actionVal == SLUGS_ACTION_SUCCESS) {
emit textMessageReceived(message.sysid, message.compid, MAV_SEVERITY_INFO, "Mid-level Commands Succesfully Changed");
}
break;
}
//break;
default:
// qDebug() << "\nSLUGS RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
#endif
}
}
void SlugsMAV::emitSignals (void)
{
#ifdef MAVLINK_ENABLED_SLUGS
switch(updateRoundRobin) {
case 1:
emit slugsCPULoad(uasId, mlCpuLoadData);
emit slugsSensorBias(uasId,mlSensorBiasData);
break;
case 2:
emit slugsAirData(uasId, mlAirData);
emit slugsDiagnostic(uasId,mlDiagnosticData);
break;
case 3:
emit slugsNavegation(uasId, mlNavigation);
emit slugsDataLog(uasId, mlDataLog);
break;
case 4:
emit slugsGPSDateTime(uasId, mlGpsDateTime);
break;
case 5:
emit slugsActionAck(uasId,mlActionAck);
emit emitGpsSignals();
break;
case 6:
emit slugsChannels(uasId, mlChannels);
emit slugsServo(uasId, mlServo);
emit slugsScaled(uasId, mlScaled);
break;
}
emit slugsAttitude(uasId, mlAttitude);
emit attitudeChanged(this,
mlAttitude.roll,
mlAttitude.pitch,
mlAttitude.yaw,
0.0);
#endif
emit slugsRawImu(uasId, mlRawImuData);
// wrap around
updateRoundRobin = updateRoundRobin > 10? 1: updateRoundRobin + 1;
}
#ifdef MAVLINK_ENABLED_SLUGS
void SlugsMAV::emitGpsSignals (void)
{
// qDebug()<<"After Emit GPS Signal"<<mlGpsData.fix_type;
//ToDo Uncomment if. it was comment only to test
// if (mlGpsData.fix_type > 0){
emit globalPositionChanged(this,
mlGpsData.lon,
mlGpsData.lat,
mlGpsData.alt,
0.0);
emit slugsGPSCogSog(uasId,mlGpsData.hdg, mlGpsData.v);
}
#endif // MAVLINK_ENABLED_SLUGS
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef SLUGSMAV_H
#define SLUGSMAV_H
#include "UAS.h"
#include "mavlink.h"
#include <QTimer>
#define SLUGS_UPDATE_RATE 200 // in ms
class SlugsMAV : public UAS
{
Q_OBJECT
Q_INTERFACES(UASInterface)
enum SLUGS_ACTION {
SLUGS_ACTION_NONE,
SLUGS_ACTION_SUCCESS,
SLUGS_ACTION_FAIL,
SLUGS_ACTION_EEPROM,
SLUGS_ACTION_MODE_CHANGE,
SLUGS_ACTION_MODE_REPORT,
SLUGS_ACTION_PT_CHANGE,
SLUGS_ACTION_PT_REPORT,
SLUGS_ACTION_PID_CHANGE,
SLUGS_ACTION_PID_REPORT,
SLUGS_ACTION_WP_CHANGE,
SLUGS_ACTION_WP_REPORT,
SLUGS_ACTION_MLC_CHANGE,
SLUGS_ACTION_MLC_REPORT
};
public:
SlugsMAV(MAVLinkProtocol* mavlink, QThread* thread, int id = 0);
public slots:
/** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
void emitSignals (void);
signals:
void slugsRawImu(int uasId, const mavlink_raw_imu_t& rawData);
void slugsGPSCogSog(int uasId, double cog, double sog);
#ifdef MAVLINK_ENABLED_SLUGS
void slugsCPULoad(int systemId, const mavlink_cpu_load_t& cpuLoad);
void slugsAirData(int systemId, const mavlink_air_data_t& airData);
void slugsSensorBias(int systemId, const mavlink_sensor_bias_t& sensorBias);
void slugsDiagnostic(int systemId, const mavlink_diagnostic_t& diagnostic);
void slugsNavegation(int systemId, const mavlink_slugs_navigation_t& slugsNavigation);
void slugsDataLog(int systemId, const mavlink_data_log_t& dataLog);
void slugsGPSDateTime(int systemId, const mavlink_gps_date_time_t& gpsDateTime);
void slugsActionAck(int systemId, const mavlink_action_ack_t& actionAck);
void slugsBootMsg(int uasId, mavlink_boot_t& boot);
void slugsAttitude(int uasId, mavlink_attitude_t& attitude);
void slugsScaled(int uasId, const mavlink_scaled_imu_t& scaled);
void slugsServo(int uasId, const mavlink_servo_output_raw_t& servo);
void slugsChannels(int uasId, const mavlink_rc_channels_raw_t& channels);
#endif
protected:
unsigned char updateRoundRobin;
QTimer* widgetTimer;
mavlink_raw_imu_t mlRawImuData;
#ifdef MAVLINK_ENABLED_SLUGS
mavlink_gps_raw_t mlGpsData;
mavlink_attitude_t mlAttitude;
mavlink_cpu_load_t mlCpuLoadData;
mavlink_air_data_t mlAirData;
mavlink_sensor_bias_t mlSensorBiasData;
mavlink_diagnostic_t mlDiagnosticData;
mavlink_boot_t mlBoot;
mavlink_gps_date_time_t mlGpsDateTime;
mavlink_mid_lvl_cmds_t mlMidLevelCommands;
mavlink_set_mode_t mlApMode;
mavlink_slugs_navigation_t mlNavigation;
mavlink_data_log_t mlDataLog;
mavlink_ctrl_srfc_pt_t mlPassthrough;
mavlink_action_ack_t mlActionAck;
mavlink_slugs_action_t mlAction;
mavlink_scaled_imu_t mlScaled;
mavlink_servo_output_raw_t mlServo;
mavlink_rc_channels_raw_t mlChannels;
// Standart messages MAVLINK used by SLUGS
private:
void emitGpsSignals (void);
void emitPidSignal(void);
int uasId;
#endif // if SLUGS
};
#endif // SLUGSMAV_H
......@@ -85,7 +85,6 @@ This file is part of the QGROUNDCONTROL project
// FIXME Move
#include "PxQuadMAV.h"
#include "SlugsMAV.h"
#include "LogCompressor.h"
......
......@@ -65,12 +65,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGCGoogleEarthView.h"
#endif
#include "QGCToolBar.h"
#include "SlugsDataSensorView.h"
#include "LogCompressor.h"
#include "SlugsHilSim.h"
#include "SlugsPadCameraControl.h"
#include "UASControlParameters.h"
#include "QGCMAVLinkInspector.h"
#include "QGCMAVLinkLogPlayer.h"
......@@ -463,9 +459,6 @@ protected:
QPointer<QDockWidget> hsiDockWidget;
QPointer<QDockWidget> rcViewDockWidget;
QPointer<QDockWidget> hudDockWidget;
QPointer<QDockWidget> slugsDataWidget;
QPointer<QDockWidget> slugsHilSimWidget;
QPointer<QDockWidget> slugsCamControlWidget;
QPointer<QGCToolBar> toolBar;
QPointer<QGCStatusBar> customStatusBar;
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Grpahical presentation of SLUGS generated data
*
* @author Juan F. Robles <jfroblesc@gmail.com>
*
*/
#ifndef SLUGSDATASENSORVIEW_H
#define SLUGSDATASENSORVIEW_H
#include <QWidget>
#include "UASInterface.h"
#include "SlugsMAV.h"
#include "mavlink.h"
namespace Ui
{
class SlugsDataSensorView;
}
class SlugsDataSensorView : public QWidget
{
Q_OBJECT
public:
explicit SlugsDataSensorView(QWidget *parent = 0);
~SlugsDataSensorView();
public slots:
/**
* @brief Adds the UAS for data display
*
* Adds the UAS and makes all the correct connections for data display on the Widgets. If
* there is no current UAS active, it sets it as active.
* @param uas The UAS being added
*/
void addUAS(UASInterface* uas);
/**
* @brief Sets the UAS as active
*
* @param uas The UAS being set as active
*/
void setActiveUAS(UASInterface* uas);
/**
* @brief Updates the Raw Data widget
*/
void slugRawDataChanged (int uasId, const mavlink_raw_imu_t& rawData);
#ifdef MAVLINK_ENABLED_SLUGS
/**
* @brief Adds the UAS for data display
*
* Adds the UAS and makes all the correct connections for data display on the Widgets
*/
void slugLocalPositionChanged(UASInterface* uas,
double x,
double y,
double z,
quint64 time);
/**
* @brief Adds the UAS for data display
*
* Adds the UAS and makes all the correct connections for data display on the Widgets
*/
void slugSpeedLocalPositionChanged(UASInterface* uas,
double vx,
double vy,
double vz,
quint64 time);
/**
* @brief Adds the UAS for data display
*
* Adds the UAS and makes all the correct connections for data display on the Widgets
*/
void slugAttitudeChanged(UASInterface* uas,
double slugroll,
double slugpitch,
double slugyaw,
quint64 time);
/**
* @brief Adds the UAS for data display
*
* Adds the UAS and makes all the correct connections for data display on the Widgets
*/
void slugsGlobalPositionChanged(UASInterface* uas,
double lat,
double lon,
double alt,
quint64 time);
/**
* @brief set COG and SOG values
*
* COG and SOG GPS display on the Widgets
*/
void slugsGPSCogSog(int systemId,
double cog,
double sog);
/**
* @brief Updates the CPU load widget - 170
*/
void slugsCpuLoadChanged(int systemId,
const mavlink_cpu_load_t& cpuLoad);
/**
* @brief Updates the air data widget - 171
*/
void slugsAirDataChanged(int systemId,
const mavlink_air_data_t& airData);
/**
* @brief Updates the sensor bias widget - 172
*/
void slugsSensorBiasChanged(int systemId,
const mavlink_sensor_bias_t& sensorBias);
/**
* @brief Updates the diagnostic widget - 173
*/
void slugsDiagnosticMessageChanged(int systemId,
const mavlink_diagnostic_t& diagnostic);
/**
* @brief Updates the Navigation widget - 176
*/
void slugsNavegationChanged(int systemId,
const mavlink_slugs_navigation_t& slugsNavigation);
/**
* @brief Updates the Data Log widget - 177
*/
void slugsDataLogChanged(int systemId,
const mavlink_data_log_t& dataLog);
// /**
// * @brief Updates the PWM Commands widget - 175
// */
// void slugsPWMChanged(int systemId,
// const mavlink_servo_output_raw_t& pwmCommands);
/**
* @brief Updates the filtered sensor measurements widget - 178
*/
void slugsFilteredDataChanged(int systemId,
const mavlink_scaled_imu_t& filteredData);
/**
* @brief Updates the gps Date Time widget - 179
*/
void slugsGPSDateTimeChanged(int systemId,
const mavlink_gps_date_time_t& gpsDateTime);
void slugsRCRawChannels(int systemId,
const mavlink_rc_channels_raw_t& gpsDateTime);
void slugsRCServo(int systemId,
const mavlink_servo_output_raw_t& gpsDateTime);
#endif // MAVLINK_ENABLED_SLUGS
protected:
UASInterface* activeUAS;
private:
Ui::SlugsDataSensorView *ui;
};
#endif // SLUGSDATASENSORVIEW_H
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of the configuration Window for Slugs' HIL Simulator
* @author Mariano Lizarraga <malife@gmail.com>
*/
#ifndef SLUGSHILSIM_H
#define SLUGSHILSIM_H
#include <stdint.h>
#include <QWidget>
#include <QHostAddress>
#include <QUdpSocket>
#include <QMessageBox>
#include <QByteArray>
#include "LinkInterface.h"
#include "UAS.h"
#include "LinkManager.h"
#include "SlugsMAV.h"
namespace Ui
{
class SlugsHilSim;
}
class SlugsHilSim : public QWidget
{
Q_OBJECT
public:
explicit SlugsHilSim(QWidget *parent = 0);
~SlugsHilSim();
protected:
LinkInterface* hilLink;
QHostAddress* simulinkIp;
QUdpSocket* txSocket;
QUdpSocket* rxSocket;
UAS* activeUas;
mavlink_local_position_ned_t tmpLocalPositionData;
mavlink_attitude_t tmpAttitudeData;
mavlink_raw_imu_t tmpRawImuData;
#ifdef MAVLINK_ENABLED_SLUGS
mavlink_air_data_t tmpAirData;
#endif
mavlink_gps_raw_int_t tmpGpsData;
#ifdef MAVLINK_ENABLED_SLUGS
mavlink_gps_date_time_t tmpGpsTime;
#endif
public slots:
/**
* @brief Adds a link to the combo box listing so the user can select a link
*
* Populates the Combo box that allows the user to select the link with which Slugs will
* receive the simulated sensor data from Simulink
*
* @param theLink the link that is being added to the combo box
*/
void addToCombo(LinkInterface* theLink);
/**
* @brief Puts Slugs in HIL Mode
*
* Sends the required messages through the main communication link to set Slugs in HIL Mode
*
*/
void putInHilMode(void);
/**
* @brief Receives a datagram from Simulink containing the sensor data.
*
* Receives a datagram from Simulink containing the simulated sensor data. This data is then
* forwarded to Slugs to use as input to the attitude estimation and navigation algorithms.
*
*/
void readDatagram(void);
/**
* @brief Called when the a new UAS is set to active.
*
* Called when the a new UAS is set to active.
*
* @param uas The new active UAS
*/
void activeUasSet(UASInterface* uas);
/**
* @brief Called when the Link combobox selects a new link.
*
* @param uas The new index of the selected link
*/
void linkSelected (int cbIndex);
public slots:
private:
typedef union _tFloatToChar {
unsigned char chData[4];
float flData;
} tFloatToChar;
typedef union _tUint16ToChar {
unsigned char chData[2];
uint16_t uiData;
} tUint16ToChar;
Ui::SlugsHilSim *ui;
QHash <int, LinkInterface*> linksAvailable;
void processHilDatagram (const QByteArray* datagram);
float getFloatFromDatagram (const QByteArray* datagram, unsigned char * i);
uint16_t getUint16FromDatagram (const QByteArray* datagram, unsigned char * i);
void setUInt16ToDatagram(QByteArray& datagram, unsigned char* pos, uint16_t value);
void sendMessageToSlugs();
void commandDatagramToSimulink();
};
#endif // SLUGSHILSIM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SlugsHilSim</class>
<widget class="QWidget" name="SlugsHilSim">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>337</width>
<height>278</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>320</width>
<height>252</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>450</width>
<height>278</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>IP Address</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="ed_ipAdress">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Receive Port</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="ed_rxPort">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Send Port</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="ed_txPort">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Slugs HIL Link</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
<widget class="QComboBox" name="cb_mavlinkLinks">
<property name="minimumSize">
<size>
<width>171</width>
<height>26</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<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>
<widget class="QPushButton" name="bt_startHil">
<property name="text">
<string>Set Slugs in HIL Mode</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Count</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ed_count">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="ed_1">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ed_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ed_3">
<property name="minimumSize">
<size>
<width>60</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>18</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="tbA"/>
</item>
<item>
<widget class="QLineEdit" name="tbB"/>
</item>
<item>
<widget class="QLineEdit" name="tbC"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "SlugsPadCameraControl.h"
#include "ui_SlugsPadCameraControl.h"
SlugsPadCameraControl::SlugsPadCameraControl(QWidget *parent) :
QWidget(parent),
ui(new Ui::SlugsPadCameraControl),
dragging(0)
{
ui->setupUi(this);
x1= 0;
y1 = 0;
motion = NONE;
}
SlugsPadCameraControl::~SlugsPadCameraControl()
{
delete ui;
}
void SlugsPadCameraControl::activeUasSet(UASInterface *uas)
{
if(uas) {
this->activeUAS= uas;
}
}
void SlugsPadCameraControl::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event);
if(dragging) {
getDeltaPositionPad(event->x(), event->y());
}
}
void SlugsPadCameraControl::mousePressEvent(QMouseEvent *event)
{
if(!dragging) {
dragging = true;
x1 = event->x();
y1 = event->y();
}
}
void SlugsPadCameraControl::mouseReleaseEvent(QMouseEvent *event)
{
if(dragging) {
dragging = false;
getDeltaPositionPad(event->x(), event->y());
xFin = event->x();
yFin = event->y();
}
}
void SlugsPadCameraControl::getDeltaPositionPad(int x2, int y2)
{
QPointF localMeasures = ObtenerMarcacionDistanciaPixel(y1,x1,y2,x2);
if(localMeasures.y()>10) {
QString dir = "nd";
double bearing = localMeasures.x();
bearing = bearing +90;
if(bearing>= 360) {
bearing = bearing - 360;
}
if(bearing >337.5 || bearing <=22.5) {
motion= UP;
movePad = QPoint(0, 1);
dir = "UP";
} else if(bearing >22.5 && bearing <=67.5) {
motion= RIGHT_UP;
movePad = QPoint(1, 1);
dir = "RIGHT UP";
} else if(bearing >67.5 && bearing <=112.5) {
motion= RIGHT;
movePad = QPoint(1, 0);
dir = "RIGHT";
} else if(bearing >112.5 && bearing <= 157.5) {
motion= RIGHT_DOWN;
movePad = QPoint(1, -1);
dir = "RIGHT DOWN";
} else if(bearing >157.5 && bearing <=202.5) {
motion= DOWN;
movePad = QPoint(0, -1);
dir = "DOWN";
} else if(bearing >202.5 && bearing <=247.5) {
motion= LEFT_DOWN;
movePad = QPoint(-1, -1);
dir = "LEFT DOWN";
} else if(bearing >247.5 && bearing <=292.5) {
motion= LEFT;
movePad = QPoint(-1, 0);
dir = "LEFT";
} else if(bearing >292.5 && bearing <=337.5) {
motion= LEFT_UP;
movePad = QPoint(-1, 1);
dir = "LEFT UP";
}
emit changeMotionCamera(motion);
ui->lbPixel->setText(QString::number(localMeasures.y()));
ui->lbDirection->setText(dir);
//qDebug()<<dir;
update();
}
}
QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, double lat1,
double lon2, double lat2)
{
double cateto_opuesto,cateto_adyacente, hipotenusa;//, distancia;
double marcacion = 0.0;
//latitude and longitude first point
if(lat1<0) lat1= lat1*(-1);
if(lat2<0) lat2= lat2*(-1);
if(lon1<0) lon1= lon1*(-1);
if(lon2<0) lon1= lon1*(-1);
cateto_opuesto = abs((lat1-lat2));
cateto_adyacente = abs((lon1-lon2));
hipotenusa = sqrt(pow(cateto_opuesto,2) + pow(cateto_adyacente,2));
//distancia = hipotenusa*60.0;
if ((lat1 < lat2) && (lon1 > lon2)) //primer cuadrante
marcacion = 360 -((asin(cateto_adyacente/hipotenusa))/ 0.017453292);
else if ((lat1 < lat2) && (lon1 < lon2)) //segundo cuadrante
marcacion = (asin(cateto_adyacente/hipotenusa))/ 0.017453292;
else if((lat1 > lat2) && (lon1 < lon2)) //tercer cuadrante
marcacion = 180 -((asin(cateto_adyacente/hipotenusa))/ 0.017453292);
else if((lat1 > lat2) && (lon1 > lon2)) //cuarto cuadrante
marcacion = 180 +((asin(cateto_adyacente/hipotenusa))/ 0.017453292);
else if((lat1 < lat2) && (lon1 == lon2)) //360
marcacion = 360;
else if((lat1 == lat2) && (lon1 > lon2)) //270
marcacion = 270;
else if((lat1 > lat2) && (lon1 == lon2)) //180
marcacion = 180;
else if((lat1 == lat2) && (lon1 < lon2)) //90
marcacion =90;
else if((lat1 == lat2) && (lon1 == lon2)) //0
marcacion = 0.0;
return QPointF(marcacion,hipotenusa);// distancia);
}
void SlugsPadCameraControl::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Left:
emit changeMotionCamera(LEFT);
break;
case Qt::Key_Right:
emit changeMotionCamera(RIGHT);
break;
case Qt::Key_Down:
emit changeMotionCamera(DOWN);
break;
case Qt::Key_Up:
emit changeMotionCamera(UP);
break;
default:
QWidget::keyPressEvent(event);
}
}
#ifndef SLUGSPADCAMERACONTROL_H
#define SLUGSPADCAMERACONTROL_H
#include <QWidget>
#include <QGraphicsView>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QDebug>
#include <qmath.h>
#include <QPainter>
#include "UASManager.h"
namespace Ui
{
class SlugsPadCameraControl;
}
class SlugsPadCameraControl : public QWidget //QGraphicsView//
{
Q_OBJECT
public:
explicit SlugsPadCameraControl(QWidget *parent = 0);
~SlugsPadCameraControl();
enum MotionCamera {
UP,
DOWN,
LEFT,
RIGHT,
RIGHT_UP,
RIGHT_DOWN,
LEFT_UP,
LEFT_DOWN,
NONE
};
public slots:
void getDeltaPositionPad(int x, int y);
QPointF ObtenerMarcacionDistanciaPixel(double lon1, double lat1, double lon2, double lat2);
void activeUasSet(UASInterface *uas);
signals:
void changeMotionCamera(MotionCamera);
protected:
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *event);
//void paintEvent(QPaintEvent *pe);
private:
Ui::SlugsPadCameraControl *ui;
bool dragging;
int x1;
int y1;
int xFin;
int yFin;
QString directionPad;
MotionCamera motion;
UASInterface* activeUAS;
QPoint movePad;
};
#endif // SLUGSPADCAMERACONTROL_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SlugsPadCameraControl</class>
<widget class="QWidget" name="SlugsPadCameraControl">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>200</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 170, 0);</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>1</number>
</property>
<property name="spacing">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(135, 206, 235);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>156</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lbPixel">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>----</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbDirection">
<property name="text">
<string>----</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "SlugsVideoCamControl.h"
#include "ui_SlugsVideoCamControl.h"
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QTextStream>
#include <QScrollBar>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QDebug>
#include <qmath.h>
#include <QPainter>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include "SlugsPadCameraControl.h"
SlugsVideoCamControl::SlugsVideoCamControl(QWidget *parent) :
QWidget(parent),
ui(new Ui::SlugsVideoCamControl)
{
ui->setupUi(this);
// x1= 0;
// y1 = 0;
connect(ui->viewCamBordeatMap_checkBox,SIGNAL(clicked(bool)),this,SLOT(changeViewCamBorderAtMapStatus(bool)));
padCamera = new SlugsPadCameraControl(this);
ui->gridLayout->addWidget(padCamera);
//connect(padCamera,SIGNAL(mouseMoveCoord(int,int)),this,SLOT(mousePadMoveEvent(int,int)));
//connect(padCamera,SIGNAL(mousePressCoord(int,int)),this,SLOT(mousePadPressEvent(int,int)));
//connect(padCamera,SIGNAL(mouseReleaseCoord(int,int)),this,SLOT(mousePadReleaseEvent(int,int)));
//connect(padCamera,SIGNAL(changeCursorPosition(double,double,QString)),this,SLOT(getDeltaPositionPad(double,double,QString)));
}
SlugsVideoCamControl::~SlugsVideoCamControl()
{
delete ui;
}
//void SlugsVideoCamControl::mouseMoveEvent(QMouseEvent *event)
//{
// Q_UNUSED(event);
//}
//void SlugsVideoCamControl::mousePressEvent(QMouseEvent *evnt)
//{
// Q_UNUSED(evnt);
//}
//void SlugsVideoCamControl::mouseReleaseEvent(QMouseEvent *evnt)
//{
// Q_UNUSED(evnt);
//}
//void SlugsVideoCamControl::mousePadMoveEvent(int x, int y)
//{
//}
//void SlugsVideoCamControl::mousePadPressEvent(int x, int y)
//{
//}
//void SlugsVideoCamControl::mousePadReleaseEvent(int x, int y)
//{
//}
void SlugsVideoCamControl::changeViewCamBorderAtMapStatus(bool status)
{
emit viewCamBorderAtMap(status);
}
void SlugsVideoCamControl::getDeltaPositionPad(double bearing, double distance, QString dirText)
{
ui->label_dir->setText(dirText);
ui->label_x->setText("Distancia= " + QString::number(distance));
ui->label_y->setText("Bearing= " + QString::number(bearing));
//emit changeCamPosition(20, bearing, dirText);
}
/* This information is at least for the time not shown here but rather in some always visible bar.
void updateBattery(UASInterface*, double, double, double, int);
void receiveHeartbeat(UASInterface*);
void updateMode(int id,QString mode, QString description);
void updateLoad(UASInterface*, double);
void updateState(UASInterface*,QString);
void updateGPSFixType(UASInterface*,int);
void updateSatelliteCount(double count,QString sth);
void updateThrust(UASInterface*, double);
void updateLocalPosition(UASInterface*,double,double,double,quint64);
void updateGlobalPosition(UASInterface*,double,double,double,quint64);
void selectWaypoint(int uasId, int id);
*/
/*
bool uavIsArmed;
QString mode;
QString state;
float load;
double batteryVoltage;
double batteryCurrent;
double batteryCharge;
int GPSFixType;
int satelliteCount;
*/
batteryVoltage(UNKNOWN_BATTERY),
batteryCurrent(UNKNOWN_BATTERY),
batteryCharge(UNKNOWN_BATTERY),
GPSFixType(UNKNOWN_GPSFIXTYPE),
satelliteCount(UNKNOWN_COUNT),
uavIsArmed(false), // TODO: This is an assumption. We have no idea!
mode("-"),
state("-"),
load(0),
void PrimaryFlightDisplay::updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds)
{
Q_UNUSED(uas);
Q_UNUSED(seconds);
batteryVoltage = voltage;
batteryCurrent = current;
batteryCharge = percent;
}
void PrimaryFlightDisplay::updateGPSFixType(UASInterface* uas, int fixType) {
Q_UNUSED(uas);
this->GPSFixType = fixType;
}
void PrimaryFlightDisplay::updateSatelliteCount(double count, QString name) {
Q_UNUSED(uas)
this->satelliteCount = (int)count;
}
void PrimaryFlightDisplay::receiveHeartbeat(UASInterface*)
{
}
void PrimaryFlightDisplay::updateThrust(UASInterface* uas, double thrust)
{
Q_UNUSED(uas);
Q_UNUSED(thrust);
}
/*
* TODO! Implementation or removal of this.
* Currently a dummy.
*/
void PrimaryFlightDisplay::updateLocalPosition(UASInterface* uas,double x,double y,double z,quint64 timestamp)
{
Q_UNUSED(uas);
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(z);
Q_UNUSED(timestamp);
}
void PrimaryFlightDisplay::updateGlobalPosition(UASInterface* uas,double lat, double lon, double altitude, quint64 timestamp)
{
Q_UNUSED(uas);
Q_UNUSED(lat);
Q_UNUSED(lon);
Q_UNUSED(timestamp);
// TODO: Examine whether this is really the GPS alt or the mix-alt coming in.
GPSAltitude = altitude;
}
void PrimaryFlightDisplay::updateState(UASInterface* uas,QString state)
{
// Only one UAS is connected at a time
Q_UNUSED(uas);
this->state = state;
}
void PrimaryFlightDisplay::updateMode(int id, QString mode, QString description)
{
// Only one UAS is connected at a time
Q_UNUSED(id);
Q_UNUSED(description);
this->mode = mode;
}
void PrimaryFlightDisplay::updateLoad(UASInterface* uas, double load)
{
Q_UNUSED(uas);
this->load = load;
//updateValue(uas, "load", load, MG::TIME::getGroundTimeNow());
}
void PrimaryFlightDisplay::selectWaypoint(int uasId, int id) {
}
void PrimaryFlightDisplay::drawLinkStatsPanel (
QPainter& painter,
QRectF area) {
// UAV Id
// Droprates up, down
QString s_linkStat("100%");
QString s_upTime("01:23:34");
painter.resetTransform();
if (style == NO_OVERLAYS)
drawInstrumentBackground(painter, area);
painter.translate(area.center());
QPen pen;
pen.setWidthF(lineWidth);
pen.setColor(amberColor);
painter.setPen(pen);
drawTextCenter(painter, s_linkStat, mediumTextSize, 0, -area.height()/6);
drawTextCenter(painter, s_upTime, mediumTextSize, 0, area.height()/6);
}
void PrimaryFlightDisplay::drawMissionStatsPanel (
QPainter& painter,
QRectF area) {
// Flight mode
// next WP
// next WP dist
QString s_flightMode("Auto");
QString s_nextWP("1234m\u21924");
painter.resetTransform();
if (style == NO_OVERLAYS)
drawInstrumentBackground(painter, area);
painter.translate(area.center());
QPen pen;
pen.setWidthF(lineWidth);
pen.setColor(amberColor);
painter.setPen(pen);
drawTextCenter(painter, s_flightMode, mediumTextSize, 0, -area.height()/6);
drawTextCenter(painter, s_nextWP, mediumTextSize, 0, area.height()/6);
}
void PrimaryFlightDisplay::drawSensorsStatsPanel (
QPainter& painter,
QRectF area) {
// GPS fixmode and #sats
// Home alt.?
// Groundspeed?
QString s_GPS("GPS 3D(8)");
QString s_homealt("H.alt 472m");
painter.resetTransform();
if (style == NO_OVERLAYS)
drawInstrumentBackground(painter, area);
painter.translate(area.center());
QPen pen;
pen.setWidthF(lineWidth);
pen.setColor(amberColor);
painter.setPen(pen);
drawTextCenter(painter, s_GPS, mediumTextSize, 0, -area.height()/6);
drawTextCenter(painter, s_homealt, mediumTextSize, 0, area.height()/6);
}
void PrimaryFlightDisplay::drawSysStatsPanel (
QPainter& painter,
QRectF area) {
// Timer
// Battery
// Armed/not
/*
energyStatus = tr("BAT [%1V | %2V%]").arg(voltage, 4, 'f', 1, QChar('0')).arg(percent, 2, 'f', 0, QChar('0'));
if (percent < 20.0f) {
fuelColor = warningColor;
} else if (percent < 10.0f) {
fuelColor = criticalColor;
} else {
fuelColor = infoColor;
}
*/
QString voltageStatus = batteryVoltage == UNKNOWN_BATTERY ? "-V" :
tr("%1V").arg(batteryVoltage, 4, 'f', 1, QChar('0'));
QString chargeStatus = batteryCharge == UNKNOWN_BATTERY ? "-%" :
tr("%2%").arg(batteryCharge, 2, 'f', 0, QChar('0'));
// We ignore current right now.
QString batteryStatus = voltageStatus.append(" ").append(chargeStatus);
QString s_arm = uavIsArmed ? "Armed" : "Disarmed";
painter.resetTransform();
if (style == NO_OVERLAYS)
drawInstrumentBackground(painter, area);
painter.translate(area.center());
QPen pen;
pen.setWidthF(lineWidth);
pen.setColor(amberColor);
painter.setPen(pen);
drawTextCenter(painter, batteryStatus, mediumTextSize, 0, -area.height()/6);
pen.setColor(redColor);
drawTextCenter(painter, s_arm, mediumTextSize, 0, area.height()/6);
}
......@@ -4,18 +4,6 @@
#define CONTROL_MODE_LOCKED "MODE LOCKED"
#define CONTROL_MODE_MANUAL "MODE MANUAL"
#ifdef MAVLINK_ENABLED_SLUGS
#define CONTROL_MODE_GUIDED "MODE MID-L CMDS"
#define CONTROL_MODE_AUTO "MODE WAYPOINT"
#define CONTROL_MODE_TEST1 "MODE PASST"
#define CONTROL_MODE_TEST2 "MODE SEL PT"
#else
#define CONTROL_MODE_GUIDED "MODE GUIDED"
#define CONTROL_MODE_AUTO "MODE AUTO"
#define CONTROL_MODE_TEST1 "MODE TEST1"
#define CONTROL_MODE_TEST2 "MODE TEST2"
#endif
#define CONTROL_MODE_READY "MODE TEST3"
#define CONTROL_MODE_RC_TRAINING "RC SIMULATION"
......@@ -61,21 +49,6 @@ void UASControlParameters::changedMode(int mode)
case (uint8_t)MAV_MODE_MANUAL_DISARMED:
modeTemp = "D/MANUAL MODE";
break;
#ifdef MAVLINK_ENABLED_SLUGS
case (uint8_t)MAV_MODE_AUTO:
modeTemp = "WAYPOINT MODE";
break;
case (uint8_t)MAV_MODE_GUIDED:
modeTemp = "MID-L CMDS MODE";
break;
case (uint8_t)MAV_MODE_TEST1:
modeTemp = "PASST MODE";
break;
case (uint8_t)MAV_MODE_TEST2:
modeTemp = "SEL PT MODE";
break;
#endif
default:
modeTemp = "UNKNOWN MODE";
break;
......@@ -131,20 +104,6 @@ void UASControlParameters::updateAttitude(UASInterface *uas, double roll, double
void UASControlParameters::setCommands()
{
#ifdef MAVLINK_ENABLED_SLUGS
if(this->activeUAS) {
UAS* myUas= static_cast<UAS*>(this->activeUAS);
mavlink_message_t msg;
tempCmds.uCommand = ui->sbAirSpeed->value();
tempCmds.hCommand = ui->sbHeight->value();
tempCmds.rCommand = ui->sbTurnRate->value();
mavlink_msg_mid_lvl_cmds_encode(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, &this->tempCmds);
myUas->sendMessage(msg);
}
#endif
}
void UASControlParameters::getCommands()
......@@ -156,40 +115,6 @@ void UASControlParameters::getCommands()
void UASControlParameters::setPassthrough()
{
#ifdef MAVLINK_ENABLED_SLUGS
if(this->activeUAS) {
UAS* myUas= static_cast<UAS*>(this->activeUAS);
mavlink_message_t msg;
int8_t tmpBit=0;
if(ui->cxdle_c->isChecked()) { //left elevator command
tmpBit+=8;
}
if(ui->cxdr_c->isChecked()) { //rudder command
tmpBit+=16;
}
if(ui->cxdla_c->isChecked()) { //left aileron command
tmpBit+=64;
}
if(ui->cxdt_c->isChecked()) { //throttle command
tmpBit+=128;
}
generic_16bit r;
r.b[1] = 0;
r.b[0] = tmpBit;//255;
tempCtrl.target= this->activeUAS->getUASID();
tempCtrl.bitfieldPt= (uint16_t)r.s;
mavlink_msg_ctrl_srfc_pt_encode(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, &this->tempCtrl);
myUas->sendMessage(msg);
//qDebug()<<tempCtrl.bitfieldPt;
}
#endif
}
void UASControlParameters::updateMode(int uas,QString mode,QString description)
......
......@@ -3,7 +3,6 @@
#include <QWidget>
#include "UASManager.h"
#include "SlugsMAV.h"
#include <QTimer>
#include <QTabWidget>
......@@ -45,10 +44,6 @@ private:
QString REDcolorStyle;
QPointer<RadioCalibrationData> radio;
LinkInterface* hilLink;
#ifdef MAVLINK_ENABLED_SLUGS
mavlink_mid_lvl_cmds_t tempCmds;
mavlink_ctrl_srfc_pt_t tempCtrl;
#endif
};
#endif // UASCONTROLPARAMETERS_H
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