CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
/*
17
Camera driver for cameras that implement the newer MAVLink camera v2 protocol
18
see https://mavlink.io/en/services/camera.html
19
*/
20
#pragma once
21
22
#include "AP_Camera_Backend.h"
23
24
#if AP_CAMERA_MAVLINKCAMV2_ENABLED
25
26
class AP_Camera_MAVLinkCamV2 : public AP_Camera_Backend
27
{
28
public:
29
30
// Constructor
31
using AP_Camera_Backend::AP_Camera_Backend;
32
33
/* Do not allow copies */
34
CLASS_NO_COPY(AP_Camera_MAVLinkCamV2);
35
36
// update - should be called at 50hz
37
void update() override;
38
39
// entry point to actually take a picture
40
bool trigger_pic() override;
41
42
// start or stop video recording. returns true on success
43
// set start_recording = true to start record, false to stop recording
44
bool record_video(bool start_recording) override;
45
46
// set zoom specified as a rate or percentage
47
bool set_zoom(ZoomType zoom_type, float zoom_value) override;
48
49
// set focus specified as rate, percentage or auto
50
// focus in = -1, focus hold = 0, focus out = 1
51
SetFocusResult set_focus(FocusType focus_type, float focus_value) override;
52
53
// handle MAVLink messages from the camera
54
void handle_message(mavlink_channel_t chan, const mavlink_message_t &msg) override;
55
56
// send camera information message to GCS
57
void send_camera_information(mavlink_channel_t chan) const override;
58
59
private:
60
61
// search for camera in GCS_MAVLink routing table
62
void find_camera();
63
64
// request CAMERA_INFORMATION (holds vendor and model name)
65
void request_camera_information() const;
66
67
// internal members
68
bool _initialised; // true once the camera has provided a CAMERA_INFORMATION
69
bool _got_camera_info; // true once camera has provided CAMERA_INFORMATION
70
mavlink_camera_information_t _cam_info {}; // latest camera information received from camera
71
uint32_t _last_caminfo_req_ms; // system time that CAMERA_INFORMATION was last requested (used to throttle requests)
72
class GCS_MAVLINK *_link; // link we have found the camera on. nullptr if not seen yet
73
uint8_t _sysid; // sysid of camera
74
uint8_t _compid; // component id of gimbal
75
};
76
77
#endif // AP_CAMERA_MAVLINKCAMV2_ENABLED
78
79