From 0f064266abb447527b668d7033742122048cbc6a Mon Sep 17 00:00:00 2001 From: tecnosapiens Date: Fri, 10 Dec 2010 17:12:39 -0600 Subject: [PATCH] finished the connection of signal of the slugs data in SlugsDataSensorView --- src/uas/SlugsMAV.cc | 35 +++++++++++---- src/uas/SlugsMAV.h | 3 ++ src/uas/UAS.cc | 4 ++ src/uas/UAS.h | 20 ++++----- src/ui/SlugsDataSensorView.cc | 82 ++++++++++++++++++++++++++++++++--- src/ui/SlugsDataSensorView.h | 16 +++++++ src/ui/SlugsDataSensorView.ui | 2 +- 7 files changed, 135 insertions(+), 27 deletions(-) diff --git a/src/uas/SlugsMAV.cc b/src/uas/SlugsMAV.cc index 7728ec387..edc2a4d3b 100644 --- a/src/uas/SlugsMAV.cc +++ b/src/uas/SlugsMAV.cc @@ -169,11 +169,16 @@ void SlugsMAV::emitSignals (void){ case 2: emit slugsAirData(uasId, mlAirData); emit slugsDiagnostic(uasId,mlDiagnosticData); + break; case 3: emit remoteControlChannelScaledChanged(0,(mlPilotConsoleData.de- 1000.0f)/1000.0f); - emit remoteControlChannelScaledChanged(1,0.75); + emit remoteControlChannelScaledChanged(1,(mlPilotConsoleData.dla- 1000.0f)/1000.0f); + emit remoteControlChannelScaledChanged(2,(mlPilotConsoleData.dr- 1000.0f)/1000.0f); + emit remoteControlChannelScaledChanged(3,(mlPilotConsoleData.dra- 1000.0f)/1000.0f); + emit remoteControlChannelScaledChanged(0,(mlPilotConsoleData.dt- 1000.0f)/1000.0f); + emit slugsPWM(uasId, mlPwmCommands); break; @@ -185,11 +190,13 @@ void SlugsMAV::emitSignals (void){ case 5: emit slugsFilteredData(uasId,mlFilteredData); emit slugsGPSDateTime(uasId, mlGpsDateTime); + break; case 6: emit slugsActionAck(uasId,mlActionAck); emit emitGpsSignals(); + break; } @@ -213,20 +220,30 @@ void SlugsMAV::emitSignals (void){ #ifdef MAVLINK_ENABLED_SLUGS void SlugsMAV::emitGpsSignals (void){ - if (mlGpsData.fix_type > 0){ + qDebug()<<"After Emit GPS Signal"< 0){ emit globalPositionChanged(this, mlGpsData.lon, mlGpsData.lat, mlGpsData.alt, 0.0); - // Smaller than threshold and not NaN - if (mlGpsData.v < 1000000 && mlGpsData.v == mlGpsData.v){ - emit speedChanged(this, (double)mlGpsData.v, 0.0, 0.0, 0.0); - } else { - emit textMessageReceived(uasId, uasId, 255, QString("GCS ERROR: RECEIVED INVALID SPEED OF %1 m/s").arg(mlGpsData.v)); - } - } + emit slugsGPSCogSog(uasId,mlGpsData.hdg, mlGpsData.v); + +// // Smaller than threshold and not NaN +// if (mlGpsData.v < 1000000 && mlGpsData.v == mlGpsData.v){ +// // emit speedChanged(this, (double)mlGpsData.v, 0.0, 0.0, 0.0); + +// } +// else { +// emit textMessageReceived(uasId, uasId, 255, QString("GCS ERROR: RECEIVED INVALID SPEED OF %1 m/s").arg(mlGpsData.v)); +// } + //} + } void SlugsMAV::emitPidSignal() diff --git a/src/uas/SlugsMAV.h b/src/uas/SlugsMAV.h index 295c82065..c30996d32 100644 --- a/src/uas/SlugsMAV.h +++ b/src/uas/SlugsMAV.h @@ -47,6 +47,7 @@ public slots: signals: void slugsRawImu(int uasId, const mavlink_raw_imu_t& rawData); + void slugsGPSCogSog(int uasId, double cog, double sog); #ifdef MAVLINK_ENABLED_SLUGS @@ -67,6 +68,8 @@ signals: void slugsBootMsg(int uasId, mavlink_boot_t& boot); void slugsAttitude(int uasId, mavlink_attitude_t& attitude); + + #endif protected: diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 69af7a9d1..ba5ca80ec 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -328,6 +328,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) emit valueChanged(uasId, "Vz", pos.vz, time); emit localPositionChanged(this, pos.x, pos.y, pos.z, time); emit speedChanged(this, pos.vx, pos.vy, pos.vz, time); + +// qDebug()<<"Local Position = "<* getLinks(); - double getLocalX() const { return localX; }; - double getLocalY() const { return localY; }; - double getLocalZ() const { return localZ; }; - double getLatitude() const { return latitude; }; - double getLongitude() const { return longitude; }; - double getAltitude() const { return altitude; }; - - double getRoll() const { return roll; }; - double getPitch() const { return pitch; }; - double getYaw() const { return yaw; }; + double getLocalX() const { return localX; } + double getLocalY() const { return localY; } + double getLocalZ() const { return localZ; } + double getLatitude() const { return latitude; } + double getLongitude() const { return longitude; } + double getAltitude() const { return altitude; } + + double getRoll() const { return roll; } + double getPitch() const { return pitch; } + double getYaw() const { return yaw; } friend class UASWaypointManager; diff --git a/src/ui/SlugsDataSensorView.cc b/src/ui/SlugsDataSensorView.cc index cf6588b67..c8a12cd56 100644 --- a/src/ui/SlugsDataSensorView.cc +++ b/src/ui/SlugsDataSensorView.cc @@ -41,10 +41,12 @@ void SlugsDataSensorView::addUAS(UASInterface* uas) connect(slugsMav, SIGNAL(speedChanged(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 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&))); @@ -53,7 +55,8 @@ void SlugsDataSensorView::addUAS(UASInterface* uas) 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,mavlink_air_data_t&)),this,SLOT(slugsAirDataChanged(int,mavlink_air_data_t&))); + connect(slugsMav,SIGNAL(slugsAirData(int, const mavlink_air_data_t&)),this,SLOT(slugsAirDataChanged(int, const mavlink_air_data_t&))); + #endif // MAVLINK_ENABLED_SLUGS // Set this UAS as active if it is the first one @@ -70,6 +73,15 @@ void SlugsDataSensorView::slugRawDataChanged(int uasId, const mavlink_raw_imu_t 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)); + } void SlugsDataSensorView::setActiveUAS(UASInterface* uas){ @@ -86,9 +98,13 @@ void SlugsDataSensorView::slugsGlobalPositionChanged(UASInterface *uas, 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 = "<ed_y->setPlainText(QString::number(y)); ui->ed_z->setPlainText(QString::number(z)); + //qDebug()<<"Local Position = "<ed_vy->setPlainText(QString::number(vy)); ui->ed_vz->setPlainText(QString::number(vz)); + //qDebug()<<"Speed Local Position = "<m_Pitch->setPlainText(QString::number(slugpitch)); ui->m_Yaw->setPlainText(QString::number(slugyaw)); + qDebug()<<"Attitude change = "<m_GpsDate->setText(QString::number(gpsDateTime.month) + "/" + - QString::number(gpsDateTime.day) + "/" + + + 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)); - ui->m_GpsTime->setText(QString::number(gpsDateTime.hour) + ":" + - QString::number(gpsDateTime.min) + ":" + - QString::number(gpsDateTime.sec)); + 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)); + + } /** @@ -252,8 +297,31 @@ void SlugsDataSensorView::slugsAirDataChanged(int systemId, const mavlink_air_da ui->ed_static->setText(QString::number(airData.staticPressure)); ui->ed_temp->setText(QString::number(airData.temperature)); +// qDebug()<<"Air Data = "<m_GpsCog->setText(QString::number(cog)); + ui->m_GpsSog->setText(QString::number(sog)); + +} + + + diff --git a/src/ui/SlugsDataSensorView.h b/src/ui/SlugsDataSensorView.h index 07bccc8e2..b1adcca6a 100644 --- a/src/ui/SlugsDataSensorView.h +++ b/src/ui/SlugsDataSensorView.h @@ -70,6 +70,9 @@ public slots: void setActiveUAS(UASInterface* uas); + /** + * @brief Updates the Raw Data widget + */ void slugRawDataChanged (int uasId, const mavlink_raw_imu_t& rawData); #ifdef MAVLINK_ENABLED_SLUGS @@ -115,6 +118,16 @@ public slots: 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 @@ -174,6 +187,9 @@ public slots: + + + #endif // MAVLINK_ENABLED_SLUGS protected: diff --git a/src/ui/SlugsDataSensorView.ui b/src/ui/SlugsDataSensorView.ui index b0ea75669..5474afb0a 100644 --- a/src/ui/SlugsDataSensorView.ui +++ b/src/ui/SlugsDataSensorView.ui @@ -35,7 +35,7 @@ - 2 + 1 -- 2.22.0