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
6f572a7f
Unverified
Commit
6f572a7f
authored
Jan 29, 2019
by
Gus Grubba
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7196 from mavlink/exposeCommonParams
Expose Common (camera) Parameters
parents
0a4fe0e4
9b4adfc6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
31 deletions
+48
-31
QGCCameraControl.cc
src/Camera/QGCCameraControl.cc
+9
-9
QGCCameraControl.h
src/Camera/QGCCameraControl.h
+12
-2
QGCCameraManager.cc
src/Camera/QGCCameraManager.cc
+25
-19
QGCCameraManager.h
src/Camera/QGCCameraManager.h
+2
-1
No files found.
src/Camera/QGCCameraControl.cc
View file @
6f572a7f
...
...
@@ -61,13 +61,13 @@ static const char* kPhotoLapseCount = "PhotoLapseCount";
//-----------------------------------------------------------------------------
// Known Parameters
static
const
char
*
kCAM_EV
=
"CAM_EV"
;
static
const
char
*
kCAM_EXPMODE
=
"CAM_EXPMODE"
;
static
const
char
*
kCAM_ISO
=
"CAM_ISO"
;
static
const
char
*
kCAM_SHUTTER
=
"CAM_SHUTTER
"
;
static
const
char
*
kCAM_APERTURE
=
"CAM_APERTURE"
;
static
const
char
*
kCAM_WBMODE
=
"CAM_WBMODE"
;
static
const
char
*
kCAM_MODE
=
"CAM_MODE"
;
const
char
*
QGCCameraControl
::
kCAM_EV
=
"CAM_EV"
;
const
char
*
QGCCameraControl
::
kCAM_EXPMODE
=
"CAM_EXPMODE"
;
const
char
*
QGCCameraControl
::
kCAM_ISO
=
"CAM_ISO"
;
const
char
*
QGCCameraControl
::
kCAM_SHUTTERSPD
=
"CAM_SHUTTERSPD
"
;
const
char
*
QGCCameraControl
::
kCAM_APERTURE
=
"CAM_APERTURE"
;
const
char
*
QGCCameraControl
::
kCAM_WBMODE
=
"CAM_WBMODE"
;
const
char
*
QGCCameraControl
::
kCAM_MODE
=
"CAM_MODE"
;
//-----------------------------------------------------------------------------
QGCCameraOptionExclusion
::
QGCCameraOptionExclusion
(
QObject
*
parent
,
QString
param_
,
QString
value_
,
QStringList
exclusions_
)
...
...
@@ -1990,9 +1990,9 @@ QGCCameraControl::iso()
//-----------------------------------------------------------------------------
Fact
*
QGCCameraControl
::
shutter
()
QGCCameraControl
::
shutter
Speed
()
{
return
(
_paramComplete
&&
_activeSettings
.
contains
(
kCAM_SHUTTER
))
?
getFact
(
kCAM_SHUTTER
)
:
nullptr
;
return
(
_paramComplete
&&
_activeSettings
.
contains
(
kCAM_SHUTTER
SPD
))
?
getFact
(
kCAM_SHUTTERSPD
)
:
nullptr
;
}
//-----------------------------------------------------------------------------
...
...
src/Camera/QGCCameraControl.h
View file @
6f572a7f
...
...
@@ -144,7 +144,7 @@ public:
Q_PROPERTY
(
Fact
*
exposureMode
READ
exposureMode
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
ev
READ
ev
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
iso
READ
iso
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
shutter
READ
shutter
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
shutter
Speed
READ
shutterSpeed
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
aperture
READ
aperture
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
wb
READ
wb
NOTIFY
parametersReady
)
Q_PROPERTY
(
Fact
*
mode
READ
mode
NOTIFY
parametersReady
)
...
...
@@ -222,7 +222,7 @@ public:
virtual
Fact
*
exposureMode
();
virtual
Fact
*
ev
();
virtual
Fact
*
iso
();
virtual
Fact
*
shutter
();
virtual
Fact
*
shutter
Speed
();
virtual
Fact
*
aperture
();
virtual
Fact
*
wb
();
virtual
Fact
*
mode
();
...
...
@@ -249,6 +249,16 @@ public:
//-- Allow controller to modify or invalidate parameter change
virtual
bool
validateParameter
(
Fact
*
pFact
,
QVariant
&
newValue
);
// Known Parameters
static
const
char
*
kCAM_EV
;
static
const
char
*
kCAM_EXPMODE
;
static
const
char
*
kCAM_ISO
;
static
const
char
*
kCAM_SHUTTERSPD
;
static
const
char
*
kCAM_APERTURE
;
static
const
char
*
kCAM_WBMODE
;
static
const
char
*
kCAM_MODE
;
signals:
void
infoChanged
();
void
videoStatusChanged
();
...
...
src/Camera/QGCCameraManager.cc
View file @
6f572a7f
...
...
@@ -109,35 +109,39 @@ QGCCameraManager::_handleHeartbeat(const mavlink_message_t &message)
//-- If this heartbeat is from a different component within the vehicle
if
(
_vehicleReadyState
&&
_vehicle
->
id
()
==
message
.
sysid
&&
_vehicle
->
defaultComponentId
()
!=
message
.
compid
)
{
//-- First time hearing from this one?
if
(
!
_cameraInfoRequest
.
contains
(
message
.
compid
))
{
QString
sCompID
=
QString
::
number
(
message
.
compid
);
if
(
!
_cameraInfoRequest
.
contains
(
sCompID
))
{
qCDebug
(
CameraManagerLog
)
<<
"Hearbeat from "
<<
message
.
compid
;
CameraStruct
*
pInfo
=
new
CameraStruct
(
this
);
pInfo
->
lastHeartbeat
.
start
();
_cameraInfoRequest
[
message
.
compid
]
=
pInfo
;
_cameraInfoRequest
[
sCompID
]
=
pInfo
;
//-- Request camera info
_requestCameraInfo
(
message
.
compid
);
}
else
{
if
(
_cameraInfoRequest
[
message
.
compid
])
{
if
(
_cameraInfoRequest
[
sCompID
])
{
CameraStruct
*
pInfo
=
_cameraInfoRequest
[
sCompID
];
//-- Check if we have indeed received the camera info
if
(
_cameraInfoRequest
[
message
.
compid
]
->
infoReceived
)
{
if
(
pInfo
->
infoReceived
)
{
//-- We have it. Just update the heartbeat timeout
_cameraInfoRequest
[
message
.
compid
]
->
lastHeartbeat
.
start
();
pInfo
->
lastHeartbeat
.
start
();
}
else
{
//-- Try again. Maybe.
if
(
_cameraInfoRequest
[
message
.
compid
]
->
lastHeartbeat
.
elapsed
()
>
2000
)
{
if
(
_cameraInfoRequest
[
message
.
compid
]
->
tryCount
>
3
)
{
if
(
!
_cameraInfoRequest
[
message
.
compid
]
->
gaveUp
)
{
_cameraInfoRequest
[
message
.
compid
]
->
gaveUp
=
true
;
if
(
pInfo
->
lastHeartbeat
.
elapsed
()
>
2000
)
{
if
(
pInfo
->
tryCount
>
3
)
{
if
(
!
pInfo
->
gaveUp
)
{
pInfo
->
gaveUp
=
true
;
qWarning
()
<<
"Giving up requesting camera info from"
<<
_vehicle
->
id
()
<<
message
.
compid
;
}
}
else
{
_cameraInfoRequest
[
message
.
compid
]
->
tryCount
++
;
pInfo
->
tryCount
++
;
//-- Request camera info. Again. It could be something other than a camera, in which
// case, we won't ever receive it.
_requestCameraInfo
(
message
.
compid
);
}
}
}
}
else
{
qWarning
()
<<
"_cameraInfoRequest["
<<
sCompID
<<
"] is null"
;
}
}
}
...
...
@@ -191,9 +195,10 @@ void
QGCCameraManager
::
_handleCameraInfo
(
const
mavlink_message_t
&
message
)
{
//-- Have we requested it?
if
(
_cameraInfoRequest
.
contains
(
message
.
compid
)
&&
!
_cameraInfoRequest
[
message
.
compid
]
->
infoReceived
)
{
QString
sCompID
=
QString
::
number
(
message
.
compid
);
if
(
_cameraInfoRequest
.
contains
(
sCompID
)
&&
!
_cameraInfoRequest
[
sCompID
]
->
infoReceived
)
{
//-- Flag it as done
_cameraInfoRequest
[
message
.
compid
]
->
infoReceived
=
true
;
_cameraInfoRequest
[
sCompID
]
->
infoReceived
=
true
;
mavlink_camera_information_t
info
;
mavlink_msg_camera_information_decode
(
&
message
,
&
info
);
qCDebug
(
CameraManagerLog
)
<<
"_handleCameraInfo:"
<<
reinterpret_cast
<
const
char
*>
(
info
.
model_name
)
<<
reinterpret_cast
<
const
char
*>
(
info
.
vendor_name
)
<<
"Comp ID:"
<<
message
.
compid
;
...
...
@@ -213,14 +218,15 @@ void
QGCCameraManager
::
_cameraTimeout
()
{
//-- Iterate cameras
for
(
int
i
=
0
;
i
<
_cameraInfoRequest
.
count
();
i
++
)
{
if
(
_cameraInfoRequest
[
i
])
{
foreach
(
QString
sCompID
,
_cameraInfoRequest
.
keys
())
{
if
(
_cameraInfoRequest
[
sCompID
])
{
CameraStruct
*
pInfo
=
_cameraInfoRequest
[
sCompID
];
//-- Have we received a camera info message?
if
(
_cameraInfoRequest
[
i
]
->
infoReceived
)
{
if
(
pInfo
->
infoReceived
)
{
//-- Has the camera stopped talking to us?
if
(
_cameraInfoRequest
[
i
]
->
lastHeartbeat
.
elapsed
()
>
5000
)
{
if
(
pInfo
->
lastHeartbeat
.
elapsed
()
>
5000
)
{
//-- Camera is gone. Remove it.
QGCCameraControl
*
pCamera
=
_findCamera
(
i
);
QGCCameraControl
*
pCamera
=
_findCamera
(
pInfo
->
compID
);
qWarning
()
<<
"Camera"
<<
pCamera
->
modelName
()
<<
"stopped transmitting. Removing from list."
;
int
idx
=
_cameraLabels
.
indexOf
(
pCamera
->
modelName
());
if
(
idx
>=
0
)
{
...
...
@@ -232,8 +238,8 @@ QGCCameraManager::_cameraTimeout()
}
bool
autoStream
=
pCamera
->
autoStream
();
pCamera
->
deleteLater
();
delete
_cameraInfoRequest
[
i
]
;
_cameraInfoRequest
.
remove
(
i
);
delete
pInfo
;
_cameraInfoRequest
.
remove
(
sCompID
);
emit
cameraLabelsChanged
();
//-- If we have another camera, switch current camera.
if
(
_cameras
.
count
())
{
...
...
src/Camera/QGCCameraManager.h
View file @
6f572a7f
...
...
@@ -81,6 +81,7 @@ protected:
bool
infoReceived
=
false
;
bool
gaveUp
=
false
;
int
tryCount
=
0
;
uint8_t
compID
=
0
;
};
Vehicle
*
_vehicle
=
nullptr
;
...
...
@@ -93,5 +94,5 @@ protected:
QTime
_lastZoomChange
;
QTime
_lastCameraChange
;
QTimer
_cameraTimer
;
QMap
<
int
,
CameraStruct
*>
_cameraInfoRequest
;
QMap
<
QString
,
CameraStruct
*>
_cameraInfoRequest
;
};
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