Skip to content

Commit

Permalink
Adds an interface to start capturing serie of images
Browse files Browse the repository at this point in the history
  • Loading branch information
kpetrykin committed Sep 5, 2019
1 parent 4e100d6 commit d5d5cf2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 21 deletions.
53 changes: 43 additions & 10 deletions src/FlightMap/Widgets/CameraPageWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ Column {
mainWindow.showComponentDialog(cameraSettings, _cameraVideoMode ? qsTr("Video Settings") : qsTr("Camera Settings"), 70, StandardButton.Ok)
}

//-- Dumb camera trigger if no actual camera interface exists
QGCButton {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Trigger Camera")
visible: !_camera
onClicked: activeVehicle.triggerCamera()
enabled: activeVehicle
objectName: "triggerCameraButton"
}

QGCButton {
anchors.horizontalCenter: parent.horizontalCenter
Expand Down Expand Up @@ -248,7 +239,7 @@ Column {
}

ComboBox {
currentIndex: (activeVehicle._duocamColormap != -1? activeVehicle._duocamColormap : -1)
currentIndex: activeVehicle._duocamColormap
visible: !activeVehicle._duocamColormapUpdating
model: ListModel {
id: cbColormap
Expand Down Expand Up @@ -355,6 +346,48 @@ Column {
}
}

Rectangle {
width: parent.width
height: 1
color: qgcPal.text
}

QGCLabel {
text: "Capture images (count, interval):"
}
Row {
SpinBox {
id: photoCountBox
value: 1
}
SpinBox {
id: photoIntervalBox
value: 0
}
}

Row {
Column {
QGCButton {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Start")
visible: !_camera
onClicked: activeVehicle.startImageCapture(photoIntervalBox.value, photoCountBox.value)
enabled: activeVehicle
}
}

Column {
QGCButton {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Stop")
visible: !_camera
onClicked: activeVehicle.stopImageCapture()
enabled: activeVehicle
}
}
}

// Row{
// QGCLabel {
// text: "Color palette: "
Expand Down
36 changes: 25 additions & 11 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3600,17 +3600,6 @@ void Vehicle::setOfflineEditingDefaultComponentId(int defaultComponentId)

void Vehicle::triggerCamera(void)
{
QObject *trigCamBut = this->_toolbox->corePlugin()->findChild<QObject*>("triggerCameraButton");

if (trigCamBut)
{
qDebug() << "trigCamBut found!";
trigCamBut->setProperty("color", "red");
}
else {
qDebug() << "trigCamBut NOT found!";
}

sendMavCommand(_defaultComponentId,
MAV_CMD_DO_DIGICAM_CONTROL,
true, // show errors
Expand All @@ -3620,6 +3609,31 @@ void Vehicle::triggerCamera(void)
1.0); // test shot flag
}

void Vehicle::startImageCapture(float interval, float count)
{
sendMavCommand(_defaultComponentId,
MAV_CMD_IMAGE_START_CAPTURE,
true, // show errors
0.0, // camera id
interval,
count,
0.0,
0.0,
0.0,
0.0);
}

void Vehicle::stopImageCapture(void)
{
sendMavCommand(_defaultComponentId,
MAV_CMD_IMAGE_STOP_CAPTURE,
true, // show errors
0.0, 0.0, 0.0, 0.0,
0.0,
0.0,
0.0);
}

void Vehicle::startVideoCapture(void)
{
sendMavCommand(_defaultComponentId,
Expand Down
2 changes: 2 additions & 0 deletions src/Vehicle/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ class Vehicle : public FactGroup
Q_INVOKABLE void updateDuocamProperties(void);

Q_INVOKABLE void triggerCamera(void);
Q_INVOKABLE void startImageCapture(float interval, float count);
Q_INVOKABLE void stopImageCapture(void);
Q_INVOKABLE void startVideoCapture(void);
Q_INVOKABLE void stopVideoCapture(void);
Q_INVOKABLE void setCameraProperty(QString propertyName, float value);
Expand Down

0 comments on commit d5d5cf2

Please sign in to comment.