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_Scripting.cpp
Views: 1798
1
#include "AP_Camera_Scripting.h"
2
3
#if AP_CAMERA_SCRIPTING_ENABLED
4
5
extern const AP_HAL::HAL& hal;
6
7
// entry point to actually take a picture
8
bool AP_Camera_Scripting::trigger_pic()
9
{
10
// increment counter to allow backend to notice request
11
_cam_state.take_pic_incr++;
12
return true;
13
}
14
15
// start or stop video recording. returns true on success
16
// set start_recording = true to start record, false to stop recording
17
bool AP_Camera_Scripting::record_video(bool start_recording)
18
{
19
_cam_state.recording_video = start_recording;
20
return true;
21
}
22
23
// set zoom specified as a rate or percentage
24
bool AP_Camera_Scripting::set_zoom(ZoomType zoom_type, float zoom_value)
25
{
26
_cam_state.zoom_type = (uint8_t)zoom_type;
27
_cam_state.zoom_value = zoom_value;
28
return true;
29
}
30
31
// set focus specified as rate, percentage or auto
32
// focus in = -1, focus hold = 0, focus out = 1
33
SetFocusResult AP_Camera_Scripting::set_focus(FocusType focus_type, float focus_value)
34
{
35
_cam_state.focus_type = (uint8_t)focus_type;
36
_cam_state.focus_value = focus_value;
37
return SetFocusResult::ACCEPTED;
38
}
39
40
// set tracking to none, point or rectangle (see TrackingType enum)
41
// if POINT only p1 is used, if RECTANGLE then p1 is top-left, p2 is bottom-right
42
// p1,p2 are in range 0 to 1. 0 is left or top, 1 is right or bottom
43
bool AP_Camera_Scripting::set_tracking(TrackingType tracking_type, const Vector2f& p1, const Vector2f& p2)
44
{
45
_cam_state.tracking_type = (uint8_t)tracking_type;
46
_cam_state.tracking_p1 = p1;
47
_cam_state.tracking_p2 = p2;
48
return true;
49
}
50
51
// access for scripting backend to retrieve state
52
// returns true on success and cam_state is filled in
53
bool AP_Camera_Scripting::get_state(AP_Camera::camera_state_t& cam_state)
54
{
55
cam_state = _cam_state;
56
return true;
57
}
58
59
#endif // AP_CAMERA_SCRIPTING_ENABLED
60
61