Commit ceead0c5 authored by Jessica's avatar Jessica

Merge branch 'signalWaypoint_unittest_fix' into organize

parents 6c6684d3 8d3f5c4c
......@@ -229,14 +229,21 @@ FORMS += src/ui/MainWindow.ui \
src/ui/designer/QGCCommandButton.ui \
src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCWaypointListMulti.ui \
src/ui/mission/QGCCustomWaypointAction.ui \
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/QGCSettingsWidget.ui \
src/ui/UASControlParameters.ui \
src/ui/mission/QGCMissionDoWidget.ui \
src/ui/mission/QGCMissionConditionWidget.ui \
src/ui/map/QGCMapTool.ui \
src/ui/map/QGCMapToolBar.ui \
src/ui/mission/QGCMissionOther.ui \
src/ui/mission/QGCMissionConditionDelay.ui \
src/ui/mission/QGCMissionDoJump.ui \
src/ui/mission/QGCMissionNavReturnToLaunch.ui \
src/ui/mission/QGCMissionNavLoiterUnlim.ui \
src/ui/mission/QGCMissionNavLoiterTurns.ui \
src/ui/mission/QGCMissionNavTakeoff.ui \
src/ui/mission/QGCMissionNavLand.ui \
src/ui/mission/QGCMissionNavWaypoint.ui \
src/ui/mission/QGCMissionNavLoiterTime.ui \
src/ui/QGCMAVLinkInspector.ui \
src/ui/WaypointViewOnlyView.ui \
src/ui/WaypointEditableView.ui \
......@@ -326,6 +333,7 @@ HEADERS += src/MG.h \
src/comm/QGCMAVLink.h \
src/ui/QGCWebView.h \
src/ui/map3D/QGCWebPage.h \
src/ui/map3D/PixhawkCheetahNode.cc \
src/ui/SlugsDataSensorView.h \
src/ui/SlugsHilSim.h \
src/ui/SlugsPadCameraControl.h \
......@@ -344,14 +352,22 @@ HEADERS += src/MG.h \
src/ui/QGCUDPLinkConfiguration.h \
src/ui/QGCSettingsWidget.h \
src/ui/uas/UASControlParameters.h \
src/ui/mission/QGCMissionDoWidget.h \
src/ui/mission/QGCMissionConditionWidget.h \
src/uas/QGCUASParamManager.h \
src/ui/map/QGCMapWidget.h \
src/ui/map/MAV2DIcon.h \
src/ui/map/Waypoint2DIcon.h \
src/ui/map/QGCMapTool.h \
src/ui/map/QGCMapToolBar.h \
src/ui/mission/QGCMissionOther.h \
src/ui/mission/QGCMissionConditionDelay.h \
src/ui/mission/QGCMissionDoJump.h \
src/ui/mission/QGCMissionNavReturnToLaunch.h \
src/ui/mission/QGCMissionNavLoiterUnlim.h \
src/ui/mission/QGCMissionNavLoiterTurns.h \
src/ui/mission/QGCMissionNavTakeoff.h \
src/ui/mission/QGCMissionNavLand.h \
src/ui/mission/QGCMissionNavWaypoint.h \
src/ui/mission/QGCMissionNavLoiterTime.h \
src/libs/qextserialport/qextserialenumerator.h \
src/QGCGeo.h \
src/ui/QGCToolBar.h \
......@@ -493,14 +509,22 @@ SOURCES += src/QGCCore.cc \
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/QGCSettingsWidget.cc \
src/ui/uas/UASControlParameters.cpp \
src/ui/mission/QGCMissionDoWidget.cc \
src/ui/mission/QGCMissionConditionWidget.cc \
src/uas/QGCUASParamManager.cc \
src/ui/map/QGCMapWidget.cc \
src/ui/map/MAV2DIcon.cc \
src/ui/map/Waypoint2DIcon.cc \
src/ui/map/QGCMapTool.cc \
src/ui/map/QGCMapToolBar.cc \
src/ui/mission/QGCMissionOther.cc \
src/ui/mission/QGCMissionConditionDelay.cc \
src/ui/mission/QGCMissionDoJump.cc \
src/ui/mission/QGCMissionNavReturnToLaunch.cc \
src/ui/mission/QGCMissionNavLoiterUnlim.cc \
src/ui/mission/QGCMissionNavLoiterTurns.cc \
src/ui/mission/QGCMissionNavTakeoff.cc \
src/ui/mission/QGCMissionNavLand.cc \
src/ui/mission/QGCMissionNavWaypoint.cc \
src/ui/mission/QGCMissionNavLoiterTime.cc \
src/ui/QGCToolBar.cc \
src/ui/QGCMAVLinkInspector.cc \
src/ui/MAVLinkDecoder.cc \
......@@ -533,7 +557,7 @@ contains(DEPENDENCIES_PRESENT, osg) {
src/ui/map3D/Q3DWidget.cc \
src/ui/map3D/ImageWindowGeode.cc \
src/ui/map3D/GCManipulator.cc \
src/ui/map3D/PixhawkCheetahGeode.cc \
src/ui/map3D/PixhawkCheetahNode.cc \
src/ui/map3D/Pixhawk3DWidget.cc \
src/ui/map3D/Q3DWidgetFactory.cc \
src/ui/map3D/WebImageCache.cc \
......
......@@ -15,7 +15,7 @@
namespace AutoTest
{
typedef QList<QObject*> TestList;
inline TestList& testList()
{
static TestList list;
......@@ -49,14 +49,14 @@ namespace AutoTest
}
inline int run(int argc, char *argv[])
{
{
int ret = 0;
QCoreApplication t(argc, argv);
foreach (QObject* test, testList())
{
ret += QTest::qExec(test, argc, argv);
{
ret += QTest::qExec(test, argc, argv);
}
return ret;
}
}
......
#include "UASUnitTest.h"
#include <stdio.h>
#include <QObject>
UASUnitTest::UASUnitTest()
{
}
void UASUnitTest::initTestCase()
//This function is called after every test
void UASUnitTest::init()
{
mav = new MAVLinkProtocol();
uas = new UAS(mav,UASID);
uas = new UAS(mav, UASID);
uas->deleteSettings();
}
void UASUnitTest::cleanupTestCase()
//this function is called after every test
void UASUnitTest::cleanup()
{
delete uas;
delete mav;
delete mav;
mav = NULL;
if(uas != NULL){
delete uas;
uas = NULL;
}
}
void UASUnitTest::getUASID_test()
......@@ -32,6 +38,7 @@ void UASUnitTest::getUASID_test()
// Make sure that ID >= 0
QCOMPARE(uas->getUASID(), 100);
}
void UASUnitTest::getUASName_test()
......@@ -118,11 +125,12 @@ void UASUnitTest::getStatusForCode_test()
uas->getStatusForCode(5325, state, desc);
QVERIFY(state == "UNKNOWN");
}
void UASUnitTest::getLocalX_test()
{
QCOMPARE(uas->getLocalX(), 0.0);
QCOMPARE(uas->getLocalX(), 0.0);
}
void UASUnitTest::getLocalY_test()
{
......@@ -162,18 +170,32 @@ void UASUnitTest::getSelected_test()
}
void UASUnitTest::getSystemType_test()
{
{ //check that system type is set to MAV_TYPE_GENERIC when initialized
QCOMPARE(uas->getSystemType(), 0);
uas->setSystemType(13);
QCOMPARE(uas->getSystemType(), 13);
}
void UASUnitTest::getAirframe_test()
{
//when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC which is 0
QCOMPARE(uas->getAirframe(), 0);
uas->setAirframe(25);
QVERIFY(uas->getAirframe() == 25);
}
void UASUnitTest::setAirframe_test()
{
//check at construction, that airframe=0 (GENERIC)
QVERIFY(uas->getAirframe() == 0);
//check that set airframe works
uas->setAirframe(11);
QVERIFY(uas->getAirframe() == 11);
//check that setAirframe will not assign a number to airframe, that is
//not defined in the enum
uas->setAirframe(12);
QVERIFY(uas->getAirframe() == 11);
}
void UASUnitTest::getWaypointList_test()
{
QVector<Waypoint*> kk = uas->getWaypointManager()->getWaypointEditableList();
......@@ -200,11 +222,12 @@ void UASUnitTest::getWaypointList_test()
QCOMPARE(kk.count(), 0);
qDebug()<<"disconnect SIGNAL waypointListChanged";
}
void UASUnitTest::getWaypoint_test()
{
Waypoint* wp = new Waypoint(0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
Waypoint* wp = new Waypoint(0,5.6,2.0,3.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
uas->getWaypointManager()->addWaypointEditable(wp, true);
......@@ -213,22 +236,31 @@ void UASUnitTest::getWaypoint_test()
QCOMPARE(wpList.count(), 1);
QCOMPARE(static_cast<quint16>(0), static_cast<Waypoint*>(wpList.at(0))->getId());
wp = new Waypoint(0, 5.6, 2, 3);
uas->getWaypointManager()->addWaypointEditable(wp, true);
Waypoint* wp3 = new Waypoint(1, 5.6, 2.0, 3.0);
uas->getWaypointManager()->addWaypointEditable(wp3, true);
wpList = uas->getWaypointManager()->getWaypointEditableList();
Waypoint* wp2 = static_cast<Waypoint*>(wpList.at(0));
QCOMPARE(wp->getX(), wp2->getX());
QCOMPARE(wp->getFrame(), MAV_FRAME_GLOBAL);
QCOMPARE(wp->getFrame(), wp2->getFrame());
QCOMPARE(wpList.count(), 2);
QCOMPARE(wp3->getX(), wp2->getX());
QCOMPARE(wp3->getY(), wp2->getY());
QCOMPARE(wp3->getZ(), wp2->getZ());
QCOMPARE(wpList.at(1)->getId(), static_cast<quint16>(1));
QCOMPARE(wp3->getFrame(), MAV_FRAME_GLOBAL);
QCOMPARE(wp3->getFrame(), wp2->getFrame());
delete wp3;
delete wp;
}
void UASUnitTest::signalWayPoint_test()
{
QSignalSpy spy(uas->getWaypointManager(), SIGNAL(waypointListChanged()));
Waypoint* wp = new Waypoint(0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
QSignalSpy spy(uas->getWaypointManager(), SIGNAL(waypointEditableListChanged()));
Waypoint* wp = new Waypoint(0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
uas->getWaypointManager()->addWaypointEditable(wp, true);
QCOMPARE(spy.count(), 1); // 1 listChanged for add wayPoint
uas->getWaypointManager()->removeWaypoint(0);
QCOMPARE(spy.count(), 2); // 2 listChanged for remove wayPoint
......@@ -238,18 +270,21 @@ void UASUnitTest::signalWayPoint_test()
QCOMPARE( spyDestroyed.count(), 0 );
delete uas;// delete(destroyed) uas for validating
uas = NULL;
QCOMPARE(spyDestroyed.count(), 1);// count destroyed uas should are 1
uas = new UAS(mav,UASID);
QSignalSpy spy2(uas->getWaypointManager(), SIGNAL(waypointListChanged()));
QSignalSpy spy2(uas->getWaypointManager(), SIGNAL(waypointEditableListChanged()));
QCOMPARE(spy2.count(), 0);
Waypoint* wp2 = new Waypoint(0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
uas->getWaypointManager()->addWaypointEditable(wp, true);
uas->getWaypointManager()->addWaypointEditable(wp2, true);
QCOMPARE(spy2.count(), 1);
uas->getWaypointManager()->clearWaypointList();
QVector<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QCOMPARE(wpList.count(), 1);
delete wp2;
}
void UASUnitTest::signalUASLink_test()
......@@ -308,6 +343,7 @@ void UASUnitTest::signalUASLink_test()
LinkManager::instance()->add(link);
LinkManager::instance()->addProtocol(link, mav);
QCOMPARE(spyS.count(), 3);
}
void UASUnitTest::signalIdUASLink_test()
......@@ -331,4 +367,5 @@ void UASUnitTest::signalIdUASLink_test()
QCOMPARE(a->getName(), QString("serial port COM 17"));
QCOMPARE(b->getName(), QString("serial port COM 18"));
}
......@@ -26,10 +26,9 @@ public:
UASUnitTest();
private slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
void getUASID_test();
void getUASName_test();
void getUpTime_test();
......@@ -47,16 +46,13 @@ private slots:
void getRoll_test();
void getPitch_test();
void getYaw_test();
void getSelected_test();
void getSystemType_test();
void getAirframe_test();
void setAirframe_test();
void getWaypointList_test();
void getWaypoint_test();
void signalWayPoint_test();
void getWaypoint_test();
void signalUASLink_test();
void signalIdUASLink_test();
};
......
......@@ -30,8 +30,8 @@ This file is part of the QGROUNDCONTROL project
#ifndef QGCMAVLINK_H
#define QGCMAVLINK_H
#include <mavlink_types.h>
#include <mavlink.h>
#include <../../mavlink/include/mavlink/v1.0/mavlink_types.h>
#include <../../mavlink/include/mavlink/v1.0/common/mavlink.h>
#ifdef MAVLINK_CONF
#define MY_MACRO(x) <x>
......
......@@ -25,7 +25,7 @@ This file is part of the QGROUNDCONTROL project
#define SLUGSMAV_H
#include "UAS.h"
#include "mavlink.h"
#include "../../mavlink/include/mavlink/v1.0/common/mavlink.h"
#include <QTimer>
#define SLUGS_UPDATE_RATE 200 // in ms
......
......@@ -86,7 +86,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
receivedRGBDImageTimestamp(0.0),
#endif
paramsOnceRequested(false),
airframe(QGC_AIRFRAME_EASYSTAR),
airframe(QGC_AIRFRAME_GENERIC),
attitudeKnown(false),
paramManager(NULL),
attitudeStamped(false),
......@@ -97,20 +97,22 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
systemIsArmed(false),
nedPosGlobalOffset(0,0,0),
nedAttGlobalOffset(0,0,0)
{
for (unsigned int i = 0; i<255;++i)
{
componentID[i] = -1;
componentMulti[i] = false;
}
color = UASInterface::getNextColor();
setBatterySpecs(QString("9V,9.5V,12.6V"));
connect(statusTimeout, SIGNAL(timeout()), this, SLOT(updateState()));
connect(this, SIGNAL(systemSpecsChanged(int)), this, SLOT(writeSettings()));
statusTimeout->start(500);
readSettings();
readSettings();
type = MAV_TYPE_GENERIC;
// Initial signals
emit disarmed();
emit armingChanged(false);
......@@ -122,7 +124,6 @@ UAS::~UAS()
delete links;
links=NULL;
}
void UAS::writeSettings()
{
QSettings settings;
......@@ -149,6 +150,14 @@ void UAS::readSettings()
settings.endGroup();
}
void UAS::deleteSettings()
{
this->name = "";
this->airframe = QGC_AIRFRAME_GENERIC;
this->autopilot = -1;
setBatterySpecs(QString("9V,9.5V,12.6V"));
}
int UAS::getUASID() const
{
return uasId;
......@@ -2073,21 +2082,25 @@ void UAS::requestParameter(int component, const QString& parameter)
void UAS::setSystemType(int systemType)
{
type = systemType;
// If the airframe is still generic, change it to a close default type
if (airframe == 0)
{
switch (systemType)
{
case MAV_TYPE_FIXED_WING:
airframe = QGC_AIRFRAME_EASYSTAR;
break;
case MAV_TYPE_QUADROTOR:
airframe = QGC_AIRFRAME_MIKROKOPTER;
break;
}
}
emit systemSpecsChanged(uasId);
if((systemType >= MAV_TYPE_GENERIC) && (systemType < MAV_TYPE_ENUM_END))
{
type = systemType;
// If the airframe is still generic, change it to a close default type
if (airframe == 0)
{
switch (systemType)
{
case MAV_TYPE_FIXED_WING:
airframe = QGC_AIRFRAME_EASYSTAR;
break;
case MAV_TYPE_QUADROTOR:
airframe = QGC_AIRFRAME_MIKROKOPTER;
break;
}
}
emit systemSpecsChanged(uasId);
}
}
void UAS::setUASName(const QString& name)
......
......@@ -143,7 +143,6 @@ public:
return yaw;
}
bool getSelected() const;
QVector3D getNedPosGlobalOffset() const
{
return nedPosGlobalOffset;
......@@ -430,7 +429,7 @@ public:
QImage getImage();
void requestImage();
int getAutopilotType() {
int getAutopilotType(){
return autopilot;
}
QString getAutopilotTypeName()
......@@ -491,8 +490,12 @@ public slots:
/** @brief Set the specific airframe type */
void setAirframe(int airframe)
{
this->airframe = airframe;
emit systemSpecsChanged(uasId);
if((airframe >= QGC_AIRFRAME_GENERIC) && (airframe < QGC_AIRFRAME_END_OF_ENUM))
{
this->airframe = airframe;
emit systemSpecsChanged(uasId);
}
}
/** @brief Set a new name **/
void setUASName(const QString& name);
......@@ -638,9 +641,8 @@ public slots:
void startDataRecording();
void stopDataRecording();
void deleteSettings();
signals:
/** @brief The main/battery voltage has changed/was updated */
//void voltageChanged(int uasId, double voltage); // Defined in UASInterface already
/** @brief An actuator value has changed */
......
......@@ -149,7 +149,8 @@ public:
QGC_AIRFRAME_COAXIAL,
QGC_AIRFRAME_PTERYX,
QGC_AIRFRAME_TRICOPTER,
QGC_AIRFRAME_HEXCOPTER
QGC_AIRFRAME_HEXCOPTER,
QGC_AIRFRAME_END_OF_ENUM
};
/**
......@@ -171,36 +172,34 @@ public:
*/
static QColor getNextColor() {
/* Create color map */
static QList<QColor> colors = QList<QColor>();
static QList<QColor> colors = QList<QColor>()
<< QColor(231,72,28)
<< QColor(104,64,240)
<< QColor(203,254,121)
<< QColor(161,252,116)
<< QColor(232,33,47)
<< QColor(116,251,110)
<< QColor(234,38,107)
<< QColor(104,250,138)
<< QColor(235,43,165)
<< QColor(98,248,176)
<< QColor(236,48,221)
<< QColor(92,247,217)
<< QColor(200,54,238)
<< QColor(87,231,246)
<< QColor(151,59,239)
<< QColor(81,183,244)
<< QColor(75,133,243)
<< QColor(242,255,128)
<< QColor(230,126,23);
static int nextColor = -1;
if (nextColor == -1) {
///> Color map for plots, includes 20 colors
///> Map will start from beginning when the first 20 colors are exceeded
colors.append(QColor(231,72,28));
colors.append(QColor(104,64,240));
colors.append(QColor(203,254,121));
colors.append(QColor(161,252,116));
colors.append(QColor(232,33,47));
colors.append(QColor(116,251,110));
colors.append(QColor(234,38,107));
colors.append(QColor(104,250,138));
colors.append(QColor(235,43,165));
colors.append(QColor(98,248,176));
colors.append(QColor(236,48,221));
colors.append(QColor(92,247,217));
colors.append(QColor(200,54,238));
colors.append(QColor(87,231,246));
colors.append(QColor(151,59,239));
colors.append(QColor(81,183,244));
colors.append(QColor(75,133,243));
colors.append(QColor(242,255,128));
colors.append(QColor(230,126,23));
nextColor = 0;
if(nextColor == 18){//if at the end of the list
nextColor = -1;//go back to the beginning
}
return colors[nextColor++];
}
nextColor++;
return colors[nextColor];//return the next color
}
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
virtual int getSystemType() = 0;
......
......@@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASWaypointManager.h"
#include "UAS.h"
#include "mavlink_types.h"
#include "../../mavlink/include/mavlink/v1.0/mavlink_types.h"
#define PROTOCOL_TIMEOUT_MS 2000 ///< maximum time to wait for pending messages until timeout
#define PROTOCOL_DELAY_MS 20 ///< minimum delay between sent messages
......
......@@ -4,7 +4,7 @@
#include "UAS.h"
#include "mavlink.h"
#include "../../mavlink/include/mavlink/v1.0/common/mavlink.h"
#include <QTimer>
......@@ -26,4 +26,4 @@ private:
void quat2euler(const double *quat, double &roll, double &pitch, double &yaw);
};
#endif // _SENSESOARMAV_H_
\ No newline at end of file
#endif // _SENSESOARMAV_H_
......@@ -35,7 +35,7 @@ This file is part of the QGROUNDCONTROL project
#include "ui_DebugConsole.h"
#include "LinkManager.h"
#include "UASManager.h"
#include "protocol.h"
#include "../../mavlink/include/mavlink/v1.0/protocol.h"
#include "QGC.h"
#include <QDebug>
......
......@@ -50,8 +50,8 @@ This file is part of the QGROUNDCONTROL project
#include "SwitchCalibrator.h"
#include "CurveCalibrator.h"
#include "mavlink.h"
#include "mavlink_types.h"
#include "../../../mavlink/include/mavlink/v1.0/common/mavlink.h"
#include "../../../mavlink/include/mavlink/v1.0/mavlink_types.h"
#include "UAS.h"
#include "UASManager.h"
#include "RadioCalibrationData.h"
......
......@@ -36,7 +36,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASInterface.h"
#include "SlugsMAV.h"
#include "mavlink.h"
#include "../../mavlink/include/mavlink/v1.0/common/mavlink.h"
namespace Ui
......
......@@ -21,19 +21,19 @@
#include "ui_WaypointEditableView.h"
#include "QGCMissionNavWaypoint.h"
#include "QGCMissionNavLoiterUnlim.h"
#include "QGCMissionNavLoiterTurns.h"
#include "QGCMissionNavLoiterTime.h"
#include "QGCMissionNavReturnToLaunch.h"
#include "QGCMissionNavLand.h"
#include "QGCMissionNavTakeoff.h"
#include "QGCMissionNavSweep.h"
#include "QGCMissionConditionDelay.h"
#include "QGCMissionDoJump.h"
#include "QGCMissionDoStartSearch.h"
#include "QGCMissionDoFinishSearch.h"
#include "QGCMissionOther.h"
#include "mission/QGCMissionNavWaypoint.h"
#include "mission/QGCMissionNavLoiterUnlim.h"
#include "mission/QGCMissionNavLoiterTurns.h"
#include "mission/QGCMissionNavLoiterTime.h"
#include "mission/QGCMissionNavReturnToLaunch.h"
#include "mission/QGCMissionNavLand.h"
#include "mission/QGCMissionNavTakeoff.h"
#include "mission/QGCMissionNavSweep.h"
#include "mission/QGCMissionConditionDelay.h"
#include "mission/QGCMissionDoJump.h"
#include "mission/QGCMissionDoStartSearch.h"
#include "mission/QGCMissionDoFinishSearch.h"
#include "mission/QGCMissionOther.h"
WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) :
......
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