Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
96f44416
Commit
96f44416
authored
Mar 15, 2015
by
Don Gagne
Browse files
Merge pull request #1362 from DonLakeFlyer/Preflight
Preflight check
parents
65e79da4
a03e816a
Changes
14
Hide whitespace changes
Inline
Side-by-side
qgroundcontrol.pro
View file @
96f44416
...
...
@@ -479,7 +479,6 @@ HEADERS += \
src
/
uas
/
QGCUASFileManager
.
h
\
src
/
ui
/
QGCUASFileView
.
h
\
src
/
CmdLineOptParser
.
h
\
src
/
uas
/
QGXPX4UAS
.
h
\
src
/
QGCFileDialog
.
h
\
src
/
QGCMessageBox
.
h
\
src
/
QGCComboBox
.
h
\
...
...
@@ -623,7 +622,6 @@ SOURCES += \
src
/
uas
/
QGCUASFileManager
.
cc
\
src
/
ui
/
QGCUASFileView
.
cc
\
src
/
CmdLineOptParser
.
cc
\
src
/
uas
/
QGXPX4UAS
.
cc
\
src
/
QGCFileDialog
.
cc
\
src
/
QGCComboBox
.
cc
\
src
/
QGCTemporaryFile
.
cc
\
...
...
src/AutoPilotPlugins/PX4/FlightModesComponentController.cc
View file @
96f44416
...
...
@@ -69,7 +69,11 @@ void FlightModesComponentController::_validateConfiguration(void)
{
_validConfiguration
=
true
;
_channelCount
=
_autoPilotPlugin
->
factExists
(
"RC_CHAN_CNT"
)
?
_autoPilotPlugin
->
getFact
(
"RC_CHAN_CNT"
)
->
value
().
toInt
()
:
18
;
_channelCount
=
_autoPilotPlugin
->
factExists
(
"RC_CHAN_CNT"
)
?
_autoPilotPlugin
->
getFact
(
"RC_CHAN_CNT"
)
->
value
().
toInt
()
:
_chanMax
;
if
(
_channelCount
<=
0
||
_channelCount
>
_chanMax
)
{
// Parameter exists, but has not yet been set or is invalid. Use default
_channelCount
=
_chanMax
;
}
// Make sure switches are valid and within channel range
...
...
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
View file @
96f44416
...
...
@@ -80,7 +80,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
_parameterFacts
=
new
PX4ParameterFacts
(
uas
,
this
);
Q_CHECK_PTR
(
_parameterFacts
);
connect
(
_parameterFacts
,
&
PX4ParameterFacts
::
factsReady
,
this
,
&
PX4AutoPilotPlugin
::
_
checkForIncorrectParameterVersion
);
connect
(
_parameterFacts
,
&
PX4ParameterFacts
::
factsReady
,
this
,
&
PX4AutoPilotPlugin
::
_
pluginReadyPreChecks
);
PX4ParameterFacts
::
loadParameterFactMetaData
();
}
...
...
@@ -237,12 +237,29 @@ QUrl PX4AutoPilotPlugin::setupBackgroundImage(void)
return
QUrl
::
fromUserInput
(
"qrc:/qml/px4fmu_2.x.png"
);
}
void
PX4AutoPilotPlugin
::
_checkForIncorrectParameterVersion
(
void
)
/// This will perform various checks prior to signalling that the plug in ready
void
PX4AutoPilotPlugin
::
_pluginReadyPreChecks
(
void
)
{
// Check for older parameter version set
// FIXME: Firmware is moving to version stamp parameter set. Once that is complete the version stamp
// should be used instead.
if
(
parameters
().
contains
(
"SENS_GYRO_XOFF"
))
{
_incorrectParameterVersion
=
true
;
QGCMessageBox
::
warning
(
tr
(
"Setup"
),
tr
(
"This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup."
));
}
else
{
// Check for missing setup complete
foreach
(
const
QVariant
componentVariant
,
components
())
{
VehicleComponent
*
component
=
qobject_cast
<
VehicleComponent
*>
(
qvariant_cast
<
QObject
*>
(
componentVariant
));
Q_ASSERT
(
component
);
if
(
!
component
->
setupComplete
())
{
QGCMessageBox
::
warning
(
tr
(
"Setup"
),
tr
(
"One or more vehicle components require setup prior to flight. "
"Please correct these by going to the Setup view."
));
break
;
}
}
}
emit
pluginReady
();
}
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
View file @
96f44416
...
...
@@ -68,7 +68,7 @@ public:
PowerComponent
*
powerComponent
(
void
)
{
return
_powerComponent
;
}
private
slots
:
void
_
checkForIncorrectParameterVersion
(
void
);
void
_
pluginReadyPreChecks
(
void
);
private:
PX4ParameterFacts
*
_parameterFacts
;
...
...
src/qgcunittest/MockLink.param
View file @
96f44416
...
...
@@ -21,20 +21,20 @@
1 50 BD_OBJ_SURFACE 0.00311725 9
1 50 BD_PRECISION 30 9
1 50 BD_TURNRADIUS 120 9
1 50 CAL_ACC0_ID
0
6
1 50 CAL_ACC0_XOFF
0
9
1 50 CAL_ACC0_XSCALE
1
9
1 50 CAL_ACC0_YOFF
0
9
1 50 CAL_ACC0_YSCALE
1
9
1 50 CAL_ACC0_ZOFF
0
9
1 50 CAL_ACC0_ZSCALE
1
9
1 50 CAL_ACC1_ID
0
6
1 50 CAL_ACC1_XOFF
0
9
1 50 CAL_ACC1_XSCALE
1
9
1 50 CAL_ACC1_YOFF
0
9
1 50 CAL_ACC1_YSCALE
1 9
1 50 CAL_ACC1_ZOFF
0
9
1 50 CAL_ACC1_ZSCALE
1
9
1 50 CAL_ACC0_ID
1246218
6
1 50 CAL_ACC0_XOFF
0.0657825
9
1 50 CAL_ACC0_XSCALE
0.99657
9
1 50 CAL_ACC0_YOFF
-0.0470138
9
1 50 CAL_ACC0_YSCALE
1.00066
9
1 50 CAL_ACC0_ZOFF
0.2244
9
1 50 CAL_ACC0_ZSCALE
0.985475
9
1 50 CAL_ACC1_ID
1114634
6
1 50 CAL_ACC1_XOFF
0.976983
9
1 50 CAL_ACC1_XSCALE
0.978487
9
1 50 CAL_ACC1_YOFF
0.92215
9
1 50 CAL_ACC1_YSCALE
1.0118
1 9
1 50 CAL_ACC1_ZOFF
1.07291
9
1 50 CAL_ACC1_ZSCALE
1.00673
9
1 50 CAL_ACC2_ID 0 6
1 50 CAL_ACC2_XOFF 0 9
1 50 CAL_ACC2_XSCALE 1 9
...
...
@@ -42,20 +42,20 @@
1 50 CAL_ACC2_YSCALE 1 9
1 50 CAL_ACC2_ZOFF 0 9
1 50 CAL_ACC2_ZSCALE 1 9
1 50 CAL_BOARD_ID
0
6
1 50 CAL_GYRO0_ID
0
6
1 50 CAL_GYRO0_XOFF
0
9
1 50 CAL_BOARD_ID
825374003
6
1 50 CAL_GYRO0_ID
2163722
6
1 50 CAL_GYRO0_XOFF
0.0102227
9
1 50 CAL_GYRO0_XSCALE 1 9
1 50 CAL_GYRO0_YOFF
0
9
1 50 CAL_GYRO0_YOFF
0.0485427
9
1 50 CAL_GYRO0_YSCALE 1 9
1 50 CAL_GYRO0_ZOFF
0
9
1 50 CAL_GYRO0_ZOFF
-0.00950837
9
1 50 CAL_GYRO0_ZSCALE 1 9
1 50 CAL_GYRO1_ID 0 6
1 50 CAL_GYRO1_XOFF
0
9
1 50 CAL_GYRO1_ID
222849
0 6
1 50 CAL_GYRO1_XOFF
0.012822
9
1 50 CAL_GYRO1_XSCALE 1 9
1 50 CAL_GYRO1_YOFF
0
9
1 50 CAL_GYRO1_YOFF
0.00126972
9
1 50 CAL_GYRO1_YSCALE 1 9
1 50 CAL_GYRO1_ZOFF
0
9
1 50 CAL_GYRO1_ZOFF
-0.0285923
9
1 50 CAL_GYRO1_ZSCALE 1 9
1 50 CAL_GYRO2_ID 0 6
1 50 CAL_GYRO2_XOFF 0 9
...
...
@@ -64,21 +64,21 @@
1 50 CAL_GYRO2_YSCALE 1 9
1 50 CAL_GYRO2_ZOFF 0 9
1 50 CAL_GYRO2_ZSCALE 1 9
1 50 CAL_MAG0_ID
0
6
1 50 CAL_MAG0_ROT
-1
6
1 50 CAL_MAG0_XOFF
0
9
1 50 CAL_MAG0_XSCALE
1
9
1 50 CAL_MAG0_YOFF
0
9
1 50 CAL_MAG0_YSCALE
1
9
1 50 CAL_MAG0_ZOFF
0
9
1 50 CAL_MAG0_ZSCALE
1 9
1 50 CAL_MAG1_ID
0
6
1 50 CAL_MAG0_ID
73225
6
1 50 CAL_MAG0_ROT
0
6
1 50 CAL_MAG0_XOFF
0.0546612
9
1 50 CAL_MAG0_XSCALE
1.03474
9
1 50 CAL_MAG0_YOFF
-0.0299049
9
1 50 CAL_MAG0_YSCALE
0.934338
9
1 50 CAL_MAG0_ZOFF
-0.100793
9
1 50 CAL_MAG0_ZSCALE
0.98102
1 9
1 50 CAL_MAG1_ID
131594
6
1 50 CAL_MAG1_ROT -1 6
1 50 CAL_MAG1_XOFF
0
9
1 50 CAL_MAG1_XOFF
-0.0239289
9
1 50 CAL_MAG1_XSCALE 1 9
1 50 CAL_MAG1_YOFF
0
9
1 50 CAL_MAG1_YOFF
0.0811809
9
1 50 CAL_MAG1_YSCALE 1 9
1 50 CAL_MAG1_ZOFF
0
9
1 50 CAL_MAG1_ZOFF
0.0455695
9
1 50 CAL_MAG1_ZSCALE 1 9
1 50 CAL_MAG2_ID 0 6
1 50 CAL_MAG2_ROT -1 6
...
...
@@ -180,6 +180,7 @@
1 50 GF_ON 1 6
1 50 GF_SOURCE 0 6
1 50 INAV_DELAY_GPS 0.2 9
1 50 INAV_ENABLED 0 6
1 50 INAV_FLOW_K 0.15 9
1 50 INAV_FLOW_Q_MIN 0.5 9
1 50 INAV_LAND_DISP 0.7 9
...
...
@@ -433,6 +434,7 @@
1 50 RC_ACRO_TH 0.5 9
1 50 RC_ASSIST_TH 0.25 9
1 50 RC_AUTO_TH 0.75 9
1 50 RC_CHAN_CNT 0 6
1 50 RC_DSM_BIND -1 6
1 50 RC_FAILS_THR 0 6
1 50 RC_LOITER_TH 0.5 9
...
...
@@ -443,7 +445,7 @@
1 50 RC_MAP_FAILSAFE 0 6
1 50 RC_MAP_FLAPS 0 6
1 50 RC_MAP_LOITER_SW 0 6
1 50 RC_MAP_MODE_SW
0
6
1 50 RC_MAP_MODE_SW
6
6
1 50 RC_MAP_OFFB_SW 0 6
1 50 RC_MAP_PARAM1 0 6
1 50 RC_MAP_PARAM2 0 6
...
...
@@ -457,6 +459,7 @@
1 50 RC_OFFB_TH 0.5 9
1 50 RC_POSCTL_TH 0.5 9
1 50 RC_RETURN_TH 0.5 9
1 50 RC_TH_USER 1 6
1 50 RTL_DESCEND_ALT 10 9
1 50 RTL_LAND_DELAY -1 9
1 50 RTL_LOITER_RAD 50 9
...
...
src/qgcunittest/PX4RCCalibrationTest.cc
View file @
96f44416
...
...
@@ -31,6 +31,7 @@
/// @author Don Gagne <don@thegagnes.com>
UT_REGISTER_TEST
(
PX4RCCalibrationTest
)
QGC_LOGGING_CATEGORY
(
PX4RCCalibrationTestLog
,
"PX4RCCalibrationTestLog"
)
// This will check for the wizard buttons being enabled of disabled according to the mask you pass in.
// We use a macro instead of a method so that we get better line number reporting on failure.
...
...
@@ -39,7 +40,7 @@ UT_REGISTER_TEST(PX4RCCalibrationTest)
if (_nextButton->isEnabled() != !!((mask) & nextButtonMask) || \
_skipButton->isEnabled() != !!((mask) & skipButtonMask) || \
_cancelButton->isEnabled() != !!((mask) & cancelButtonMask) ) { \
qDebug() << _statusLabel->text(); \
q
C
Debug(
PX4RCCalibrationTestLog
) << _statusLabel->text(); \
} \
QCOMPARE(_nextButton->isEnabled(), !!((mask) & nextButtonMask)); \
QCOMPARE(_skipButton->isEnabled(), !!((mask) & skipButtonMask)); \
...
...
@@ -66,10 +67,6 @@ const int PX4RCCalibrationTest::_testMinValue = PX4RCCalibration::_rcCalPWMDefau
const
int
PX4RCCalibrationTest
::
_testMaxValue
=
PX4RCCalibration
::
_rcCalPWMDefaultMaxValue
-
10
;
const
int
PX4RCCalibrationTest
::
_testCenterValue
=
PX4RCCalibrationTest
::
_testMinValue
+
((
PX4RCCalibrationTest
::
_testMaxValue
-
PX4RCCalibrationTest
::
_testMinValue
)
/
2
);
/// @brief Maps from function index to channel index. -1 signals no mapping. Channel indices are offset 1 from function index
/// to catch bugs where function index is incorrectly used as channel index.
const
int
PX4RCCalibrationTest
::
_rgFunctionChannelMap
[
PX4RCCalibration
::
rcCalFunctionMax
]
=
{
1
,
2
,
3
,
4
,
-
1
,
-
1
,
-
1
,
-
1
,
9
,
10
,
11
};
const
struct
PX4RCCalibrationTest
::
ChannelSettings
PX4RCCalibrationTest
::
_rgChannelSettings
[
PX4RCCalibrationTest
::
_availableChannels
]
=
{
// Function Min Max # Reversed
...
...
@@ -145,19 +142,6 @@ PX4RCCalibrationTest::PX4RCCalibrationTest(void) :
{
}
/// @brief Called one time before any test cases are run.
void
PX4RCCalibrationTest
::
initTestCase
(
void
)
{
// Validate that our function to channel mapping is still correct.
for
(
int
function
=
0
;
function
<
PX4RCCalibration
::
rcCalFunctionMax
;
function
++
)
{
int
chanIndex
=
_rgFunctionChannelMap
[
function
];
if
(
chanIndex
!=
-
1
)
{
Q_ASSERT
(
_rgChannelSettings
[
chanIndex
].
function
==
function
);
Q_ASSERT
(
_rgChannelSettingsValidate
[
chanIndex
].
function
==
function
);
}
}
}
void
PX4RCCalibrationTest
::
init
(
void
)
{
UnitTest
::
init
();
...
...
@@ -252,7 +236,7 @@ void PX4RCCalibrationTest::_minRCChannels_test(void)
// Only available channels should have visible widget. A ui update cycle needs to have passed so we wait a little.
QTest::qWait(PX4RCCalibration::_updateInterval * 2);
for (int chanWidget=0; chanWidget<PX4RCCalibration::_chanMax; chanWidget++) {
//
qDebug() << _rgValueWidget[chanWidget]->objectName() << chanWidget << chan;
q
C
Debug(
PX4RCCalibrationTestLog
) << _rgValueWidget[chanWidget]->objectName() << chanWidget << chan;
QCOMPARE(_rgValueWidget[chanWidget]->isVisible(), !!(chanWidget <= chan));
}
#endif
...
...
@@ -272,7 +256,7 @@ void PX4RCCalibrationTest::_beginCalibration(void)
void
PX4RCCalibrationTest
::
_stickMoveWaitForSettle
(
int
channel
,
int
value
)
{
//
qDebug() << "_stickMoveWaitForSettle channel:value" << channel << value;
q
C
Debug
(
PX4RCCalibrationTestLog
)
<<
"_stickMoveWaitForSettle channel:value"
<<
channel
<<
value
;
// Move the stick, this will initialized the settle checker
_mockUAS
->
emitRemoteControlChannelRawChanged
(
channel
,
value
);
...
...
@@ -290,7 +274,7 @@ void PX4RCCalibrationTest::_stickMoveWaitForSettle(int channel, int value)
void
PX4RCCalibrationTest
::
_stickMoveAutoStep
(
const
char
*
functionStr
,
enum
PX4RCCalibration
::
rcCalFunctions
function
,
enum
PX4RCCalibrationTest
::
MoveToDirection
direction
,
bool
identifyStep
)
{
Q_UNUSED
(
functionStr
);
//
qDebug() << "_stickMoveAutoStep function:direction:reversed:identifyStep" << functionStr << function << direction << identifyStep;
q
C
Debug
(
PX4RCCalibrationTestLog
)
<<
"_stickMoveAutoStep function:direction:reversed:identifyStep"
<<
functionStr
<<
function
<<
direction
<<
identifyStep
;
CHK_BUTTONS
(
cancelButtonMask
);
...
...
@@ -345,7 +329,6 @@ void PX4RCCalibrationTest::_switchMinMaxStep(void)
// Send min/max values switch channels
for
(
int
chan
=
0
;
chan
<
_availableChannels
;
chan
++
)
{
//qDebug() << chan << _rgChannelSettingsPreValidate[chan].rcMin << _rgChannelSettingsPreValidate[chan].rcMax;
_mockUAS
->
emitRemoteControlChannelRawChanged
(
chan
,
_rgChannelSettings
[
chan
].
rcMin
);
_mockUAS
->
emitRemoteControlChannelRawChanged
(
chan
,
_rgChannelSettings
[
chan
].
rcMax
);
}
...
...
@@ -361,7 +344,7 @@ void PX4RCCalibrationTest::_flapsDetectStep(void)
{
int
channel
=
_rgFunctionChannelMap
[
PX4RCCalibration
::
rcCalFunctionFlaps
];
//
qDebug() << "_flapsDetectStep channel" << channel;
q
C
Debug
(
PX4RCCalibrationTestLog
)
<<
"_flapsDetectStep channel"
<<
channel
;
// Test code can't handle reversed flaps channel
Q_ASSERT
(
!
_rgChannelSettings
[
channel
].
reversed
);
...
...
@@ -387,7 +370,7 @@ void PX4RCCalibrationTest::_flapsDetectStep(void)
void
PX4RCCalibrationTest
::
_switchSelectAutoStep
(
const
char
*
functionStr
,
PX4RCCalibration
::
rcCalFunctions
function
)
{
Q_UNUSED
(
functionStr
);
//
q
Debug() << "_switchSelectAutoStep" << functionStr << "function:" << function;
//
//qC
Debug(
PX4RCCalibrationTestLog)(
) << "_switchSelectAutoStep" << functionStr << "function:" << function;
int
buttonMask
=
cancelButtonMask
;
if
(
function
!=
PX4RCCalibration
::
rcCalFunctionModeSwitch
)
{
...
...
@@ -408,6 +391,50 @@ void PX4RCCalibrationTest::_switchSelectAutoStep(const char* functionStr, PX4RCC
void
PX4RCCalibrationTest
::
_fullCalibration_test
(
void
)
{
// IMPORTANT NOTE: We used channels 1-5 for attitude mapping in the test below.
// MockLink.param file cannot have flight mode switches mapped to those channels.
// If it does it will cause errors since the stick will not be detetected where
MockQGCUASParamManager
*
paramMgr
=
_mockUAS
->
getMockQGCUASParamManager
();
MockQGCUASParamManager
::
ParamMap_t
mapParamsSet
=
paramMgr
->
getMockSetParameters
();
/// _rgFunctionChannelMap maps from function index to channel index. For channels which are not part of
/// rc cal set the mapping the the previous mapping.
for
(
int
function
=
0
;
function
<
PX4RCCalibration
::
rcCalFunctionMax
;
function
++
)
{
bool
found
=
false
;
// If we are mapping this function during cal set it into _rgFunctionChannelMap
for
(
int
channel
=
0
;
channel
<
PX4RCCalibrationTest
::
_availableChannels
;
channel
++
)
{
if
(
_rgChannelSettings
[
channel
].
function
==
function
)
{
// First make sure this function isn't being use for a switch
QStringList
switchList
;
switchList
<<
"RC_MAP_MODE_SW"
<<
"RC_MAP_LOITER_SW"
<<
"RC_MAP_RETURN_SW"
<<
"RC_MAP_POSCTL_SW"
;
foreach
(
QString
switchParam
,
switchList
)
{
Q_ASSERT
(
mapParamsSet
[
switchParam
].
toInt
()
!=
channel
+
1
);
}
_rgFunctionChannelMap
[
function
]
=
channel
;
found
=
true
;
break
;
}
}
// If we aren't mapping this function during calibration, set it to the previous setting
if
(
!
found
)
{
_rgFunctionChannelMap
[
function
]
=
mapParamsSet
[
PX4RCCalibration
::
_rgFunctionInfo
[
function
].
parameterName
].
toInt
();
qCDebug
(
PX4RCCalibrationTestLog
)
<<
"Assigning switch"
<<
function
<<
mapParamsSet
[
PX4RCCalibration
::
_rgFunctionInfo
[
function
].
parameterName
].
toInt
();
if
(
_rgFunctionChannelMap
[
function
]
==
0
)
{
_rgFunctionChannelMap
[
function
]
=
-
1
;
// -1 signals no mapping
}
else
{
_rgFunctionChannelMap
[
function
]
--
;
// parameter is 1-based, _rgFunctionChannelMap is not
}
}
}
_channelHomePosition
();
QTest
::
mouseClick
(
_nextButton
,
Qt
::
LeftButton
);
...
...
@@ -466,6 +493,7 @@ void PX4RCCalibrationTest::_validateParameters(void)
expectedParameterValue
=
chanIndex
+
1
;
// 1-based parameter value
}
qCDebug
(
PX4RCCalibrationTestLog
)
<<
"Validate"
<<
chanFunction
<<
mapParamsSet
[
PX4RCCalibration
::
_rgFunctionInfo
[
chanFunction
].
parameterName
].
toInt
();
QCOMPARE
(
mapParamsSet
.
contains
(
PX4RCCalibration
::
_rgFunctionInfo
[
chanFunction
].
parameterName
),
true
);
QCOMPARE
(
mapParamsSet
[
PX4RCCalibration
::
_rgFunctionInfo
[
chanFunction
].
parameterName
].
toInt
(),
expectedParameterValue
);
}
...
...
@@ -496,8 +524,8 @@ void PX4RCCalibrationTest::_validateParameters(void)
QCOMPARE
(
convertOk
,
true
);
bool
rcReversedActual
=
(
rcReversedFloat
==
-
1.0
f
);
//
qDebug() << "_validateParemeters expected channel:min:max:trim:rev" << chan << rcMinExpected << rcMaxExpected << rcTrimExpected << rcReversedExpected;
//
qDebug() << "_validateParemeters actual channel:min:max:trim:rev" << chan << rcMinActual << rcMaxActual << rcTrimActual << rcReversedActual;
q
C
Debug
(
PX4RCCalibrationTestLog
)
<<
"_validateParemeters expected channel:min:max:trim:rev"
<<
chan
<<
rcMinExpected
<<
rcMaxExpected
<<
rcTrimExpected
<<
rcReversedExpected
;
q
C
Debug
(
PX4RCCalibrationTestLog
)
<<
"_validateParemeters actual channel:min:max:trim:rev"
<<
chan
<<
rcMinActual
<<
rcMaxActual
<<
rcTrimActual
<<
rcReversedActual
;
QCOMPARE
(
rcMinExpected
,
rcMinActual
);
QCOMPARE
(
rcMaxExpected
,
rcMaxActual
);
...
...
@@ -515,7 +543,7 @@ void PX4RCCalibrationTest::_validateParameters(void)
}
else
{
expectedValue
=
_rgFunctionChannelMap
[
chanFunction
]
+
1
;
// 1-based
}
// qDebug() << chanFunction << expectedValue << mapParamsSet[PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName].toInt();
// q
C
Debug(
PX4RCCalibrationTestLog
) << chanFunction << expectedValue << mapParamsSet[PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName].toInt();
QCOMPARE
(
mapParamsSet
[
PX4RCCalibration
::
_rgFunctionInfo
[
chanFunction
].
parameterName
].
toInt
(),
expectedValue
);
}
}
src/qgcunittest/PX4RCCalibrationTest.h
View file @
96f44416
...
...
@@ -29,12 +29,15 @@
#include
"MockUAS.h"
#include
"MultiSignalSpy.h"
#include
"px4_configuration/PX4RCCalibration.h"
#include
"QGCLoggingCategory.h"
/// @file
/// @brief PX4RCCalibration Widget unit test
///
/// @author Don Gagne <don@thegagnes.com>
Q_DECLARE_LOGGING_CATEGORY
(
PX4RCCalibrationTestLog
)
/// @brief PX4RCCalibration Widget unit test
class
PX4RCCalibrationTest
:
public
UnitTest
{
...
...
@@ -44,7 +47,6 @@ public:
PX4RCCalibrationTest
(
void
);
private
slots
:
void
initTestCase
(
void
);
void
init
(
void
);
void
cleanup
(
void
);
...
...
@@ -125,7 +127,7 @@ private:
static
const
struct
ChannelSettings
_rgChannelSettings
[
_availableChannels
];
static
const
struct
ChannelSettings
_rgChannelSettingsValidate
[
PX4RCCalibration
::
_chanMax
];
static
const
int
_rgFunctionChannelMap
[
PX4RCCalibration
::
rcCalFunctionMax
];
int
_rgFunctionChannelMap
[
PX4RCCalibration
::
rcCalFunctionMax
];
};
#endif
src/uas/QGCMAVLinkUASFactory.cc
View file @
96f44416
#include
"QGCMAVLinkUASFactory.h"
#include
"UASManager.h"
#include
"QGXPX4UAS.h"
QGCMAVLinkUASFactory
::
QGCMAVLinkUASFactory
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -20,62 +19,31 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte
p
=
mavlink
;
}
UASInterface
*
uas
;
UASInterface
*
uas
Interface
;
switch
(
heartbeat
->
autopilot
)
{
case
MAV_AUTOPILOT_GENERIC
:
{
UAS
*
mav
=
new
UAS
(
mavlink
,
sysid
);
// Set the system type
mav
->
setSystemType
((
int
)
heartbeat
->
type
);
// Connect this robot to the UAS object
connect
(
mavlink
,
SIGNAL
(
messageReceived
(
LinkInterface
*
,
mavlink_message_t
)),
mav
,
SLOT
(
receiveMessage
(
LinkInterface
*
,
mavlink_message_t
)));
connect
(
mavlink
,
SIGNAL
(
messageReceived
(
LinkInterface
*
,
mavlink_message_t
)),
mav
->
getFileManager
(),
SLOT
(
receiveMessage
(
LinkInterface
*
,
mavlink_message_t
)));
uas
=
mav
;
}
break
;
case
MAV_AUTOPILOT_PX4
:
{
QGXPX4UAS
*
px4
=
new
QGXPX4UAS
(
mavlink
,
sysid
);
// Set the system type
px4
->
setSystemType
((
int
)
heartbeat
->
type
);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
// packets never reach their goal)
connect
(
mavlink
,
SIGNAL
(
messageReceived
(
LinkInterface
*
,
mavlink_message_t
)),
px4
,
SLOT
(
receiveMessage
(
LinkInterface
*
,
mavlink_message_t
)));
uas
=
px4
;
}
break
;
default:
{
UAS
*
mav
=
new
UAS
(
mavlink
,
sysid
);
mav
->
setSystemType
((
int
)
heartbeat
->
type
);
UAS
*
uasObject
=
new
UAS
(
mavlink
,
sysid
);
Q_CHECK_PTR
(
uasObject
);
uasInterface
=
uasObject
;
uasObject
->
setSystemType
((
int
)
heartbeat
->
type
);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
// packets never reach their goal)
connect
(
mavlink
,
SIGNAL
(
messageReceived
(
LinkInterface
*
,
mavlink_message_t
)),
mav
,
SLOT
(
receiveMessage
(
LinkInterface
*
,
mavlink_message_t
)));
uas
=
mav
;
}
break
;
}
// Connect this robot to the UAS object
// It is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
// packets never reach their goal)
connect
(
mavlink
,
&
MAVLinkProtocol
::
messageReceived
,
uasObject
,
&
UAS
::
receiveMessage
);
// Set the autopilot type
uas
->
setAutopilotType
((
int
)
heartbeat
->
autopilot
);
uas
Interface
->
setAutopilotType
((
int
)
heartbeat
->
autopilot
);
// Make UAS aware that this link can be used to communicate with the actual robot
uas
->
addLink
(
link
);
uas
Interface
->
addLink
(
link
);
// First thing we do with a new UAS is get the parameters
uas
->
getParamManager
()
->
requestParameterList
();
uas
Interface
->
getParamManager
()
->
requestParameterList
();
// Now add UAS to "official" list, which makes the whole application aware of it
UASManager
::
instance
()
->
addUAS
(
uas
);
UASManager
::
instance
()
->
addUAS
(
uas
Interface
);
return
uas
;
return
uas
Interface
;
}
src/uas/QGXPX4UAS.cc
deleted
100644 → 0
View file @
65e79da4
#include
"QGXPX4UAS.h"
QGXPX4UAS
::
QGXPX4UAS
(
MAVLinkProtocol
*
mavlink
,
int
id
)
:
UAS
(
mavlink
,
id
)
{
}
/**
* 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
QGXPX4UAS
::
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
)
{
UAS
::
receiveMessage
(
link
,
message
);
}
void
QGXPX4UAS
::
processParamValueMsgHook
(
mavlink_message_t
&
msg
,
const
QString
&
paramName
,
const
mavlink_param_value_t
&
rawValue
,
mavlink_param_union_t
&
paramValue
)
{
Q_UNUSED
(
rawValue
);
Q_UNUSED
(
paramValue
);
int
compId
=
msg
.
compid
;
if
(
paramName
==
"SYS_AUTOSTART"
)
{
bool
ok
;
int
val
=
parameters
.
value
(
compId
)
->
value
(
paramName
).
toInt
(
&
ok
);
if
(
ok
&&
val
==
0
)
{
emit
misconfigurationDetected
(
this
);
qDebug
()
<<
"HINTING MISCONFIGURATION"
;
}
qDebug
()
<<
"SYS_AUTOSTART FOUND WITH VAL: "
<<
val
;
}
}
src/uas/QGXPX4UAS.h
deleted
100644 → 0
View file @
65e79da4
#ifndef QGXPX4UAS_H
#define QGXPX4UAS_H
#include
"UAS.h"
class
QGXPX4UAS
:
public
UAS
{
Q_OBJECT
Q_INTERFACES
(
UASInterface
)
public:
QGXPX4UAS
(
MAVLinkProtocol
*
mavlink
,
int
id
);
public
slots
:
/** @brief Receive a MAVLink message from this MAV */
void
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
);
virtual
void
processParamValueMsgHook
(
mavlink_message_t
&
msg
,
const
QString
&
paramName
,
const
mavlink_param_value_t
&
rawValue
,
mavlink_param_union_t
&
paramValue
);
};
#endif // QGXPX4UAS_H
src/uas/UAS.cc
View file @
96f44416
...
...
@@ -1029,8 +1029,6 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
paramVal
.
type
=
rawValue
.
param_type
;
processParamValueMsg
(
message
,
parameterName
,
rawValue
,
paramVal
);
processParamValueMsgHook
(
message
,
parameterName
,
rawValue
,
paramVal
);
}
break
;
case
MAVLINK_MSG_ID_COMMAND_ACK
:
...
...
src/uas/UAS.h
View file @
96f44416
...
...
@@ -930,7 +930,6 @@ protected:
quint64
getUnixReferenceTime
(
quint64
time
);
virtual
void
processParamValueMsg
(
mavlink_message_t
&
msg
,
const
QString
&
paramName
,
const
mavlink_param_value_t
&
rawValue
,
mavlink_param_union_t
&
paramValue
);
virtual
void
processParamValueMsgHook
(
mavlink_message_t
&
msg
,
const
QString
&
paramName
,
const
mavlink_param_value_t
&
rawValue
,
mavlink_param_union_t
&
paramValue
)
{
Q_UNUSED
(
msg
);
Q_UNUSED
(
paramName
);
Q_UNUSED
(
rawValue
);
Q_UNUSED
(
paramValue
);
};
int
componentID
[
256
];
bool
componentMulti
[
256
];
...
...
src/ui/px4_configuration/PX4RCCalibration.cc
View file @
96f44416
...
...
@@ -31,6 +31,8 @@
#include
"UASManager.h"
#include
"QGCMessageBox.h"
QGC_LOGGING_CATEGORY
(
PX4RCCalibrationLog
,
"PX4RCCalibrationLog"
)
const
int
PX4RCCalibration
::
_updateInterval
=
150
;
///< Interval for timer which updates radio channel widgets
const
int
PX4RCCalibration
::
_rcCalPWMCenterPoint
=
((
PX4RCCalibration
::
_rcCalPWMValidMaxValue
-
PX4RCCalibration
::
_rcCalPWMValidMinValue
)
/
2.0
f
)
+
PX4RCCalibration
::
_rcCalPWMValidMinValue
;
// FIXME: Double check these mins againt 150% throws
...
...
@@ -262,7 +264,7 @@ void PX4RCCalibration::_remoteControlChannelRawChanged(int chan, float fval)
// We always update raw values
_rcRawValue
[
chan
]
=
fval
;
//
qDebug() << "Raw value" << chan << fval;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"Raw value"
<<
chan
<<
fval
;
if
(
_currentStep
==
-
1
)
{
// Track the receiver channel count by keeping track of how many channels we see
...
...
@@ -330,7 +332,7 @@ void PX4RCCalibration::_saveAllTrims(void)
// trims reset to correct values.
for
(
int
i
=
0
;
i
<
_chanCount
;
i
++
)
{
//
qDebug() << "_saveAllTrims trim" << _rcRawValue[i];
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_saveAllTrims trim"
<<
_rcRawValue
[
i
];
_rgChannelInfo
[
i
].
rcTrim
=
_rcRawValue
[
i
];
}
_nextStep
();
...
...
@@ -355,7 +357,7 @@ bool PX4RCCalibration::_stickSettleComplete(int value)
if
(
abs
(
_stickDetectValue
-
value
)
>
_rcCalSettleDelta
)
{
// Stick is moving too much to consider stopped
//
qDebug() << "_stickSettleComplete still moving, _stickDetectValue:value" << _stickDetectValue << value;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_stickSettleComplete still moving, _stickDetectValue:value"
<<
_stickDetectValue
<<
value
;
_stickDetectValue
=
value
;
_stickDetectSettleStarted
=
false
;
...
...
@@ -372,7 +374,7 @@ bool PX4RCCalibration::_stickSettleComplete(int value)
}
else
{
// Start waiting for the stick to stay settled for _stickDetectSettleWaitMSecs msecs
//
qDebug() << "_stickSettleComplete starting settle timer, _stickDetectValue:value" << _stickDetectValue << value;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_stickSettleComplete starting settle timer, _stickDetectValue:value"
<<
_stickDetectValue
<<
value
;
_stickDetectSettleStarted
=
true
;
_stickDetectSettleElapsed
.
start
();
...
...
@@ -384,7 +386,7 @@ bool PX4RCCalibration::_stickSettleComplete(int value)
void
PX4RCCalibration
::
_inputStickDetect
(
enum
rcCalFunctions
function
,
int
channel
,
int
value
)
{
//
qDebug() << "_inputStickDetect function:channel:value" <<
function
<< channel << value;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_inputStickDetect function:channel:value"
<<
_rgFunctionInfo
[
function
].
parameterName
<<
channel
<<
value
;
// If this channel is already used in a mapping we can't use it again
if
(
_rgChannelInfo
[
channel
].
function
!=
rcCalFunctionMax
)
{
...
...
@@ -397,7 +399,7 @@ void PX4RCCalibration::_inputStickDetect(enum rcCalFunctions function, int chann
if
(
abs
(
_rcValueSave
[
channel
]
-
value
)
>
_rcCalMoveDelta
)
{
// Stick has moved far enough to consider it as being selected for the function
//
qDebug() << "_inputStickDetect starting settle wait, function:channel:value" << function << channel << value;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_inputStickDetect starting settle wait, function:channel:value"
<<
function
<<
channel
<<
value
;
// Setup up to detect stick being pegged to min or max value
_stickDetectChannel
=
channel
;
...
...
@@ -408,7 +410,7 @@ void PX4RCCalibration::_inputStickDetect(enum rcCalFunctions function, int chann
if
(
_stickSettleComplete
(
value
))
{
ChannelInfo
*
info
=
&
_rgChannelInfo
[
channel
];
//
qDebug() << "_inputStickDetect settle complete, function:channel:value" << function << channel << value;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_inputStickDetect settle complete, function:channel:value"
<<
function
<<
channel
<<
value
;
// Stick detection is complete. Stick should be at max position.
// Map the channel to the function
...
...
@@ -515,7 +517,7 @@ void PX4RCCalibration::_inputSwitchMinMax(enum rcCalFunctions function, int chan
if
(
value
<
_rcCalPWMCenterPoint
)
{
int
minValue
=
qMin
(
_rgChannelInfo
[
channel
].
rcMin
,
value
);
//
qDebug() << "_inputSwitchMinMax setting min channel:min" << channel << minValue;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_inputSwitchMinMax setting min channel:min"
<<
channel
<<
minValue
;
_rgChannelInfo
[
channel
].
rcMin
=
minValue
;
_rgRCValueMonitorWidget
[
channel
]
->
setMin
(
minValue
);
...
...
@@ -523,7 +525,7 @@ void PX4RCCalibration::_inputSwitchMinMax(enum rcCalFunctions function, int chan
}
else
{
int
maxValue
=
qMax
(
_rgChannelInfo
[
channel
].
rcMax
,
value
);
//
qDebug() << "_inputSwitchMinMax setting max channel:max" << channel << maxValue;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_inputSwitchMinMax setting max channel:max"
<<
channel
<<
maxValue
;
_rgChannelInfo
[
channel
].
rcMax
=
maxValue
;
_rgRCValueMonitorWidget
[
channel
]
->
setMax
(
maxValue
);
...
...
@@ -651,7 +653,7 @@ void PX4RCCalibration::_switchDetect(enum rcCalFunctions function, int channel,
_rgFunctionChannelMapping
[
function
]
=
channel
;
info
->
function
=
function
;
//
qDebug() << "Function:" << function << "mapped to:" << channel;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"Function:"
<<
function
<<
"mapped to:"
<<
channel
;
if
(
moveToNextStep
)
{
_nextStep
();
...
...
@@ -682,7 +684,7 @@ void PX4RCCalibration::_resetInternalCalibrationValues(void)
info
->
rcTrim
=
PX4RCCalibration
::
_rcCalPWMCenterPoint
;
}
// Initialize function mapping to function channel not set
// Initialize
attitude
function mapping to function channel not set
for
(
size_t
i
=
0
;
i
<
rcCalFunctionMax
;
i
++
)
{
_rgFunctionChannelMapping
[
i
]
=
_chanMax
;
}
...
...
@@ -709,16 +711,17 @@ void PX4RCCalibration::_resetInternalCalibrationValues(void)
Q_UNUSED
(
paramFound
);
bool
ok
;
int
c
hannel
=
value
.
toInt
(
&
ok
);
int
switchC
hannel
=
value
.
toInt
(
&
ok
);
Q_ASSERT
(
ok
);
Q_UNUSED
(
ok
);
// Parameter: 1-based channel, 0=not mapped
// _rgFunctionChannelMapping: 0-based channel, _chanMax=not mapped
_rgFunctionChannelMapping
[
curFunction
]
=
(
channel
==
0
)
?
_chanMax
:
channel
;
if
(
channel
!=
0
)
{
_rgChannelInfo
[
channel
-
1
].
function
=
curFunction
;
if
(
switchChannel
!=
0
)
{
qCDebug
(
PX4RCCalibrationLog
)
<<
"Reserving 0-based switch channel"
<<
switchChannel
-
1
;
_rgFunctionChannelMapping
[
curFunction
]
=
switchChannel
-
1
;
_rgChannelInfo
[
switchChannel
-
1
].
function
=
curFunction
;
}
}
}
...
...
@@ -848,7 +851,7 @@ void PX4RCCalibration::_validateCalibration(void)
// Validate Min/Max values. Although the channel appears as available we still may
// not have good min/max/trim values for it. Set to defaults if needed.
if
(
info
->
rcMin
>
_rcCalPWMValidMinValue
||
info
->
rcMax
<
_rcCalPWMValidMaxValue
)
{
//
qDebug() << "_validateCalibration resetting channel" << chan;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_validateCalibration resetting channel"
<<
chan
;
info
->
rcMin
=
_rcCalPWMDefaultMinValue
;
info
->
rcMax
=
_rcCalPWMDefaultMaxValue
;
info
->
rcTrim
=
info
->
rcMin
+
((
info
->
rcMax
-
info
->
rcMin
)
/
2
);
...
...
@@ -874,7 +877,7 @@ void PX4RCCalibration::_validateCalibration(void)
}
}
else
{
// Unavailable channels are set to defaults
//
qDebug() << "_validateCalibration resetting unavailable channel" << chan;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_validateCalibration resetting unavailable channel"
<<
chan
;
info
->
rcMin
=
_rcCalPWMDefaultMinValue
;
info
->
rcMax
=
_rcCalPWMDefaultMaxValue
;
info
->
rcTrim
=
info
->
rcMin
+
((
info
->
rcMax
-
info
->
rcMin
)
/
2
);
...
...
@@ -943,7 +946,7 @@ void PX4RCCalibration::_updateView()
valueWidget
->
setVisible
(
true
);
_rgRCValueMonitorLabel
[
chan
]
->
setVisible
(
true
);
//qDebug() << "Visible" << valueWidget->objectName() << chan;
//q
C
Debug(
PX4RCCalibrationLog
) << "Visible" << valueWidget->objectName() << chan;
struct
ChannelInfo
*
info
=
&
_rgChannelInfo
[
chan
];
valueWidget
->
setValueAndMinMax
(
_rcRawValue
[
chan
],
info
->
rcMin
,
info
->
rcMax
);
...
...
@@ -970,7 +973,7 @@ void PX4RCCalibration::_updateView()
for
(
int
chan
=
_chanCount
;
chan
<
_chanMax
;
chan
++
)
{
_rgRCValueMonitorWidget
[
chan
]
->
setVisible
(
false
);
_rgRCValueMonitorLabel
[
chan
]
->
setVisible
(
false
);
//
qDebug(
) << "Off
" << _rgRCValueMonitorWidget[chan]->objectName() << chan;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"Hiding channel
"
<<
_rgRCValueMonitorWidget
[
chan
]
->
objectName
()
<<
chan
;
}
}
...
...
@@ -1016,7 +1019,7 @@ void PX4RCCalibration::_stopCalibration(void)
/// @brief Saves the current channel values, so that we can detect when the use moves an input.
void
PX4RCCalibration
::
_rcCalSaveCurrentValues
(
void
)
{
//
qDebug() << "_rcCalSaveCurrentValues";
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_rcCalSaveCurrentValues"
;
for
(
unsigned
i
=
0
;
i
<
_chanMax
;
i
++
)
{
_rcValueSave
[
i
]
=
_rcRawValue
[
i
];
}
...
...
@@ -1136,7 +1139,7 @@ void PX4RCCalibration::_setHelpImage(const char* imageFile)
}
file
+=
imageFile
;
//
qDebug() << "_setHelpImage" << file;
q
C
Debug
(
PX4RCCalibrationLog
)
<<
"_setHelpImage"
<<
file
;
_ui
->
radioIcon
->
setPixmap
(
QPixmap
(
file
));
}
src/ui/px4_configuration/PX4RCCalibration.h
View file @
96f44416
...
...
@@ -34,9 +34,12 @@
#include
"UASInterface.h"
#include
"RCValueWidget.h"
#include
"QGCLoggingCategory.h"
#include
"ui_PX4RCCalibration.h"
Q_DECLARE_LOGGING_CATEGORY
(
PX4RCCalibrationLog
)
class
PX4RCCalibrationTest
;
namespace
Ui
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment