Browse Source
SLUGS has maintained their patches out-of-tree for a long while now. These will eventually get merged back in, but it'll be easier to evaluate them as fresh commits instead of modifications to this old & dead code, so we'll delete this for now.QGC4.4
20 changed files with 0 additions and 5514 deletions
@ -1,235 +0,0 @@ |
|||||||
#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
|
|
@ -1,131 +0,0 @@ |
|||||||
/*=====================================================================
|
|
||||||
|
|
||||||
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
|
|
@ -1,352 +0,0 @@ |
|||||||
#include "SlugsDataSensorView.h" |
|
||||||
#include "ui_SlugsDataSensorView.h" |
|
||||||
|
|
||||||
#include <UASManager.h> |
|
||||||
#include "SlugsMAV.h" |
|
||||||
|
|
||||||
#include <QDebug> |
|
||||||
|
|
||||||
SlugsDataSensorView::SlugsDataSensorView(QWidget *parent) : |
|
||||||
QWidget(parent), |
|
||||||
ui(new Ui::SlugsDataSensorView) |
|
||||||
{ |
|
||||||
ui->setupUi(this); |
|
||||||
|
|
||||||
activeUAS = NULL; |
|
||||||
|
|
||||||
this->setVisible(false); |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
SlugsDataSensorView::~SlugsDataSensorView() |
|
||||||
{ |
|
||||||
delete ui; |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::addUAS(UASInterface* uas) |
|
||||||
{ |
|
||||||
SlugsMAV* slugsMav = qobject_cast<SlugsMAV*>(uas); |
|
||||||
|
|
||||||
if (slugsMav != NULL) { |
|
||||||
|
|
||||||
connect(slugsMav, SIGNAL(slugsRawImu(int, const mavlink_raw_imu_t&)), this, SLOT(slugRawDataChanged(int, const mavlink_raw_imu_t&))); |
|
||||||
|
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
|
|
||||||
//connect standar messages
|
|
||||||
connect(slugsMav, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(slugLocalPositionChanged(UASInterface*,double,double,double,quint64))); |
|
||||||
connect(slugsMav, SIGNAL(velocityChanged_NED(UASInterface*,double,double,double,quint64)), this, SLOT(slugSpeedLocalPositionChanged(UASInterface*,double,double,double,quint64))); |
|
||||||
connect(slugsMav, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(slugAttitudeChanged(UASInterface*,double,double,double,quint64))); |
|
||||||
connect(slugsMav, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(slugsGlobalPositionChanged(UASInterface*,double,double,double,quint64))); |
|
||||||
connect(slugsMav,SIGNAL(slugsGPSCogSog(int,double,double)),this,SLOT(slugsGPSCogSog(int,double,double))); |
|
||||||
|
|
||||||
//connect slugs especial messages
|
|
||||||
connect(slugsMav, SIGNAL(slugsSensorBias(int,const mavlink_sensor_bias_t&)), this, SLOT(slugsSensorBiasChanged(int,const mavlink_sensor_bias_t&))); |
|
||||||
connect(slugsMav, SIGNAL(slugsDiagnostic(int,const mavlink_diagnostic_t&)), this, SLOT(slugsDiagnosticMessageChanged(int,const mavlink_diagnostic_t&))); |
|
||||||
connect(slugsMav, SIGNAL(slugsCPULoad(int,const mavlink_cpu_load_t&)), this, SLOT(slugsCpuLoadChanged(int,const mavlink_cpu_load_t&))); |
|
||||||
|
|
||||||
connect(slugsMav, SIGNAL(slugsNavegation(int,const mavlink_slugs_navigation_t&)),this,SLOT(slugsNavegationChanged(int,const mavlink_slugs_navigation_t&))); |
|
||||||
connect(slugsMav, SIGNAL(slugsDataLog(int,const mavlink_data_log_t&)), this, SLOT(slugsDataLogChanged(int,const mavlink_data_log_t&))); |
|
||||||
// connect(slugsMav, SIGNAL(slugsPWM(int,const mavlink_pwm_commands_t&)),this,SLOT(slugsPWMChanged(int,const mavlink_pwm_commands_t&)));
|
|
||||||
// connect(slugsMav, SIGNAL(slugsFilteredData(int,const mavlink_filtered_data_t&)),this,SLOT(slugsFilteredDataChanged(int,const mavlink_filtered_data_t&)));
|
|
||||||
connect(slugsMav, SIGNAL(slugsGPSDateTime(int,const mavlink_gps_date_time_t&)),this,SLOT(slugsGPSDateTimeChanged(int,const mavlink_gps_date_time_t&))); |
|
||||||
connect(slugsMav,SIGNAL(slugsAirData(int, const mavlink_air_data_t&)),this,SLOT(slugsAirDataChanged(int, const mavlink_air_data_t&))); |
|
||||||
|
|
||||||
|
|
||||||
connect(slugsMav, SIGNAL(slugsChannels(int, const mavlink_rc_channels_raw_t&)), this, SLOT(slugsRCRawChannels(int, const mavlink_rc_channels_raw_t&))); |
|
||||||
connect(slugsMav, SIGNAL(slugsServo(int, const mavlink_servo_output_raw_t&)), this, SLOT(slugsRCServo(int,const mavlink_servo_output_raw_t&))); |
|
||||||
connect(slugsMav, SIGNAL(slugsScaled(int, const mavlink_scaled_imu_t&)), this, SLOT(slugsFilteredDataChanged(int, const mavlink_scaled_imu_t&))); |
|
||||||
|
|
||||||
#endif // MAVLINK_ENABLED_SLUGS
|
|
||||||
// Set this UAS as active if it is the first one
|
|
||||||
if(activeUAS == 0) { |
|
||||||
activeUAS = uas; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugRawDataChanged(int uasId, const mavlink_raw_imu_t &rawData) |
|
||||||
{ |
|
||||||
Q_UNUSED(uasId); |
|
||||||
|
|
||||||
ui->m_Axr->setText(QString::number(rawData.xacc)); |
|
||||||
ui->m_Ayr->setText(QString::number(rawData.yacc)); |
|
||||||
ui->m_Azr->setText(QString::number(rawData.zacc)); |
|
||||||
|
|
||||||
ui->m_Mxr->setText(QString::number(rawData.xmag)); |
|
||||||
ui->m_Myr->setText(QString::number(rawData.ymag)); |
|
||||||
ui->m_Mzr->setText(QString::number(rawData.zmag)); |
|
||||||
|
|
||||||
ui->m_Gxr->setText(QString::number(rawData.xgyro)); |
|
||||||
ui->m_Gyr->setText(QString::number(rawData.ygyro)); |
|
||||||
ui->m_Gzr->setText(QString::number(rawData.zgyro)); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
void SlugsDataSensorView::slugsRCRawChannels(int systemId, const mavlink_rc_channels_raw_t &gpsDateTime) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
|
|
||||||
ui->tbRCThrottle->setText(QString::number(gpsDateTime.chan1_raw)); |
|
||||||
ui->tbRCAileron->setText(QString::number(gpsDateTime.chan2_raw)); |
|
||||||
ui->tbRCRudder->setText(QString::number(gpsDateTime.chan3_raw)); |
|
||||||
ui->tbRCElevator->setText(QString::number(gpsDateTime.chan4_raw)); |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsRCServo(int systemId, const mavlink_servo_output_raw_t &gpsDateTime) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
|
|
||||||
ui->m_pwmThro->setText(QString::number(gpsDateTime.servo1_raw)); |
|
||||||
ui->m_pwmAile->setText(QString::number(gpsDateTime.servo2_raw)); |
|
||||||
ui->m_pwmRudd->setText(QString::number(gpsDateTime.servo3_raw)); |
|
||||||
ui->m_pwmElev->setText(QString::number(gpsDateTime.servo4_raw)); |
|
||||||
|
|
||||||
ui->m_pwmThroTrim->setText(QString::number(gpsDateTime.servo5_raw)); |
|
||||||
ui->m_pwmAileTrim->setText(QString::number(gpsDateTime.servo6_raw)); |
|
||||||
ui->m_pwmRuddTrim->setText(QString::number(gpsDateTime.servo7_raw)); |
|
||||||
ui->m_pwmElevTrim->setText(QString::number(gpsDateTime.servo8_raw)); |
|
||||||
} |
|
||||||
#endif |
|
||||||
|
|
||||||
void SlugsDataSensorView::setActiveUAS(UASInterface* uas) |
|
||||||
{ |
|
||||||
activeUAS = uas; |
|
||||||
addUAS(activeUAS); |
|
||||||
} |
|
||||||
|
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsGlobalPositionChanged(UASInterface *uas, |
|
||||||
double lat, |
|
||||||
double lon, |
|
||||||
double alt, |
|
||||||
quint64 time) |
|
||||||
{ |
|
||||||
Q_UNUSED(uas); |
|
||||||
Q_UNUSED(time); |
|
||||||
|
|
||||||
ui->m_GpsLatitude->setText(QString::number(lat)); |
|
||||||
ui->m_GpsLongitude->setText(QString::number(lon)); |
|
||||||
ui->m_GpsHeight->setText(QString::number(alt)); |
|
||||||
|
|
||||||
//qDebug()<<"GPS Position = "<<lat<<" - "<<lon<<" - "<<alt;
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugLocalPositionChanged(UASInterface* uas, |
|
||||||
double x, |
|
||||||
double y, |
|
||||||
double z, |
|
||||||
quint64 time) |
|
||||||
{ |
|
||||||
Q_UNUSED(uas); |
|
||||||
Q_UNUSED(time); |
|
||||||
|
|
||||||
ui->ed_x->setText(QString::number(x)); |
|
||||||
ui->ed_y->setText(QString::number(y)); |
|
||||||
ui->ed_z->setText(QString::number(z)); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugSpeedLocalPositionChanged(UASInterface* uas, |
|
||||||
double vx, |
|
||||||
double vy, |
|
||||||
double vz, |
|
||||||
quint64 time) |
|
||||||
{ |
|
||||||
Q_UNUSED( uas); |
|
||||||
Q_UNUSED(time); |
|
||||||
|
|
||||||
ui->ed_vx->setText(QString::number(vx)); |
|
||||||
ui->ed_vy->setText(QString::number(vy)); |
|
||||||
ui->ed_vz->setText(QString::number(vz)); |
|
||||||
|
|
||||||
//qDebug()<<"Speed Local Position = "<<vx<<" - "<<vy<<" - "<<vz;
|
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugAttitudeChanged(UASInterface* uas, |
|
||||||
double slugroll, |
|
||||||
double slugpitch, |
|
||||||
double slugyaw, |
|
||||||
quint64 time) |
|
||||||
{ |
|
||||||
Q_UNUSED( uas); |
|
||||||
Q_UNUSED(time); |
|
||||||
|
|
||||||
ui->m_Roll->setText(QString::number(slugroll)); |
|
||||||
ui->m_Pitch->setText(QString::number(slugpitch)); |
|
||||||
ui->m_Yaw->setText(QString::number(slugyaw)); |
|
||||||
|
|
||||||
// qDebug()<<"Attitude change = "<<slugroll<<" - "<<slugpitch<<" - "<<slugyaw;
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsSensorBiasChanged(int systemId, |
|
||||||
const mavlink_sensor_bias_t& sensorBias) |
|
||||||
{ |
|
||||||
Q_UNUSED( systemId); |
|
||||||
|
|
||||||
ui->m_AxBiases->setText(QString::number(sensorBias.axBias)); |
|
||||||
ui->m_AyBiases->setText(QString::number(sensorBias.ayBias)); |
|
||||||
ui->m_AzBiases->setText(QString::number(sensorBias.azBias)); |
|
||||||
ui->m_GxBiases->setText(QString::number(sensorBias.gxBias)); |
|
||||||
ui->m_GyBiases->setText(QString::number(sensorBias.gyBias)); |
|
||||||
ui->m_GzBiases->setText(QString::number(sensorBias.gzBias)); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsDiagnosticMessageChanged(int systemId, |
|
||||||
const mavlink_diagnostic_t& diagnostic) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
|
|
||||||
ui->m_Fl1->setText(QString::number(diagnostic.diagFl1)); |
|
||||||
ui->m_Fl2->setText(QString::number(diagnostic.diagFl2)); |
|
||||||
ui->m_Fl3->setText(QString::number(diagnostic.diagFl2)); |
|
||||||
|
|
||||||
ui->m_Sh1->setText(QString::number(diagnostic.diagSh1)); |
|
||||||
ui->m_Sh2->setText(QString::number(diagnostic.diagSh2)); |
|
||||||
ui->m_Sh3->setText(QString::number(diagnostic.diagSh3)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsCpuLoadChanged(int systemId, |
|
||||||
const mavlink_cpu_load_t& cpuLoad) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
ui->ed_sens->setText(QString::number(cpuLoad.sensLoad)); |
|
||||||
ui->ed_control->setText(QString::number(cpuLoad.ctrlLoad)); |
|
||||||
ui->ed_batvolt->setText(QString::number(cpuLoad.batVolt)); |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsNavegationChanged(int systemId, |
|
||||||
const mavlink_slugs_navigation_t& slugsNavigation) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
ui->m_Um->setText(QString::number(slugsNavigation.u_m)); |
|
||||||
ui->m_PhiC->setText(QString::number(slugsNavigation.phi_c)); |
|
||||||
ui->m_PitchC->setText(QString::number(slugsNavigation.theta_c)); |
|
||||||
ui->m_PsidC->setText(QString::number(slugsNavigation.psiDot_c)); |
|
||||||
ui->m_AyBody->setText(QString::number(slugsNavigation.ay_body)); |
|
||||||
ui->m_TotRun->setText(QString::number(slugsNavigation.totalDist)); |
|
||||||
ui->m_DistToGo->setText(QString::number(slugsNavigation.dist2Go)); |
|
||||||
ui->m_FromWP->setText(QString::number(slugsNavigation.fromWP)); |
|
||||||
ui->m_ToWP->setText(QString::number(slugsNavigation.toWP)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsDataLogChanged(int systemId, |
|
||||||
const mavlink_data_log_t& dataLog) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
ui->m_logFl1->setText(QString::number(dataLog.fl_1)); |
|
||||||
ui->m_logFl2->setText(QString::number(dataLog.fl_2)); |
|
||||||
ui->m_logFl3->setText(QString::number(dataLog.fl_3)); |
|
||||||
ui->m_logFl4->setText(QString::number(dataLog.fl_4)); |
|
||||||
ui->m_logFl5->setText(QString::number(dataLog.fl_5)); |
|
||||||
ui->m_logFl6->setText(QString::number(dataLog.fl_6)); |
|
||||||
} |
|
||||||
|
|
||||||
//void SlugsDataSensorView::slugsPWMChanged(int systemId,
|
|
||||||
// const mavlink_servo_output_raw_t& pwmCommands){
|
|
||||||
// Q_UNUSED(systemId);
|
|
||||||
// ui->m_pwmThro->setText(QString::number(pwmCommands.servo1_raw));//.dt_c));
|
|
||||||
// ui->m_pwmAile->setText(QString::number(pwmCommands.servo2_raw));//dla_c));
|
|
||||||
// ui->m_pwmElev->setText(QString::number(pwmCommands.servo4_raw));//dle_c));
|
|
||||||
// ui->m_pwmRudd->setText(QString::number(pwmCommands.servo3_raw));//dr_c));
|
|
||||||
|
|
||||||
// ui->m_pwmThroTrim->setText(QString::number(pwmCommands.servo5_raw));//dre_c));
|
|
||||||
// ui->m_pwmAileTrim->setText(QString::number(pwmCommands.servo6_raw));//dlf_c));
|
|
||||||
// ui->m_pwmElevTrim->setText(QString::number(pwmCommands.servo8_raw));//drf_c));
|
|
||||||
// ui->m_pwmRuddTrim->setText(QString::number(pwmCommands.servo7_raw));//aux1));
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsFilteredDataChanged(int systemId, |
|
||||||
const mavlink_scaled_imu_t& filteredData) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
ui->m_Axf->setText(QString::number(filteredData.xacc/1000.0f)); |
|
||||||
ui->m_Ayf->setText(QString::number(filteredData.yacc/1000.0f)); |
|
||||||
ui->m_Azf->setText(QString::number(filteredData.zacc/1000.0f)); |
|
||||||
ui->m_Gxf->setText(QString::number(filteredData.xgyro/1000.0f)); |
|
||||||
ui->m_Gyf->setText(QString::number(filteredData.ygyro/1000.0f)); |
|
||||||
ui->m_Gzf->setText(QString::number(filteredData.zgyro/1000.0f)); |
|
||||||
ui->m_Mxf->setText(QString::number(filteredData.xmag/1000.0f)); |
|
||||||
ui->m_Myf->setText(QString::number(filteredData.ymag/1000.0f)); |
|
||||||
ui->m_Mzf->setText(QString::number(filteredData.zmag/1000.0f)); |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsDataSensorView::slugsGPSDateTimeChanged(int systemId, |
|
||||||
const mavlink_gps_date_time_t& gpsDateTime) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
|
|
||||||
QString month, day; |
|
||||||
|
|
||||||
month = QString::number(gpsDateTime.month); |
|
||||||
day = QString::number(gpsDateTime.day); |
|
||||||
|
|
||||||
if(gpsDateTime.month < 10) month = "0" + QString::number(gpsDateTime.month); |
|
||||||
if(gpsDateTime.day < 10) day = "0" + QString::number(gpsDateTime.day); |
|
||||||
|
|
||||||
|
|
||||||
ui->m_GpsDate->setText(day + "/" + |
|
||||||
month + "/" + |
|
||||||
QString::number(gpsDateTime.year)); |
|
||||||
|
|
||||||
QString hour, min, sec; |
|
||||||
|
|
||||||
hour = QString::number(gpsDateTime.hour); |
|
||||||
min = QString::number(gpsDateTime.min); |
|
||||||
sec = QString::number(gpsDateTime.sec); |
|
||||||
|
|
||||||
if(gpsDateTime.hour < 10) hour = "0" + QString::number(gpsDateTime.hour); |
|
||||||
if(gpsDateTime.min < 10) min = "0" + QString::number(gpsDateTime.min); |
|
||||||
if(gpsDateTime.sec < 10) sec = "0" + QString::number(gpsDateTime.sec); |
|
||||||
|
|
||||||
ui->m_GpsTime->setText(hour + ":" + |
|
||||||
min + ":" + |
|
||||||
sec); |
|
||||||
|
|
||||||
ui->m_GpsSat->setText(QString::number(gpsDateTime.visSat)); |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Updates the air data widget - 171 |
|
||||||
*/ |
|
||||||
void SlugsDataSensorView::slugsAirDataChanged(int systemId, const mavlink_air_data_t &airData) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
ui->ed_dynamic->setText(QString::number(airData.dynamicPressure)); |
|
||||||
ui->ed_static->setText(QString::number(airData.staticPressure)); |
|
||||||
ui->ed_temp->setText(QString::number(airData.temperature)); |
|
||||||
} |
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief set COG and SOG values |
|
||||||
* |
|
||||||
* COG and SOG GPS display on the Widgets |
|
||||||
*/ |
|
||||||
void SlugsDataSensorView::slugsGPSCogSog(int systemId, double cog, double sog) |
|
||||||
{ |
|
||||||
Q_UNUSED(systemId); |
|
||||||
|
|
||||||
ui->m_GpsCog->setText(QString::number(cog)); |
|
||||||
ui->m_GpsSog->setText(QString::number(sog)); |
|
||||||
} |
|
||||||
|
|
||||||
#endif // MAVLINK_ENABLED_SLUGS
|
|
@ -1,213 +0,0 @@ |
|||||||
/*=====================================================================
|
|
||||||
|
|
||||||
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
|
|
@ -1,364 +0,0 @@ |
|||||||
/*=====================================================================
|
|
||||||
|
|
||||||
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 Configuration Window for Slugs' HIL Simulator |
|
||||||
* @author Mariano Lizarraga <malife@gmail.com> |
|
||||||
* @author Alejandro Molina <am.alex09@gmail.com> |
|
||||||
*/ |
|
||||||
|
|
||||||
|
|
||||||
#include "SlugsHilSim.h" |
|
||||||
#include "ui_SlugsHilSim.h" |
|
||||||
|
|
||||||
|
|
||||||
SlugsHilSim::SlugsHilSim(QWidget *parent) : |
|
||||||
QWidget(parent), |
|
||||||
ui(new Ui::SlugsHilSim) |
|
||||||
{ |
|
||||||
ui->setupUi(this); |
|
||||||
|
|
||||||
rxSocket = new QUdpSocket(this); |
|
||||||
txSocket = new QUdpSocket(this); |
|
||||||
|
|
||||||
hilLink = NULL; |
|
||||||
|
|
||||||
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addToCombo(LinkInterface*))); |
|
||||||
connect(ui->cb_mavlinkLinks, SIGNAL(currentIndexChanged(int)), this, SLOT(linkSelected(int))); |
|
||||||
connect(ui->bt_startHil, SIGNAL(clicked()), this, SLOT(putInHilMode())); |
|
||||||
connect(rxSocket, SIGNAL(readyRead()), this, SLOT(readDatagram())); |
|
||||||
|
|
||||||
linksAvailable.clear(); |
|
||||||
|
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
memset(&tmpAirData, 0, sizeof(mavlink_air_data_t)); |
|
||||||
memset(&tmpAttitudeData, 0, sizeof(mavlink_attitude_t)); |
|
||||||
memset(&tmpGpsData, 0, sizeof(mavlink_gps_raw_t)); |
|
||||||
memset(&tmpGpsTime, 0, sizeof(mavlink_gps_date_time_t)); |
|
||||||
memset(&tmpLocalPositionData, 0, sizeof(mavlink_sensor_bias_t)); |
|
||||||
memset(&tmpRawImuData, 0, sizeof(mavlink_raw_imu_t)); |
|
||||||
#endif |
|
||||||
|
|
||||||
foreach (LinkInterface* link, LinkManager::instance()->getLinks()) { |
|
||||||
addToCombo(link); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
SlugsHilSim::~SlugsHilSim() |
|
||||||
{ |
|
||||||
rxSocket->disconnectFromHost(); |
|
||||||
delete ui; |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::addToCombo(LinkInterface* theLink) |
|
||||||
{ |
|
||||||
|
|
||||||
linksAvailable.insert(ui->cb_mavlinkLinks->count(),theLink); |
|
||||||
ui->cb_mavlinkLinks->addItem(theLink->getName()); |
|
||||||
|
|
||||||
if (hilLink == NULL) { |
|
||||||
hilLink = theLink; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::putInHilMode(void) |
|
||||||
{ |
|
||||||
|
|
||||||
bool sw_enableControls = !(ui->bt_startHil->isChecked()); |
|
||||||
QString buttonCaption= ui->bt_startHil->isChecked()? "Stop Slugs HIL Mode": "Set Slugs in HIL Mode"; |
|
||||||
|
|
||||||
if (ui->bt_startHil->isChecked()) { |
|
||||||
QMessageBox msgBox; |
|
||||||
msgBox.setIcon(QMessageBox::Critical); |
|
||||||
msgBox.setText("You are about to put SLUGS in HIL Mode."); |
|
||||||
msgBox.setInformativeText("It will stop reading the actual sensor readings. Do you wish to continue?"); |
|
||||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
|
||||||
msgBox.setDefaultButton(QMessageBox::No); |
|
||||||
|
|
||||||
if(msgBox.exec() == QMessageBox::Yes) { |
|
||||||
rxSocket->disconnectFromHost(); |
|
||||||
rxSocket->bind(QHostAddress::Any, ui->ed_rxPort->text().toInt()); |
|
||||||
//txSocket->bind(QHostAddress::Broadcast, ui->ed_txPort->text().toInt());
|
|
||||||
|
|
||||||
ui->ed_ipAdress->setEnabled(sw_enableControls); |
|
||||||
ui->ed_rxPort->setEnabled(sw_enableControls); |
|
||||||
ui->ed_txPort->setEnabled(sw_enableControls); |
|
||||||
ui->cb_mavlinkLinks->setEnabled(sw_enableControls); |
|
||||||
|
|
||||||
ui->bt_startHil->setText(buttonCaption); |
|
||||||
|
|
||||||
activeUas->startHil(); |
|
||||||
|
|
||||||
} else { |
|
||||||
ui->bt_startHil->setChecked(false); |
|
||||||
} |
|
||||||
} else { |
|
||||||
ui->ed_ipAdress->setEnabled(sw_enableControls); |
|
||||||
ui->ed_rxPort->setEnabled(sw_enableControls); |
|
||||||
ui->ed_txPort->setEnabled(sw_enableControls); |
|
||||||
ui->cb_mavlinkLinks->setEnabled(sw_enableControls); |
|
||||||
|
|
||||||
ui->bt_startHil->setText(buttonCaption); |
|
||||||
|
|
||||||
rxSocket->disconnectFromHost(); |
|
||||||
activeUas->stopHil(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::readDatagram(void) |
|
||||||
{ |
|
||||||
static int count = 0; |
|
||||||
while (rxSocket->hasPendingDatagrams()) { |
|
||||||
QByteArray datagram; |
|
||||||
datagram.resize(rxSocket->pendingDatagramSize()); |
|
||||||
QHostAddress sender; |
|
||||||
quint16 senderPort; |
|
||||||
|
|
||||||
rxSocket->readDatagram(datagram.data(), datagram.size(), |
|
||||||
&sender, &senderPort); |
|
||||||
|
|
||||||
if (datagram.size() == 113) { |
|
||||||
processHilDatagram(&datagram); |
|
||||||
|
|
||||||
sendMessageToSlugs(); |
|
||||||
|
|
||||||
commandDatagramToSimulink(); |
|
||||||
} |
|
||||||
|
|
||||||
ui->ed_count->setText(QString::number(count++)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsHilSim::activeUasSet(UASInterface* uas) |
|
||||||
{ |
|
||||||
|
|
||||||
if (uas != NULL) { |
|
||||||
activeUas = static_cast <UAS *>(uas); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsHilSim::processHilDatagram(const QByteArray* datagram) |
|
||||||
{ |
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
unsigned char i = 0; |
|
||||||
|
|
||||||
|
|
||||||
tmpGpsTime.year = datagram->at(i++); |
|
||||||
tmpGpsTime.month = datagram->at(i++); |
|
||||||
tmpGpsTime.day = datagram->at(i++); |
|
||||||
tmpGpsTime.hour = datagram->at(i++); |
|
||||||
tmpGpsTime.min = datagram->at(i++); |
|
||||||
tmpGpsTime.sec = datagram->at(i++); |
|
||||||
|
|
||||||
tmpGpsData.lat = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpGpsData.lon = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpGpsData.alt = getFloatFromDatagram(datagram, &i); |
|
||||||
|
|
||||||
tmpGpsData.hdg = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpGpsData.v = getUint16FromDatagram(datagram, &i); |
|
||||||
|
|
||||||
tmpGpsData.eph = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpGpsData.fix_type = datagram->at(i++); |
|
||||||
tmpGpsTime.visSat = datagram->at(i++); |
|
||||||
i++; |
|
||||||
|
|
||||||
tmpAirData.dynamicPressure= getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAirData.staticPressure= getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAirData.temperature= getUint16FromDatagram(datagram, &i); |
|
||||||
|
|
||||||
// TODO Salto en el Datagrama
|
|
||||||
i=i+8; |
|
||||||
|
|
||||||
tmpRawImuData.xgyro = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.ygyro = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.zgyro = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.xacc = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.yacc = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.zacc = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.xmag = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.ymag = getUint16FromDatagram(datagram, &i); |
|
||||||
tmpRawImuData.zmag = getUint16FromDatagram(datagram, &i); |
|
||||||
|
|
||||||
tmpAttitudeData.roll = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAttitudeData.pitch = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAttitudeData.yaw = getFloatFromDatagram(datagram, &i); |
|
||||||
|
|
||||||
tmpAttitudeData.rollspeed = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAttitudeData.pitchspeed = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpAttitudeData.yawspeed = getFloatFromDatagram(datagram, &i); |
|
||||||
|
|
||||||
// TODO Crear Paquete SYNC TIME
|
|
||||||
i=i+2; |
|
||||||
|
|
||||||
tmpLocalPositionData.x = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpLocalPositionData.y = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpLocalPositionData.z = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpLocalPositionData.vx = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpLocalPositionData.vy = getFloatFromDatagram(datagram, &i); |
|
||||||
tmpLocalPositionData.vz = getFloatFromDatagram(datagram, &i); |
|
||||||
|
|
||||||
// TODO: this is legacy of old HIL datagram. Need to remove from Simulink model
|
|
||||||
i++; |
|
||||||
|
|
||||||
ui->ed_1->setText(QString::number(tmpRawImuData.xacc)); |
|
||||||
ui->ed_2->setText(QString::number(tmpRawImuData.yacc)); |
|
||||||
ui->ed_3->setText(QString::number(tmpRawImuData.zacc)); |
|
||||||
|
|
||||||
ui->tbA->setText(QString::number(tmpRawImuData.xgyro)); |
|
||||||
ui->tbB->setText(QString::number(tmpRawImuData.ygyro)); |
|
||||||
ui->tbC->setText(QString::number(tmpRawImuData.zgyro)); |
|
||||||
|
|
||||||
#else |
|
||||||
Q_UNUSED(datagram); |
|
||||||
#endif |
|
||||||
} |
|
||||||
|
|
||||||
float SlugsHilSim::getFloatFromDatagram (const QByteArray* datagram, unsigned char * i) |
|
||||||
{ |
|
||||||
tFloatToChar tmpF2C; |
|
||||||
|
|
||||||
tmpF2C.chData[0] = datagram->at((*i)++); |
|
||||||
tmpF2C.chData[1] = datagram->at((*i)++); |
|
||||||
tmpF2C.chData[2] = datagram->at((*i)++); |
|
||||||
tmpF2C.chData[3] = datagram->at((*i)++); |
|
||||||
|
|
||||||
return tmpF2C.flData; |
|
||||||
} |
|
||||||
|
|
||||||
uint16_t SlugsHilSim::getUint16FromDatagram (const QByteArray* datagram, unsigned char * i) |
|
||||||
{ |
|
||||||
tUint16ToChar tmpU2C; |
|
||||||
|
|
||||||
tmpU2C.chData[0] = datagram->at((*i)++); |
|
||||||
tmpU2C.chData[1] = datagram->at((*i)++); |
|
||||||
|
|
||||||
return tmpU2C.uiData; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::linkSelected(int cbIndex) |
|
||||||
{ |
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
// HIL code to go here...
|
|
||||||
//hilLink = linksAvailable
|
|
||||||
// FIXME Mariano
|
|
||||||
|
|
||||||
hilLink =linksAvailable.value(cbIndex); |
|
||||||
|
|
||||||
#else |
|
||||||
Q_UNUSED(cbIndex) |
|
||||||
#endif |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::sendMessageToSlugs() |
|
||||||
{ |
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
mavlink_message_t msg; |
|
||||||
|
|
||||||
mavlink_msg_local_position_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpLocalPositionData); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
|
|
||||||
mavlink_msg_attitude_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpAttitudeData); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
|
|
||||||
mavlink_msg_raw_imu_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpRawImuData); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
|
|
||||||
mavlink_msg_air_data_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpAirData); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
|
|
||||||
mavlink_msg_gps_raw_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpGpsData); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
|
|
||||||
mavlink_msg_gps_date_time_encode(MG::SYSTEM::ID, |
|
||||||
MG::SYSTEM::COMPID, |
|
||||||
&msg, |
|
||||||
&tmpGpsTime); |
|
||||||
activeUas->sendMessage(hilLink, msg); |
|
||||||
memset(&msg, 0, sizeof(mavlink_message_t)); |
|
||||||
#endif |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void SlugsHilSim::commandDatagramToSimulink() |
|
||||||
{ |
|
||||||
#ifdef MAVLINK_ENABLED_SLUGS |
|
||||||
//mavlink_pwm_commands_t* pwdC = (static_cast<SlugsMAV*>(activeUas))->getPwmCommands();
|
|
||||||
|
|
||||||
//mavlink_pwm_commands_t* pwdC;
|
|
||||||
|
|
||||||
// if(pwdC != NULL){
|
|
||||||
// }
|
|
||||||
|
|
||||||
QByteArray data; |
|
||||||
data.resize(22); |
|
||||||
|
|
||||||
unsigned char i=0; |
|
||||||
setUInt16ToDatagram(data, &i, 1);//pwdC->dt_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 2);//pwdC->dla_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 3);//pwdC->dra_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 4);//pwdC->dr_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 5);//pwdC->dle_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 6);//pwdC->dre_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 7);//pwdC->dlf_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 8);//pwdC->drf_c);
|
|
||||||
setUInt16ToDatagram(data, &i, 9);//pwdC->aux1);
|
|
||||||
setUInt16ToDatagram(data, &i, 10);//pwdC->aux2);
|
|
||||||
setUInt16ToDatagram(data, &i, 11);//value default
|
|
||||||
|
|
||||||
txSocket->writeDatagram(data, QHostAddress::Broadcast, ui->ed_txPort->text().toInt()); |
|
||||||
#endif |
|
||||||
} |
|
||||||
|
|
||||||
void SlugsHilSim::setUInt16ToDatagram(QByteArray& datagram, unsigned char* pos, uint16_t value) |
|
||||||
{ |
|
||||||
tUint16ToChar tmpUnion; |
|
||||||
tmpUnion.uiData= value; |
|
||||||
|
|
||||||
datagram[(*pos)++]= tmpUnion.chData[0]; |
|
||||||
datagram[(*pos)++]= tmpUnion.chData[1]; |
|
||||||
} |
|
@ -1,158 +0,0 @@ |
|||||||
/*=====================================================================
|
|
||||||
|
|
||||||
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
|
|
@ -1,369 +0,0 @@ |
|||||||
<?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> |
|
@ -1,179 +0,0 @@ |
|||||||
#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); |
|
||||||
} |
|
||||||
} |
|
@ -1,69 +0,0 @@ |
|||||||
#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
|
|
@ -1,94 +0,0 @@ |
|||||||
<?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> |
|
@ -1,95 +0,0 @@ |
|||||||
#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);
|
|
||||||
} |
|
||||||
|
|
Loading…
Reference in new issue