Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
e675a324
Commit
e675a324
authored
Apr 28, 2019
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
8a564962
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
82 deletions
+131
-82
APMAirframeComponent.cc
src/AutoPilotPlugins/APM/APMAirframeComponent.cc
+15
-25
APMAirframeComponent.h
src/AutoPilotPlugins/APM/APMAirframeComponent.h
+2
-4
APMAirframeComponent.qml
src/AutoPilotPlugins/APM/APMAirframeComponent.qml
+10
-7
APMAirframeComponentController.cc
src/AutoPilotPlugins/APM/APMAirframeComponentController.cc
+97
-31
APMAirframeComponentController.h
src/AutoPilotPlugins/APM/APMAirframeComponentController.h
+2
-1
APMAirframeComponentSummary.qml
src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml
+4
-13
FactPanelController.cc
src/FactSystem/FactControls/FactPanelController.cc
+1
-1
No files found.
src/AutoPilotPlugins/APM/APMAirframeComponent.cc
View file @
e675a324
...
...
@@ -11,28 +11,22 @@
#include "ArduCopterFirmwarePlugin.h"
#include "ParameterManager.h"
const
char
*
APMAirframeComponent
::
_oldFrameParam
=
"FRAME"
;
const
char
*
APMAirframeComponent
::
_newFrameParam
=
"FRAME_CLASS"
;
const
char
*
APMAirframeComponent
::
_frameClassParam
=
"FRAME_CLASS"
;
APMAirframeComponent
::
APMAirframeComponent
(
Vehicle
*
vehicle
,
AutoPilotPlugin
*
autopilot
,
QObject
*
parent
)
:
VehicleComponent
(
vehicle
,
autopilot
,
parent
)
,
_
requiresFrameSetup
(
false
)
,
_
name
(
tr
(
"Airframe"
)
)
:
VehicleComponent
(
vehicle
,
autopilot
,
parent
)
,
_
name
(
tr
(
"Frame"
)
)
,
_
requiresFrameSetup
(
false
)
{
if
(
qobject_cast
<
ArduCopterFirmwarePlugin
*>
(
_vehicle
->
firmwarePlugin
())
!=
NULL
)
{
ParameterManager
*
paramMgr
=
_vehicle
->
parameterManager
();
ParameterManager
*
paramMgr
=
vehicle
->
parameterManager
();
if
(
paramMgr
->
parameterExists
(
FactSystem
::
defaultComponentId
,
_frameClassParam
))
{
_frameClassFact
=
paramMgr
->
getParameter
(
FactSystem
::
defaultComponentId
,
_frameClassParam
);
if
(
vehicle
->
vehicleType
()
!=
MAV_TYPE_HELICOPTER
)
{
_requiresFrameSetup
=
true
;
if
(
paramMgr
->
parameterExists
(
FactSystem
::
defaultComponentId
,
_oldFrameParam
))
{
_useNewFrameParam
=
false
;
_frameParamFact
=
paramMgr
->
getParameter
(
FactSystem
::
defaultComponentId
,
_oldFrameParam
);
MAV_TYPE
vehicleType
=
vehicle
->
vehicleType
();
if
(
vehicleType
==
MAV_TYPE_TRICOPTER
||
vehicleType
==
MAV_TYPE_HELICOPTER
)
{
_requiresFrameSetup
=
false
;
}
}
else
{
_useNewFrameParam
=
true
;
_frameParamFact
=
paramMgr
->
getParameter
(
FactSystem
::
defaultComponentId
,
_newFrameParam
);
}
_frameClassFact
=
nullptr
;
}
}
...
...
@@ -43,7 +37,7 @@ QString APMAirframeComponent::name(void) const
QString
APMAirframeComponent
::
description
(
void
)
const
{
return
tr
(
"
Airf
rame Setup is used to select the airframe which matches your vehicle."
);
return
tr
(
"
F
rame Setup is used to select the airframe which matches your vehicle."
);
}
QString
APMAirframeComponent
::
iconResource
(
void
)
const
...
...
@@ -59,11 +53,7 @@ bool APMAirframeComponent::requiresSetup(void) const
bool
APMAirframeComponent
::
setupComplete
(
void
)
const
{
if
(
_requiresFrameSetup
)
{
if
(
_useNewFrameParam
)
{
return
_frameParamFact
->
rawValue
().
toInt
()
>
0
;
}
else
{
return
_frameParamFact
->
rawValue
().
toInt
()
>=
0
;
}
return
_frameClassFact
->
rawValue
().
toInt
()
!=
0
;
}
else
{
return
true
;
}
...
...
@@ -74,7 +64,7 @@ QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const
QStringList
list
;
if
(
_requiresFrameSetup
)
{
list
<<
(
_useNewFrameParam
?
_newFrameParam
:
_oldFrameParam
)
;
list
<<
_frameClassParam
;
}
return
list
;
...
...
src/AutoPilotPlugins/APM/APMAirframeComponent.h
View file @
e675a324
...
...
@@ -35,11 +35,9 @@ public:
private:
bool
_requiresFrameSetup
;
///< true: FRAME parameter must be set
const
QString
_name
;
Fact
*
_frameParamFact
;
bool
_useNewFrameParam
;
Fact
*
_frameClassFact
;
static
const
char
*
_oldFrameParam
;
static
const
char
*
_newFrameParam
;
static
const
char
*
_frameClassParam
;
};
#endif
src/AutoPilotPlugins/APM/APMAirframeComponent.qml
View file @
e675a324
...
...
@@ -36,7 +36,8 @@ SetupPage {
property
real
_boxSpace
:
ScreenTools
.
defaultFontPixelWidth
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
property
Fact
_frameClass
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_CLASS
"
)
property
Fact
_frameType
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_TYPE
"
)
property
Fact
_frameType
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_TYPE
"
,
false
)
// FRAME_TYPE is not available on all Rover versions
property
bool
_frameTypeAvailable
:
controller
.
parameterExists
(
-
1
,
"
FRAME_TYPE
"
)
readonly
property
real
spacerHeight
:
ScreenTools
.
defaultFontPixelHeight
...
...
@@ -71,7 +72,9 @@ SetupPage {
Layout.fillWidth
:
true
text
:
(
_frameClass
.
rawValue
===
0
?
qsTr
(
"
Airframe is currently not set.
"
)
:
qsTr
(
"
Currently set to frame class '%1' and frame type '%2'.
"
).
arg
(
_frameClass
.
enumStringValue
).
arg
(
_frameType
.
enumStringValue
))
+
qsTr
(
"
Currently set to frame class '%1'
"
).
arg
(
_frameClass
.
enumStringValue
)
+
(
_frameTypeAvailable
?
qsTr
(
"
and frame type '%2'
"
).
arg
(
_frameType
.
enumStringValue
)
:
""
)
+
qsTr
(
"
.
"
,
"
period for end of sentence
"
))
+
qsTr
(
"
To change this configuration, select the desired frame class below and frame type.
"
)
font.family
:
ScreenTools
.
demiboldFontFamily
wrapMode
:
Text
.
WordWrap
...
...
src/AutoPilotPlugins/APM/APMAirframeComponentController.cc
View file @
e675a324
...
...
@@ -13,6 +13,8 @@
#include "QGCApplication.h"
#include "QGCFileDownload.h"
#include "ParameterManager.h"
#include "ArduCopterFirmwarePlugin.h"
#include "ArduRoverFirmwarePlugin.h"
#include <QVariant>
#include <QQmlProperty>
...
...
@@ -21,8 +23,7 @@
#include <QJsonParseError>
#include <QJsonObject>
// These should match the FRAME_CLASS parameter enum meta data
// These should match the ArduCopter FRAME_CLASS parameter enum meta data
#define FRAME_CLASS_UNDEFINED 0
#define FRAME_CLASS_QUAD 1
#define FRAME_CLASS_HEX 2
...
...
@@ -38,7 +39,7 @@
#define FRAME_CLASS_DODECAHEXA 12
#define FRAME_CLASS_HELIQUAD 13
// These should match the FRAME_TYPE parameter enum meta data
// These should match the
ArduCopter
FRAME_TYPE parameter enum meta data
#define FRAME_TYPE_PLUS 0
#define FRAME_TYPE_X 1
#define FRAME_TYPE_V 2
...
...
@@ -51,13 +52,24 @@
#define FRAME_TYPE_DJIX 13
#define FRAME_TYPE_CLOCKWISEX 14
// These should match the Rover FRAME_CLASS parameter enum meta data
#define FRAME_CLASS_ROVER 1
#define FRAME_CLASS_BOAT 2
#define FRAME_CLASS_BALANCEBOT 3
// These should match the Rover FRAME_TYPE parameter enum meta data
#define FRAME_TYPE_UNDEFINED 0
#define FRAME_TYPE_OMNI3 1
#define FRAME_TYPE_OMNIX 2
#define FRAME_TYPE_OMNIPLUS 3
typedef
struct
{
int
frameClass
;
int
frameType
;
const
char
*
imageResource
;
}
FrameToImageInfo_t
;
static
const
FrameToImageInfo_t
s_rgFrameToImage
[]
=
{
static
const
FrameToImageInfo_t
s_rgFrameToImage
Copter
[]
=
{
{
FRAME_CLASS_QUAD
,
FRAME_TYPE_PLUS
,
"QuadRotorPlus"
},
{
FRAME_CLASS_QUAD
,
FRAME_TYPE_X
,
"QuadRotorX"
},
{
FRAME_CLASS_QUAD
,
FRAME_TYPE_V
,
"QuadRotorWide"
},
...
...
@@ -77,10 +89,15 @@ static const FrameToImageInfo_t s_rgFrameToImage[] = {
{
FRAME_CLASS_TRI
,
-
1
,
"YPlus"
},
};
static
QString
s_findImageResource
(
int
frameClass
,
int
frameType
)
static
const
FrameToImageInfo_t
s_rgFrameToImageRover
[]
=
{
{
FRAME_CLASS_ROVER
,
-
1
,
"Rover"
},
{
FRAME_CLASS_BOAT
,
-
1
,
"Boat"
},
};
static
QString
s_findImageResourceCopter
(
int
frameClass
,
int
frameType
)
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
s_rgFrameToImage
)
/
sizeof
(
s_rgFrameToImage
[
0
]);
i
++
)
{
const
FrameToImageInfo_t
*
pFrameToImageInfo
=
&
s_rgFrameToImage
[
i
];
for
(
size_t
i
=
0
;
i
<
sizeof
(
s_rgFrameToImage
Copter
)
/
sizeof
(
s_rgFrameToImageCopter
[
0
]);
i
++
)
{
const
FrameToImageInfo_t
*
pFrameToImageInfo
=
&
s_rgFrameToImage
Copter
[
i
];
if
(
pFrameToImageInfo
->
frameClass
==
frameClass
&&
pFrameToImageInfo
->
frameType
==
frameType
)
{
return
pFrameToImageInfo
->
imageResource
;
...
...
@@ -92,9 +109,24 @@ static QString s_findImageResource(int frameClass, int frameType)
return
QStringLiteral
(
"AirframeUnknown"
);
}
static
QString
s_findImageResourceRover
(
int
frameClass
,
int
frameType
)
{
Q_UNUSED
(
frameType
);
for
(
size_t
i
=
0
;
i
<
sizeof
(
s_rgFrameToImageRover
)
/
sizeof
(
s_rgFrameToImageRover
[
0
]);
i
++
)
{
const
FrameToImageInfo_t
*
pFrameToImageInfo
=
&
s_rgFrameToImageRover
[
i
];
if
(
pFrameToImageInfo
->
frameClass
==
frameClass
)
{
return
pFrameToImageInfo
->
imageResource
;
}
}
return
QStringLiteral
(
"AirframeUnknown"
);
}
APMAirframeComponentController
::
APMAirframeComponentController
(
void
)
:
_frameClassFact
(
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FRAME_CLASS"
)))
,
_frameTypeFact
(
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FRAME_TYPE"
)))
,
_frameTypeFact
(
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FRAME_TYPE"
)
,
false
/* reportMissing */
))
,
_frameClassModel
(
new
QmlObjectListModel
(
this
))
{
_fillFrameClasses
();
...
...
@@ -107,6 +139,9 @@ APMAirframeComponentController::~APMAirframeComponentController()
void
APMAirframeComponentController
::
_fillFrameClasses
()
{
FirmwarePlugin
*
fwPlugin
=
_vehicle
->
firmwarePlugin
();
if
(
qobject_cast
<
ArduCopterFirmwarePlugin
*>
(
fwPlugin
))
{
QList
<
int
>
frameTypeNotSupported
;
frameTypeNotSupported
<<
FRAME_CLASS_HELI
...
...
@@ -121,12 +156,31 @@ void APMAirframeComponentController::_fillFrameClasses()
int
frameClass
=
_frameClassFact
->
enumValues
()[
i
].
toInt
();
int
defaultFrameType
;
if
(
frameClass
==
FRAME_CLASS_HELI
)
{
// Heli requires it's own firmware variant. You can't switch to Heli from a Copter variant firmware.
continue
;
}
if
(
frameTypeNotSupported
.
contains
(
frameClass
))
{
defaultFrameType
=
-
1
;
}
else
{
defaultFrameType
=
FRAME_TYPE_X
;
}
_frameClassModel
->
append
(
new
APMFrameClass
(
frameClassName
,
frameClass
,
_frameTypeFact
,
defaultFrameType
,
_frameClassModel
));
_frameClassModel
->
append
(
new
APMFrameClass
(
frameClassName
,
true
/* copter */
,
frameClass
,
_frameTypeFact
,
defaultFrameType
,
_frameClassModel
));
}
}
else
if
(
qobject_cast
<
ArduRoverFirmwarePlugin
*>
(
fwPlugin
))
{
for
(
int
i
=
1
;
i
<
_frameClassFact
->
enumStrings
().
count
();
i
++
)
{
QString
frameClassName
=
_frameClassFact
->
enumStrings
()[
i
];
int
frameClass
=
_frameClassFact
->
enumValues
()[
i
].
toInt
();
int
defaultFrameType
;
if
(
_frameTypeFact
)
{
defaultFrameType
=
FRAME_TYPE_UNDEFINED
;
}
else
{
defaultFrameType
=
-
1
;
}
_frameClassModel
->
append
(
new
APMFrameClass
(
frameClassName
,
false
/* copter */
,
frameClass
,
_frameTypeFact
,
defaultFrameType
,
_frameClassModel
));
}
}
}
...
...
@@ -216,16 +270,19 @@ void APMAirframeComponentController::_paramFileDownloadError(QString errorMsg)
qgcApp
()
->
restoreOverrideCursor
();
}
APMFrameClass
::
APMFrameClass
(
const
QString
&
name
,
int
frameClass
,
Fact
*
frameTypeFact
,
int
defaultFrameType
,
QObject
*
parent
)
APMFrameClass
::
APMFrameClass
(
const
QString
&
name
,
bool
copter
,
int
frameClass
,
Fact
*
frameTypeFact
,
int
defaultFrameType
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_name
(
name
)
,
_copter
(
copter
)
,
_frameClass
(
frameClass
)
,
_defaultFrameType
(
defaultFrameType
)
,
_frameTypeSupported
(
defaultFrameType
!=
-
1
)
,
_frameTypeFact
(
frameTypeFact
)
{
if
(
frameTypeFact
)
{
connect
(
frameTypeFact
,
&
Fact
::
rawValueChanged
,
this
,
&
APMFrameClass
::
imageResourceChanged
);
connect
(
frameTypeFact
,
&
Fact
::
rawValueChanged
,
this
,
&
APMFrameClass
::
frameTypeChanged
);
}
}
APMFrameClass
::~
APMFrameClass
()
...
...
@@ -235,5 +292,14 @@ APMFrameClass::~APMFrameClass()
QString
APMFrameClass
::
imageResource
(
void
)
{
return
QStringLiteral
(
"/qmlimages/Airframe/%1"
).
arg
(
s_findImageResource
(
_frameClass
,
_frameTypeFact
->
rawValue
().
toInt
()));
QString
imageResource
;
int
frameType
=
_frameTypeFact
?
_frameTypeFact
->
rawValue
().
toInt
()
:
-
1
;
if
(
_copter
)
{
imageResource
=
s_findImageResourceCopter
(
_frameClass
,
frameType
);
}
else
{
imageResource
=
s_findImageResourceRover
(
_frameClass
,
frameType
);
}
return
QStringLiteral
(
"/qmlimages/Airframe/%1"
).
arg
(
imageResource
);
}
src/AutoPilotPlugins/APM/APMAirframeComponentController.h
View file @
e675a324
...
...
@@ -54,7 +54,7 @@ class APMFrameClass : public QObject
Q_OBJECT
public:
APMFrameClass
(
const
QString
&
name
,
int
frameClass
,
Fact
*
frameTypeFact
,
int
defaultFrameType
,
QObject
*
parent
=
nullptr
);
APMFrameClass
(
const
QString
&
name
,
bool
copter
,
int
frameClass
,
Fact
*
frameTypeFact
,
int
defaultFrameType
,
QObject
*
parent
=
nullptr
);
~
APMFrameClass
();
Q_PROPERTY
(
QString
name
MEMBER
_name
CONSTANT
)
...
...
@@ -68,6 +68,7 @@ public:
QString
imageResource
(
void
);
QString
_name
;
bool
_copter
;
QString
_imageResource
;
int
_frameClass
;
int
_defaultFrameType
;
...
...
src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml
View file @
e675a324
...
...
@@ -18,32 +18,23 @@ FactPanel {
factPanel
:
panel
}
property
bool
_frameAvailable
:
controller
.
parameterExists
(
-
1
,
"
FRAME
"
)
property
Fact
_frame
:
controller
.
getParameterFact
(
-
1
,
"
FRAME
"
,
false
)
property
Fact
_frameClass
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_CLASS
"
,
false
)
property
Fact
_frameClass
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_CLASS
"
)
property
Fact
_frameType
:
controller
.
getParameterFact
(
-
1
,
"
FRAME_TYPE
"
,
false
)
property
bool
_frameTypeAvailable
:
controller
.
parameterExists
(
-
1
,
"
FRAME_TYPE
"
)
Column
{
anchors.fill
:
parent
VehicleSummaryRow
{
labelText
:
qsTr
(
"
Frame Type
"
)
valueText
:
visible
?
controller
.
currentAirframeTypeName
()
+
"
"
+
_frame
.
enumStringValue
:
""
visible
:
_frameAvailable
}
VehicleSummaryRow
{
labelText
:
qsTr
(
"
Frame Class
"
)
valueText
:
visible
?
_frameClass
.
enumStringValue
:
""
visible
:
!
_frameAvailable
valueText
:
_frameClass
.
enumStringValue
}
VehicleSummaryRow
{
labelText
:
qsTr
(
"
Frame Type
"
)
valueText
:
visible
?
_frameType
.
enumStringValue
:
""
visible
:
!
_fram
eAvailable
visible
:
_frameTyp
eAvailable
}
VehicleSummaryRow
{
...
...
src/FactSystem/FactControls/FactPanelController.cc
View file @
e675a324
...
...
@@ -132,7 +132,7 @@ Fact* FactPanelController::getParameterFact(int componentId, const QString& name
if
(
reportMissing
)
{
_reportMissingParameter
(
componentId
,
name
);
}
return
NULL
;
return
nullptr
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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