Commit 1c144fb6 authored by Don Gagne's avatar Don Gagne

Merge pull request #2291 from DonLakeFlyer/MissionItemFix

Send mission item vehicle trashing float values
parents 135996b3 e81d0bf2
...@@ -200,6 +200,28 @@ MissionItem::MissionItem(int sequenceNumber, ...@@ -200,6 +200,28 @@ MissionItem::MissionItem(int sequenceNumber,
MissionItem::MissionItem(const MissionItem& other, QObject* parent) MissionItem::MissionItem(const MissionItem& other, QObject* parent)
: QObject(parent) : QObject(parent)
, _rawEdit(false)
, _dirty(false)
, _sequenceNumber(0)
, _isCurrentItem(false)
, _distance(0.0)
, _homePositionSpecialCase(false)
, _homePositionValid(false)
, _altitudeRelativeToHomeFact (0, "Altitude is relative to home", FactMetaData::valueTypeUint32)
, _commandFact (0, "Command:", FactMetaData::valueTypeUint32)
, _frameFact (0, "Frame:", FactMetaData::valueTypeUint32)
, _param1Fact (0, "Param1:", FactMetaData::valueTypeDouble)
, _param2Fact (0, "Param2:", FactMetaData::valueTypeDouble)
, _param3Fact (0, "Param3:", FactMetaData::valueTypeDouble)
, _param4Fact (0, "Param4:", FactMetaData::valueTypeDouble)
, _param5Fact (0, "Lat/X:", FactMetaData::valueTypeDouble)
, _param6Fact (0, "Lon/Y:", FactMetaData::valueTypeDouble)
, _param7Fact (0, "Alt/Z:", FactMetaData::valueTypeDouble)
, _supportedCommandFact (0, "Command:", FactMetaData::valueTypeUint32)
, _param1MetaData(FactMetaData::valueTypeDouble)
, _param2MetaData(FactMetaData::valueTypeDouble)
, _param3MetaData(FactMetaData::valueTypeDouble)
, _param4MetaData(FactMetaData::valueTypeDouble)
, _syncingAltitudeRelativeToHomeAndFrame (false) , _syncingAltitudeRelativeToHomeAndFrame (false)
, _syncingHeadingDegreesAndParam4 (false) , _syncingHeadingDegreesAndParam4 (false)
, _syncingSupportedCommandAndCommand (false) , _syncingSupportedCommandAndCommand (false)
......
...@@ -25,68 +25,68 @@ ...@@ -25,68 +25,68 @@
#include "MissionItem.h" #include "MissionItem.h"
const MissionItemTest::ItemInfo_t MissionItemTest::_rgItemInfo[] = { const MissionItemTest::ItemInfo_t MissionItemTest::_rgItemInfo[] = {
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_WAYPOINT, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_LOITER_UNLIM, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TURNS, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_LOITER_TURNS, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TIME, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_LOITER_TIME, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LAND, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_LAND, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_TAKEOFF, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, { MAV_CMD_NAV_TAKEOFF, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_CONDITION_DELAY, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_MISSION }, { MAV_CMD_CONDITION_DELAY, MAV_FRAME_MISSION },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_DO_JUMP, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_MISSION }, { MAV_CMD_DO_JUMP, MAV_FRAME_MISSION },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesWaypoint[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesWaypoint[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Hold:", 10.0 }, { "Hold:", 10.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterUnlim[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterUnlim[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Radius:", 30.0 }, { "Radius:", 30.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTurns[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTurns[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Radius:", 30.0 }, { "Radius:", 30.1234567 },
{ "Turns:", 10.0 }, { "Turns:", 10.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTime[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTime[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Radius:", 30.0 }, { "Radius:", 30.1234567 },
{ "Hold:", 10.0 }, { "Hold:", 10.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLand[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLand[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Abort Alt:", 10.0 }, { "Abort Alt:", 10.1234567 },
{ "Heading:", 1.0 }, { "Heading:", 40.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesTakeoff[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesTakeoff[] = {
{ "Altitude:", -30.0 }, { "Altitude:", 70.1234567 },
{ "Heading:", 1.0 }, { "Heading:", 40.1234567 },
{ "Pitch:", 10.0 }, { "Pitch:", 10.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesConditionDelay[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesConditionDelay[] = {
{ "Hold:", 10.0 }, { "Hold:", 10.1234567 },
}; };
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesDoJump[] = { const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesDoJump[] = {
{ "Item #:", 10.0 }, { "Item #:", 10.1234567 },
{ "Repeat:", 20.0 }, { "Repeat:", 20.1234567 },
}; };
const MissionItemTest::ItemExpected_t MissionItemTest::_rgItemExpected[] = { const MissionItemTest::ItemExpected_t MissionItemTest::_rgItemExpected[] = {
{ "1\t0\t3\t16\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesWaypoint)/sizeof(MissionItemTest::_rgFactValuesWaypoint[0]), MissionItemTest::_rgFactValuesWaypoint }, { sizeof(MissionItemTest::_rgFactValuesWaypoint)/sizeof(MissionItemTest::_rgFactValuesWaypoint[0]), MissionItemTest::_rgFactValuesWaypoint },
{ "1\t0\t3\t17\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterUnlim)/sizeof(MissionItemTest::_rgFactValuesLoiterUnlim[0]), MissionItemTest::_rgFactValuesLoiterUnlim }, { sizeof(MissionItemTest::_rgFactValuesLoiterUnlim)/sizeof(MissionItemTest::_rgFactValuesLoiterUnlim[0]), MissionItemTest::_rgFactValuesLoiterUnlim },
{ "1\t0\t3\t18\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTurns)/sizeof(MissionItemTest::_rgFactValuesLoiterTurns[0]), MissionItemTest::_rgFactValuesLoiterTurns }, { sizeof(MissionItemTest::_rgFactValuesLoiterTurns)/sizeof(MissionItemTest::_rgFactValuesLoiterTurns[0]), MissionItemTest::_rgFactValuesLoiterTurns },
{ "1\t0\t3\t19\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTime)/sizeof(MissionItemTest::_rgFactValuesLoiterTime[0]), MissionItemTest::_rgFactValuesLoiterTime }, { sizeof(MissionItemTest::_rgFactValuesLoiterTime)/sizeof(MissionItemTest::_rgFactValuesLoiterTime[0]), MissionItemTest::_rgFactValuesLoiterTime },
{ "1\t0\t3\t21\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLand)/sizeof(MissionItemTest::_rgFactValuesLand[0]), MissionItemTest::_rgFactValuesLand }, { sizeof(MissionItemTest::_rgFactValuesLand)/sizeof(MissionItemTest::_rgFactValuesLand[0]), MissionItemTest::_rgFactValuesLand },
{ "1\t0\t3\t22\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesTakeoff)/sizeof(MissionItemTest::_rgFactValuesTakeoff[0]), MissionItemTest::_rgFactValuesTakeoff }, { sizeof(MissionItemTest::_rgFactValuesTakeoff)/sizeof(MissionItemTest::_rgFactValuesTakeoff[0]), MissionItemTest::_rgFactValuesTakeoff },
{ "1\t0\t2\t112\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesConditionDelay)/sizeof(MissionItemTest::_rgFactValuesConditionDelay[0]), MissionItemTest::_rgFactValuesConditionDelay }, { sizeof(MissionItemTest::_rgFactValuesConditionDelay)/sizeof(MissionItemTest::_rgFactValuesConditionDelay[0]), MissionItemTest::_rgFactValuesConditionDelay },
{ "1\t0\t2\t177\t10\t20\t30\t1\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesDoJump)/sizeof(MissionItemTest::_rgFactValuesDoJump[0]), MissionItemTest::_rgFactValuesDoJump }, { sizeof(MissionItemTest::_rgFactValuesDoJump)/sizeof(MissionItemTest::_rgFactValuesDoJump[0]), MissionItemTest::_rgFactValuesDoJump },
}; };
MissionItemTest::MissionItemTest(void) MissionItemTest::MissionItemTest(void)
...@@ -102,24 +102,35 @@ void MissionItemTest::_test(void) ...@@ -102,24 +102,35 @@ void MissionItemTest::_test(void)
qDebug() << "Command:" << info->command; qDebug() << "Command:" << info->command;
MissionItem* item = new MissionItem(info->sequenceNumber, MissionItem* item = new MissionItem(1,
info->command, info->command,
info->frame, info->frame,
info->param1, 10.1234567,
info->param2, 20.1234567,
info->param3, 30.1234567,
info->param4, 40.1234567,
info->coordinate.latitude(), 50.1234567,
info->coordinate.longitude(), 60.1234567,
info->coordinate.altitude(), 70.1234567,
info->autocontinue, true,
info->isCurrentItem); false);
// Validate the saving is working correctly // Validate the saving is working correctly
QString savedItemString; QString savedItemString;
QTextStream saveStream(&savedItemString, QIODevice::WriteOnly); QTextStream saveStream(&savedItemString, QIODevice::WriteOnly);
item->save(saveStream); item->save(saveStream);
QCOMPARE(savedItemString, QString(expected->streamString));
// Param floats to string with 18 digits or precision
QString paramStrings = "10.1234567000000002\t"
"20.1234566999999984\t"
"30.1234566999999984\t"
"40.1234566999999984\t"
"50.1234566999999984\t"
"60.1234566999999984\t"
"70.1234567000000055";
QString expectedItemString = QString("1\t0\t%1\t%2\t%3\t1\r\n").arg(info->frame).arg(info->command).arg(paramStrings);
QCOMPARE(savedItemString, expectedItemString);
// Validate that the fact values are correctly returned // Validate that the fact values are correctly returned
size_t factCount = 0; size_t factCount = 0;
......
...@@ -47,15 +47,7 @@ private slots: ...@@ -47,15 +47,7 @@ private slots:
private: private:
typedef struct { typedef struct {
int sequenceNumber;
QGeoCoordinate coordinate;
MAV_CMD command; MAV_CMD command;
double param1;
double param2;
double param3;
double param4;
bool autocontinue;
bool isCurrentItem;
MAV_FRAME frame; MAV_FRAME frame;
} ItemInfo_t; } ItemInfo_t;
...@@ -65,7 +57,6 @@ private: ...@@ -65,7 +57,6 @@ private:
} FactValue_t; } FactValue_t;
typedef struct { typedef struct {
const char* streamString;
size_t cFactValues; size_t cFactValues;
const FactValue_t* rgFactValues; const FactValue_t* rgFactValues;
} ItemExpected_t; } ItemExpected_t;
......
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