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
8b6aa1ed
Commit
8b6aa1ed
authored
Mar 01, 2015
by
Don Gagne
Browse files
Merge pull request #1293 from DonLakeFlyer/RadioCalTrigger
Update Radio Cal trigger
parents
677fff3e
10b60459
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/AutoPilotPlugins/PX4/AirframeComponent.cc
View file @
8b6aa1ed
...
...
@@ -27,9 +27,6 @@
#include
"AirframeComponent.h"
#include
"QGCPX4AirframeConfig.h"
/// @brief Parameters which signal a change in setupComplete state
static
const
char
*
triggerParams
[]
=
{
"SYS_AUTOSTART"
,
NULL
};
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
...
...
@@ -146,7 +143,7 @@ bool AirframeComponent::requiresSetup(void) const
bool
AirframeComponent
::
setupComplete
(
void
)
const
{
QVariant
value
;
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
triggerParams
[
0
]
,
value
))
{
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
"SYS_AUTOSTART"
,
value
))
{
return
value
.
toInt
()
!=
0
;
}
else
{
Q_ASSERT
(
false
);
...
...
@@ -166,9 +163,9 @@ QString AirframeComponent::setupStateDescription(void) const
return
QString
(
stateDescription
);
}
const
char
**
AirframeComponent
::
setupCompleteChangedTriggerList
(
void
)
const
QStringList
AirframeComponent
::
setupCompleteChangedTriggerList
(
void
)
const
{
return
tri
ggerParams
;
return
QS
tri
ngList
(
"SYS_AUTOSTART"
)
;
}
QStringList
AirframeComponent
::
paramFilterList
(
void
)
const
...
...
src/AutoPilotPlugins/PX4/AirframeComponent.h
View file @
8b6aa1ed
...
...
@@ -38,7 +38,7 @@ public:
AirframeComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
// Virtuals from PX4Component
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
;
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
;
// Virtuals from VehicleComponent
virtual
QString
name
(
void
)
const
;
...
...
src/AutoPilotPlugins/PX4/FlightModesComponent.cc
View file @
8b6aa1ed
...
...
@@ -28,9 +28,6 @@
#include
"FlightModeConfig.h"
#include
"PX4AutoPilotPlugin.h"
/// @brief Parameters which signal a change in setupComplete state
static
const
char
*
triggerParams
[]
=
{
"RC_MAP_MODE_SW"
,
NULL
};
struct
SwitchListItem
{
const
char
*
param
;
const
char
*
name
;
...
...
@@ -76,7 +73,7 @@ bool FlightModesComponent::requiresSetup(void) const
bool
FlightModesComponent
::
setupComplete
(
void
)
const
{
QVariant
value
;
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
triggerParams
[
0
]
,
value
))
{
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
"RC_MAP_MODE_SW"
,
value
))
{
return
value
.
toInt
()
!=
0
;
}
else
{
Q_ASSERT
(
false
);
...
...
@@ -96,9 +93,9 @@ QString FlightModesComponent::setupStateDescription(void) const
return
QString
(
stateDescription
);
}
const
char
**
FlightModesComponent
::
setupCompleteChangedTriggerList
(
void
)
const
QStringList
FlightModesComponent
::
setupCompleteChangedTriggerList
(
void
)
const
{
return
tri
ggerParams
;
return
QS
tri
ngList
(
"RC_MAP_MODE_SW"
)
;
}
QStringList
FlightModesComponent
::
paramFilterList
(
void
)
const
...
...
src/AutoPilotPlugins/PX4/FlightModesComponent.h
View file @
8b6aa1ed
...
...
@@ -38,7 +38,7 @@ public:
FlightModesComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
// Virtuals from PX4Component
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
;
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
;
// Virtuals from VehicleComponent
virtual
QString
name
(
void
)
const
;
...
...
src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml
View file @
8b6aa1ed
...
...
@@ -27,7 +27,7 @@ Column {
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
posctl
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_POSCTL_SW
"
].
value
==
0
?
"
Not mapp
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_POSCTL_SW
"
].
value
text
:
autopilot
.
parameters
[
"
RC_MAP_POSCTL_SW
"
].
value
==
0
?
"
Disabl
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_POSCTL_SW
"
].
value
}
}
...
...
@@ -38,7 +38,7 @@ Column {
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
loiter
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_LOITER_SW
"
].
value
==
0
?
"
Not mapp
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_LOITER_SW
"
].
value
text
:
autopilot
.
parameters
[
"
RC_MAP_LOITER_SW
"
].
value
==
0
?
"
Disabl
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_LOITER_SW
"
].
value
}
}
...
...
@@ -49,7 +49,7 @@ Column {
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
rtl
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_RETURN_SW
"
].
value
==
0
?
"
Not mapp
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_RETURN_SW
"
].
value
text
:
autopilot
.
parameters
[
"
RC_MAP_RETURN_SW
"
].
value
==
0
?
"
Disabl
ed
"
:
autopilot
.
parameters
[
"
RC_MAP_RETURN_SW
"
].
value
}
}
}
src/AutoPilotPlugins/PX4/PX4Component.cc
View file @
8b6aa1ed
...
...
@@ -39,15 +39,12 @@ void PX4Component::_parameterUpdated(int compId, QString paramName, QVariant val
Q_UNUSED
(
value
);
if
(
compId
==
_paramMgr
->
getDefaultComponentId
())
{
const
char
**
prgTriggers
=
setupCompleteChangedTriggerList
();
Q_ASSERT
(
prgTriggers
);
while
(
*
prgTriggers
!=
NULL
)
{
if
(
paramName
==
*
prgTriggers
)
{
QStringList
triggerList
=
setupCompleteChangedTriggerList
();
foreach
(
QString
triggerParam
,
triggerList
)
{
if
(
paramName
==
triggerParam
)
{
emit
setupCompleteChanged
(
setupComplete
());
return
;
}
prgTriggers
++
;
}
}
}
src/AutoPilotPlugins/PX4/PX4Component.h
View file @
8b6aa1ed
...
...
@@ -26,6 +26,8 @@
#include
"VehicleComponent.h"
#include
<QStringList>
/// @file
/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
...
...
@@ -37,9 +39,9 @@ class PX4Component : public VehicleComponent
public:
PX4Component
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
/// @brief Returns an
array
of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL.
Must be implemented by upper level class.
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
=
0
;
/// @brief Returns an
list
of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL.
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
=
0
;
private
slots
:
/// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal
...
...
src/AutoPilotPlugins/PX4/RadioComponent.cc
View file @
8b6aa1ed
...
...
@@ -28,9 +28,6 @@
#include
"PX4RCCalibration.h"
#include
"PX4AutoPilotPlugin.h"
/// @brief Parameters which signal a change in setupComplete state
static
const
char
*
triggerParams
[]
=
{
"RC_MAP_ROLL"
,
"RC_MAP_PITCH"
,
"RC_MAP_YAW"
,
"RC_MAP_THROTTLE"
,
NULL
};
RadioComponent
::
RadioComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
)
:
PX4Component
(
uas
,
autopilot
,
parent
),
_name
(
tr
(
"Radio"
))
...
...
@@ -61,9 +58,12 @@ bool RadioComponent::requiresSetup(void) const
bool
RadioComponent
::
setupComplete
(
void
)
const
{
for
(
size_t
i
=
0
;
triggerParams
[
i
]
!=
NULL
;
i
++
)
{
// Check for mapped attitude controls
QStringList
attitudeMappings
;
attitudeMappings
<<
"RC_MAP_ROLL"
<<
"RC_MAP_PITCH"
<<
"RC_MAP_YAW"
<<
"RC_MAP_THROTTLE"
;
foreach
(
QString
mapParam
,
attitudeMappings
)
{
QVariant
value
;
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
trigger
Param
s
[
0
]
,
value
))
{
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
map
Param
,
value
))
{
if
(
value
.
toInt
()
==
0
)
{
return
false
;
}
...
...
@@ -73,6 +73,47 @@ bool RadioComponent::setupComplete(void) const
}
}
// Check for min/max/trim defaults for channel 1-4
static
const
int
rcMinDefault
=
1000
;
static
const
int
rcMaxDefault
=
2000
;
static
const
int
rcTrimDefault
=
1500
;
for
(
int
i
=
1
;
i
<
5
;
i
++
)
{
QVariant
value
;
int
rcMin
,
rcMax
,
rcTrim
;
QString
param
;
param
=
QString
(
"RC%1_MIN"
).
arg
(
i
);
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
param
,
value
))
{
rcMin
=
value
.
toInt
();
}
else
{
Q_ASSERT
(
false
);
return
false
;
}
param
=
QString
(
"RC%1_MAX"
).
arg
(
i
);
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
param
,
value
))
{
rcMax
=
value
.
toInt
();
}
else
{
Q_ASSERT
(
false
);
return
false
;
}
param
=
QString
(
"RC%1_TRIM"
).
arg
(
i
);
if
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
param
,
value
))
{
rcTrim
=
value
.
toInt
();
}
else
{
Q_ASSERT
(
false
);
return
false
;
}
if
(
rcMin
==
rcMinDefault
&&
rcMax
==
rcMaxDefault
&&
rcTrim
==
rcTrimDefault
)
{
return
false
;
}
}
return
true
;
}
...
...
@@ -88,9 +129,25 @@ QString RadioComponent::setupStateDescription(void) const
return
QString
(
stateDescription
);
}
const
char
**
RadioComponent
::
setupCompleteChangedTriggerList
(
void
)
const
QStringList
RadioComponent
::
setupCompleteChangedTriggerList
(
void
)
const
{
return
triggerParams
;
QStringList
triggers
;
// The best we can do to detect the need for a radio calibration is look for trim/min/max still being
// at defaults. We also look for attitude controls to be mapped. But since they default to channels
// they are not a very reliable source.
// Attitude control mapping is always a trigger
triggers
<<
"RC_MAP_ROLL"
<<
"RC_MAP_PITCH"
<<
"RC_MAP_YAW"
<<
"RC_MAP_THROTTLE"
;
// We also trigger on min/max/trim for channels 1-4 which would normally be the attitude
// control channels. This may not always be the case, but it's the best we can
triggers
<<
"RC1_MIN"
<<
"RC1_MAX"
<<
"RC1_TRIM"
;
triggers
<<
"RC2_MIN"
<<
"RC2_MAX"
<<
"RC2_TRIM"
;
triggers
<<
"RC3_MIN"
<<
"RC3_MAX"
<<
"RC3_TRIM"
;
triggers
<<
"RC4_MIN"
<<
"RC4_MAX"
<<
"RC4_TRIM"
;
return
triggers
;
}
QStringList
RadioComponent
::
paramFilterList
(
void
)
const
...
...
src/AutoPilotPlugins/PX4/RadioComponent.h
View file @
8b6aa1ed
...
...
@@ -39,7 +39,7 @@ public:
RadioComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
// Virtuals from PX4Component
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
;
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
;
// Virtuals from VehicleComponent
virtual
QString
name
(
void
)
const
;
...
...
src/AutoPilotPlugins/PX4/RadioComponentSummary.qml
View file @
8b6aa1ed
...
...
@@ -56,11 +56,33 @@ Column {
Row
{
width
:
parent
.
width
QGCLabel
{
id
:
mode
;
text
:
"
Mode switch
:
"
}
QGCLabel
{
id
:
flaps
;
text
:
"
Flaps
:
"
}
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
mode
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_MODE_SW
"
].
value
==
0
?
"
Setup required
"
:
autopilot
.
parameters
[
"
RC_MAP_MODE_SW
"
].
value
width
:
parent
.
width
-
flaps
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_FLAPS
"
].
value
==
0
?
"
Disabled
"
:
autopilot
.
parameters
[
"
RC_MAP_FLAPS
"
].
value
}
}
Row
{
width
:
parent
.
width
QGCLabel
{
id
:
aux1
;
text
:
"
Aux1:
"
}
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
aux1
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_AUX1
"
].
value
==
0
?
"
Disabled
"
:
autopilot
.
parameters
[
"
RC_MAP_AUX1
"
].
value
}
}
Row
{
width
:
parent
.
width
QGCLabel
{
id
:
aux2
;
text
:
"
Aux2:
"
}
QGCLabel
{
horizontalAlignment
:
Text
.
AlignRight
width
:
parent
.
width
-
aux2
.
contentWidth
text
:
autopilot
.
parameters
[
"
RC_MAP_AUX2
"
].
value
==
0
?
"
Disabled
"
:
autopilot
.
parameters
[
"
RC_MAP_AUX2
"
].
value
}
}
}
src/AutoPilotPlugins/PX4/SafetyComponent.cc
View file @
8b6aa1ed
...
...
@@ -29,9 +29,6 @@
#include
"QGCQmlWidgetHolder.h"
#include
"PX4AutoPilotPlugin.h"
/// @brief Parameters which signal a change in setupComplete state
static
const
char
*
triggerParams
[]
=
{
NULL
};
SafetyComponent
::
SafetyComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
)
:
PX4Component
(
uas
,
autopilot
,
parent
),
_name
(
tr
(
"Safety"
))
...
...
@@ -76,9 +73,9 @@ QString SafetyComponent::setupStateDescription(void) const
return
QString
(
stateDescription
);
}
const
char
**
SafetyComponent
::
setupCompleteChangedTriggerList
(
void
)
const
QStringList
SafetyComponent
::
setupCompleteChangedTriggerList
(
void
)
const
{
return
tri
ggerParams
;
return
QS
tri
ngList
()
;
}
QStringList
SafetyComponent
::
paramFilterList
(
void
)
const
...
...
src/AutoPilotPlugins/PX4/SafetyComponent.h
View file @
8b6aa1ed
...
...
@@ -39,7 +39,7 @@ public:
SafetyComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
// Virtuals from PX4Component
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
;
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
;
// Virtuals from VehicleComponent
virtual
QString
name
(
void
)
const
;
...
...
src/AutoPilotPlugins/PX4/SensorsComponent.cc
View file @
8b6aa1ed
...
...
@@ -31,10 +31,6 @@
// These two list must be kept in sync
/// @brief Parameters which signal a change in setupComplete state
static
const
char
*
triggerParams
[]
=
{
"CAL_MAG0_ID"
,
"CAL_GYRO0_ID"
,
"CAL_ACC0_ID"
,
NULL
};
static
const
char
*
triggerParamsFixedWing
[]
=
{
"CAL_MAG0_ID"
,
"CAL_GYRO0_ID"
,
"CAL_ACC0_ID"
,
"SENS_DPRES_OFF"
,
NULL
};
SensorsComponent
::
SensorsComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
)
:
PX4Component
(
uas
,
autopilot
,
parent
),
_name
(
tr
(
"Sensors"
))
...
...
@@ -65,13 +61,10 @@ bool SensorsComponent::requiresSetup(void) const
bool
SensorsComponent
::
setupComplete
(
void
)
const
{
const
char
**
prgTriggers
=
setupCompleteChangedTriggerList
();
Q_ASSERT
(
prgTriggers
);
while
(
*
prgTriggers
!=
NULL
)
{
foreach
(
QString
triggerParam
,
setupCompleteChangedTriggerList
())
{
QVariant
value
;
if
(
!
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
*
prgT
rigger
s
,
value
))
{
if
(
!
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
t
rigger
Param
,
value
))
{
Q_ASSERT
(
false
);
return
false
;
}
...
...
@@ -79,8 +72,6 @@ bool SensorsComponent::setupComplete(void) const
if
(
value
.
toFloat
()
==
0.0
f
)
{
return
false
;
}
prgTriggers
++
;
}
return
true
;
...
...
@@ -98,9 +89,16 @@ QString SensorsComponent::setupStateDescription(void) const
return
QString
(
stateDescription
);
}
const
char
**
SensorsComponent
::
setupCompleteChangedTriggerList
(
void
)
const
QStringList
SensorsComponent
::
setupCompleteChangedTriggerList
(
void
)
const
{
return
_uas
->
getSystemType
()
==
MAV_TYPE_FIXED_WING
?
triggerParamsFixedWing
:
triggerParams
;
QStringList
triggers
;
triggers
<<
"CAL_MAG0_ID"
<<
"CAL_GYRO0_ID"
<<
"CAL_ACC0_ID"
;
if
(
_uas
->
getSystemType
()
==
MAV_TYPE_FIXED_WING
)
{
triggers
<<
"SENS_DPRES_OFF"
;
}
return
triggers
;
}
QStringList
SensorsComponent
::
paramFilterList
(
void
)
const
...
...
src/AutoPilotPlugins/PX4/SensorsComponent.h
View file @
8b6aa1ed
...
...
@@ -38,7 +38,7 @@ public:
SensorsComponent
(
UASInterface
*
uas
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
=
NULL
);
// Virtuals from PX4Component
virtual
const
char
**
setupCompleteChangedTriggerList
(
void
)
const
;
virtual
QStringList
setupCompleteChangedTriggerList
(
void
)
const
;
// Virtuals from VehicleComponent
virtual
QString
name
(
void
)
const
;
...
...
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