-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.h
125 lines (105 loc) · 3.31 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
#pragma once
#include <memory>
#include <functional>
#include "deprecated.h"
namespace mavsdk {
/**
* @brief Component Types
*/
enum class ComponentType { UNKNOWN, 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 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 MAVLink System ID of connected system.
*
* @note: this is 0 if nothing is connected yet.
*
* @return the system ID.
*/
uint8_t get_system_id() const;
/**
* @brief MAVLink Component ID of connected system.
*
* @note: this is 0 if nothing is connected yet.
*
* @return the component ID.
*/
uint8_t get_component_id() const;
/**
* @brief type for is connected callback.
*/
using IsConnectedCallback = std::function<void(bool)>;
/**
* @brief Subscribe to callback to be called when system connection state changes.
*
* @param callback Callback which will be called.
*/
void subscribe_is_connected(IsConnectedCallback callback);
/**
* @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