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
d2b2432f
Commit
d2b2432f
authored
Nov 30, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Level Horizon support
parent
1c7174f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
1 deletion
+92
-1
APMSensorsComponent.qml
src/AutoPilotPlugins/APM/APMSensorsComponent.qml
+37
-0
APMSensorsComponentController.cc
src/AutoPilotPlugins/APM/APMSensorsComponentController.cc
+48
-0
APMSensorsComponentController.h
src/AutoPilotPlugins/APM/APMSensorsComponentController.h
+7
-1
No files found.
src/AutoPilotPlugins/APM/APMSensorsComponent.qml
View file @
d2b2432f
...
@@ -157,6 +157,7 @@ SetupPage {
...
@@ -157,6 +157,7 @@ SetupPage {
compassButton
:
compassButton
compassButton
:
compassButton
accelButton
:
accelButton
accelButton
:
accelButton
compassMotButton
:
motorInterferenceButton
compassMotButton
:
motorInterferenceButton
levelButton
:
levelHorizonButton
nextButton
:
nextButton
nextButton
:
nextButton
cancelButton
:
cancelButton
cancelButton
:
cancelButton
setOrientationsButton
:
setOrientationsButton
setOrientationsButton
:
setOrientationsButton
...
@@ -453,6 +454,26 @@ SetupPage {
...
@@ -453,6 +454,26 @@ SetupPage {
}
// QGCViewDialog
}
// QGCViewDialog
}
// Component - compassMotDialogComponent
}
// Component - compassMotDialogComponent
Component
{
id
:
levelHorizonDialogComponent
QGCViewDialog
{
id
:
levelHorizonDialog
function
accept
()
{
controller
.
levelHorizon
()
levelHorizonDialog
.
hideDialog
()
}
QGCLabel
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
wrapMode
:
Text
.
WordWrap
text
:
qsTr
(
"
To level the horizon you need to place the vehicle in its level flight position and press Ok.
"
)
}
}
// QGCViewDialog
}
// Component - levelHorizonDialogComponent
Column
{
Column
{
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
Layout.alignment
:
Qt
.
AlignLeft
|
Qt
.
AlignTop
Layout.alignment
:
Qt
.
AlignLeft
|
Qt
.
AlignTop
...
@@ -483,6 +504,22 @@ SetupPage {
...
@@ -483,6 +504,22 @@ SetupPage {
}
}
}
}
QGCButton
{
id
:
levelHorizonButton
width
:
parent
.
buttonWidth
text
:
_levelHorizonText
readonly
property
string
_levelHorizonText
:
qsTr
(
"
Level Horizon
"
)
onClicked
:
{
if
(
controller
.
accelSetupNeeded
)
{
showMessage
(
_levelHorizonText
,
qsTr
(
"
Accelerometer must be calibrated prior to Level Horizon.
"
),
StandardButton
.
Ok
)
}
else
{
showDialog
(
levelHorizonDialogComponent
,
_levelHorizonText
,
qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Cancel
|
StandardButton
.
Ok
)
}
}
}
QGCButton
{
QGCButton
{
id
:
motorInterferenceButton
id
:
motorInterferenceButton
width
:
parent
.
buttonWidth
width
:
parent
.
buttonWidth
...
...
src/AutoPilotPlugins/APM/APMSensorsComponentController.cc
View file @
d2b2432f
...
@@ -26,6 +26,7 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
...
@@ -26,6 +26,7 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
_compassButton
(
NULL
),
_compassButton
(
NULL
),
_accelButton
(
NULL
),
_accelButton
(
NULL
),
_compassMotButton
(
NULL
),
_compassMotButton
(
NULL
),
_levelButton
(
NULL
),
_nextButton
(
NULL
),
_nextButton
(
NULL
),
_cancelButton
(
NULL
),
_cancelButton
(
NULL
),
_setOrientationsButton
(
NULL
),
_setOrientationsButton
(
NULL
),
...
@@ -33,6 +34,7 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
...
@@ -33,6 +34,7 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
_magCalInProgress
(
false
),
_magCalInProgress
(
false
),
_accelCalInProgress
(
false
),
_accelCalInProgress
(
false
),
_compassMotCalInProgress
(
false
),
_compassMotCalInProgress
(
false
),
_levelInProgress
(
false
),
_orientationCalDownSideDone
(
false
),
_orientationCalDownSideDone
(
false
),
_orientationCalUpsideDownSideDone
(
false
),
_orientationCalUpsideDownSideDone
(
false
),
_orientationCalLeftSideDone
(
false
),
_orientationCalLeftSideDone
(
false
),
...
@@ -66,6 +68,8 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
...
@@ -66,6 +68,8 @@ APMSensorsComponentController::APMSensorsComponentController(void) :
_sensorsComponent
=
apmPlugin
->
sensorsComponent
();
_sensorsComponent
=
apmPlugin
->
sensorsComponent
();
connect
(
_sensorsComponent
,
&
VehicleComponent
::
setupCompleteChanged
,
this
,
&
APMSensorsComponentController
::
setupNeededChanged
);
connect
(
_sensorsComponent
,
&
VehicleComponent
::
setupCompleteChanged
,
this
,
&
APMSensorsComponentController
::
setupNeededChanged
);
connect
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
(),
&
MAVLinkProtocol
::
messageReceived
,
this
,
&
APMSensorsComponentController
::
_mavlinkMessageReceived
);
}
}
/// Appends the specified text to the status log area in the ui
/// Appends the specified text to the status log area in the ui
...
@@ -90,6 +94,7 @@ void APMSensorsComponentController::_startLogCalibration(void)
...
@@ -90,6 +94,7 @@ void APMSensorsComponentController::_startLogCalibration(void)
_compassButton
->
setEnabled
(
false
);
_compassButton
->
setEnabled
(
false
);
_accelButton
->
setEnabled
(
false
);
_accelButton
->
setEnabled
(
false
);
_compassMotButton
->
setEnabled
(
false
);
_compassMotButton
->
setEnabled
(
false
);
_levelButton
->
setEnabled
(
false
);
_setOrientationsButton
->
setEnabled
(
false
);
_setOrientationsButton
->
setEnabled
(
false
);
if
(
_accelCalInProgress
||
_compassMotCalInProgress
)
{
if
(
_accelCalInProgress
||
_compassMotCalInProgress
)
{
_nextButton
->
setEnabled
(
true
);
_nextButton
->
setEnabled
(
true
);
...
@@ -102,6 +107,7 @@ void APMSensorsComponentController::_startVisualCalibration(void)
...
@@ -102,6 +107,7 @@ void APMSensorsComponentController::_startVisualCalibration(void)
_compassButton
->
setEnabled
(
false
);
_compassButton
->
setEnabled
(
false
);
_accelButton
->
setEnabled
(
false
);
_accelButton
->
setEnabled
(
false
);
_compassMotButton
->
setEnabled
(
false
);
_compassMotButton
->
setEnabled
(
false
);
_levelButton
->
setEnabled
(
false
);
_setOrientationsButton
->
setEnabled
(
false
);
_setOrientationsButton
->
setEnabled
(
false
);
_cancelButton
->
setEnabled
(
true
);
_cancelButton
->
setEnabled
(
true
);
...
@@ -145,6 +151,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
...
@@ -145,6 +151,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
_compassButton
->
setEnabled
(
true
);
_compassButton
->
setEnabled
(
true
);
_accelButton
->
setEnabled
(
true
);
_accelButton
->
setEnabled
(
true
);
_compassMotButton
->
setEnabled
(
true
);
_compassMotButton
->
setEnabled
(
true
);
_levelButton
->
setEnabled
(
true
);
_setOrientationsButton
->
setEnabled
(
true
);
_setOrientationsButton
->
setEnabled
(
true
);
_nextButton
->
setEnabled
(
false
);
_nextButton
->
setEnabled
(
false
);
_cancelButton
->
setEnabled
(
false
);
_cancelButton
->
setEnabled
(
false
);
...
@@ -168,6 +175,10 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
...
@@ -168,6 +175,10 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
emit
calibrationComplete
();
emit
calibrationComplete
();
break
;
break
;
case
StopCalibrationSuccessShowLog
:
emit
calibrationComplete
();
break
;
case
StopCalibrationCancelled
:
case
StopCalibrationCancelled
:
emit
resetStatusTextArea
();
emit
resetStatusTextArea
();
_hideAllCalAreas
();
_hideAllCalAreas
();
...
@@ -183,6 +194,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
...
@@ -183,6 +194,7 @@ void APMSensorsComponentController::_stopCalibration(APMSensorsComponentControll
_magCalInProgress
=
false
;
_magCalInProgress
=
false
;
_accelCalInProgress
=
false
;
_accelCalInProgress
=
false
;
_compassMotCalInProgress
=
false
;
_compassMotCalInProgress
=
false
;
_levelInProgress
=
false
;
}
}
void
APMSensorsComponentController
::
calibrateCompass
(
void
)
void
APMSensorsComponentController
::
calibrateCompass
(
void
)
...
@@ -210,6 +222,15 @@ void APMSensorsComponentController::calibrateMotorInterference(void)
...
@@ -210,6 +222,15 @@ void APMSensorsComponentController::calibrateMotorInterference(void)
_uas
->
startCalibration
(
UASInterface
::
StartCalibrationCompassMot
);
_uas
->
startCalibration
(
UASInterface
::
StartCalibrationCompassMot
);
}
}
void
APMSensorsComponentController
::
levelHorizon
(
void
)
{
_levelInProgress
=
true
;
_vehicle
->
setConnectionLostEnabled
(
false
);
_startLogCalibration
();
_appendStatusLog
(
tr
(
"Hold the vehicle in its level flight position."
));
_uas
->
startCalibration
(
UASInterface
::
StartCalibrationLevel
);
}
void
APMSensorsComponentController
::
_handleUASTextMessage
(
int
uasId
,
int
compId
,
int
severity
,
QString
text
)
void
APMSensorsComponentController
::
_handleUASTextMessage
(
int
uasId
,
int
compId
,
int
severity
,
QString
text
)
{
{
Q_UNUSED
(
compId
);
Q_UNUSED
(
compId
);
...
@@ -495,3 +516,30 @@ bool APMSensorsComponentController::usingUDPLink(void)
...
@@ -495,3 +516,30 @@ bool APMSensorsComponentController::usingUDPLink(void)
{
{
return
_vehicle
->
priorityLink
()
->
getLinkConfiguration
()
->
type
()
==
LinkConfiguration
::
TypeUdp
;
return
_vehicle
->
priorityLink
()
->
getLinkConfiguration
()
->
type
()
==
LinkConfiguration
::
TypeUdp
;
}
}
void
APMSensorsComponentController
::
_mavlinkMessageReceived
(
LinkInterface
*
link
,
mavlink_message_t
message
)
{
Q_UNUSED
(
link
);
if
(
message
.
sysid
!=
_vehicle
->
id
())
{
return
;
}
if
(
message
.
msgid
==
MAVLINK_MSG_ID_COMMAND_ACK
&&
_levelInProgress
)
{
mavlink_command_ack_t
commandAck
;
mavlink_msg_command_ack_decode
(
&
message
,
&
commandAck
);
if
(
commandAck
.
command
==
MAV_CMD_PREFLIGHT_CALIBRATION
)
{
switch
(
commandAck
.
result
)
{
case
MAV_RESULT_ACCEPTED
:
_appendStatusLog
(
tr
(
"Level horizon complete"
));
_stopCalibration
(
StopCalibrationSuccessShowLog
);
break
;
default:
_appendStatusLog
(
tr
(
"Level horizon failed"
));
_stopCalibration
(
StopCalibrationFailed
);
break
;
}
}
}
}
src/AutoPilotPlugins/APM/APMSensorsComponentController.h
View file @
d2b2432f
...
@@ -35,6 +35,7 @@ public:
...
@@ -35,6 +35,7 @@ public:
Q_PROPERTY
(
QQuickItem
*
compassButton
MEMBER
_compassButton
)
Q_PROPERTY
(
QQuickItem
*
compassButton
MEMBER
_compassButton
)
Q_PROPERTY
(
QQuickItem
*
accelButton
MEMBER
_accelButton
)
Q_PROPERTY
(
QQuickItem
*
accelButton
MEMBER
_accelButton
)
Q_PROPERTY
(
QQuickItem
*
compassMotButton
MEMBER
_compassMotButton
)
Q_PROPERTY
(
QQuickItem
*
compassMotButton
MEMBER
_compassMotButton
)
Q_PROPERTY
(
QQuickItem
*
levelButton
MEMBER
_levelButton
)
Q_PROPERTY
(
QQuickItem
*
nextButton
MEMBER
_nextButton
)
Q_PROPERTY
(
QQuickItem
*
nextButton
MEMBER
_nextButton
)
Q_PROPERTY
(
QQuickItem
*
cancelButton
MEMBER
_cancelButton
)
Q_PROPERTY
(
QQuickItem
*
cancelButton
MEMBER
_cancelButton
)
Q_PROPERTY
(
QQuickItem
*
setOrientationsButton
MEMBER
_setOrientationsButton
)
Q_PROPERTY
(
QQuickItem
*
setOrientationsButton
MEMBER
_setOrientationsButton
)
...
@@ -78,6 +79,7 @@ public:
...
@@ -78,6 +79,7 @@ public:
Q_INVOKABLE
void
calibrateCompass
(
void
);
Q_INVOKABLE
void
calibrateCompass
(
void
);
Q_INVOKABLE
void
calibrateAccel
(
void
);
Q_INVOKABLE
void
calibrateAccel
(
void
);
Q_INVOKABLE
void
calibrateMotorInterference
(
void
);
Q_INVOKABLE
void
calibrateMotorInterference
(
void
);
Q_INVOKABLE
void
levelHorizon
(
void
);
Q_INVOKABLE
void
cancelCalibration
(
void
);
Q_INVOKABLE
void
cancelCalibration
(
void
);
Q_INVOKABLE
void
nextClicked
(
void
);
Q_INVOKABLE
void
nextClicked
(
void
);
Q_INVOKABLE
bool
usingUDPLink
(
void
);
Q_INVOKABLE
bool
usingUDPLink
(
void
);
...
@@ -99,7 +101,8 @@ signals:
...
@@ -99,7 +101,8 @@ signals:
private
slots
:
private
slots
:
void
_handleUASTextMessage
(
int
uasId
,
int
compId
,
int
severity
,
QString
text
);
void
_handleUASTextMessage
(
int
uasId
,
int
compId
,
int
severity
,
QString
text
);
void
_mavlinkMessageReceived
(
LinkInterface
*
link
,
mavlink_message_t
message
);
private:
private:
void
_startLogCalibration
(
void
);
void
_startLogCalibration
(
void
);
void
_startVisualCalibration
(
void
);
void
_startVisualCalibration
(
void
);
...
@@ -110,6 +113,7 @@ private:
...
@@ -110,6 +113,7 @@ private:
enum
StopCalibrationCode
{
enum
StopCalibrationCode
{
StopCalibrationSuccess
,
StopCalibrationSuccess
,
StopCalibrationSuccessShowLog
,
StopCalibrationFailed
,
StopCalibrationFailed
,
StopCalibrationCancelled
StopCalibrationCancelled
};
};
...
@@ -125,6 +129,7 @@ private:
...
@@ -125,6 +129,7 @@ private:
QQuickItem
*
_compassButton
;
QQuickItem
*
_compassButton
;
QQuickItem
*
_accelButton
;
QQuickItem
*
_accelButton
;
QQuickItem
*
_compassMotButton
;
QQuickItem
*
_compassMotButton
;
QQuickItem
*
_levelButton
;
QQuickItem
*
_nextButton
;
QQuickItem
*
_nextButton
;
QQuickItem
*
_cancelButton
;
QQuickItem
*
_cancelButton
;
QQuickItem
*
_setOrientationsButton
;
QQuickItem
*
_setOrientationsButton
;
...
@@ -135,6 +140,7 @@ private:
...
@@ -135,6 +140,7 @@ private:
bool
_magCalInProgress
;
bool
_magCalInProgress
;
bool
_accelCalInProgress
;
bool
_accelCalInProgress
;
bool
_compassMotCalInProgress
;
bool
_compassMotCalInProgress
;
bool
_levelInProgress
;
bool
_orientationCalDownSideDone
;
bool
_orientationCalDownSideDone
;
bool
_orientationCalUpsideDownSideDone
;
bool
_orientationCalUpsideDownSideDone
;
...
...
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