/
system.h
129 lines (109 loc) · 3.63 KB
/
system.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#pragma once
#include <memory>
#include <functional>
namespace mavsdk {
/**
* @brief Component Types
*/
enum ComponentType { UNKNOWN = 0, AUTOPILOT, CAMERA, GIMBAL };
/**
* @brief type for component discovery callback
*/
typedef std::function<void(ComponentType)> discover_callback_t;
class SystemImpl;
class MavsdkImpl;
class PluginImplBase;
/**
* @brief This class represents a system, made up of one or more components
* (e.g. autopilot, cameras, servos, gimbals, etc).
*
* System objects are used to interact with UAVs (including their components) and standalone
* cameras. They are not created directly by application code, but are returned by the Mavsdk
* class.
*/
class System {
public:
/** @private Constructor, used internally
*
* This constructor is not (and should not be) directly called by application code.
*
* @param parent `MavsdkImpl` dependency.
* @param system_id System id.
* @param comp_id Component id.
* @param connected If true then the system doesn't wait for heartbeat to go into connected
* state
*/
explicit System(MavsdkImpl& parent, uint8_t system_id, uint8_t comp_id, bool connected);
/**
* @brief Destructor.
*/
~System();
/**
* @brief Checks whether the system has an autopilot.
* @return `true` if it has an autopilot, `false` otherwise.
*/
bool has_autopilot() const;
/**
* @brief Checks whether the system is a standalone (non-autopilot).
* @return `true` if stand alone, `false` otherwise.
*/
bool is_standalone() const;
/**
* @brief Checks whether the system has a camera with the given camera ID.
*
* A System may have several cameras, with IDs starting from 0.
* When called without passing a camera ID, it checks whether the system has
* any camera.
* @param camera_id ID of the camera starting from 0 onwards.
* @return `true` if camera with the given camera ID is found, `false` otherwise.
*/
bool has_camera(int camera_id = -1) const;
/**
* @brief Checks whether the system has a gimbal.
* @return `true` if the system has a gimbal, false otherwise.
*/
bool has_gimbal() const;
/**
* @brief Checks if the system is connected.
*
* A system is connected when heartbeats are arriving (discovered and not timed out).
* @return `true` if the system is connected.
*/
bool is_connected() const;
/**
* @brief Get the UUID of the system.
*
* @return UUID of system.
*/
uint64_t get_uuid() const;
/**
* @brief Register a callback to be called when a component is discovered.
*
* @param callback a function of type void(ComponentType) which will be called with the
* component type of the new component.
*/
void register_component_discovered_callback(discover_callback_t callback) const;
/**
* @brief Enable time synchronization using the TIMESYNC messages.
*/
void enable_timesync();
/**
* @brief Copy constructor (object is not copyable).
*/
System(const System&) = delete;
/**
* @brief Equality operator (object is not copyable).
*/
const System& operator=(const System&) = delete;
private:
std::shared_ptr<SystemImpl> system_impl() { return _system_impl; };
/*
* MavsdkImpl and PluginImplBase need access to SystemImpl class.
* This is not pretty but it's not easy to hide the methods from library
* users if not like that (or with an ugly reinterpret_cast).
*/
friend MavsdkImpl;
friend PluginImplBase;
std::shared_ptr<SystemImpl> _system_impl;
};
} // namespace mavsdk