-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspection_base.h
198 lines (173 loc) · 5.47 KB
/
inspection_base.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#pragma once
#include <string>
#include <functional>
#include <cmath>
#include <vector>
namespace mavsdk {
/**
* @brief Base class for every inspection.
*/
class InspectionBase {
public:
/**
* @brief Default Constructor.
*/
InspectionBase() = default;
/**
* @brief Default Destructor.
*/
virtual ~InspectionBase() = default;
/**
* @brief Type representing a waypoint item.
*
* A WaypointItem can contain a position and/or actions.
* Waypoint items are building blocks to assemble a inspection,
* which can be sent to (or received from) a system.
* They cannot be used independently.
*/
struct WaypointItem {
std::string task_uuid{""};
std::string task_type_uuid{""};
uint16_t command{0};
uint8_t autocontinue{0};
float param1{0};
float param2{0};
float param3{0};
float param4{0};
float x{0};
float y{0};
float z{0};
};
/**
* @brief Equal operator to compare two `InspectionBase::WaypointItem` objects.
*
* @return `true` if items are equal.
*/
friend bool operator==(
const InspectionBase::WaypointItem& lhs, const InspectionBase::WaypointItem& rhs);
/**
* @brief Stream operator to print information about a `InspectionBase::WaypointItem`.
*
* @return A reference to the stream.
*/
friend std::ostream&
operator<<(std::ostream& str, InspectionBase::WaypointItem const& item);
/**
* @brief Waypoint list
*/
struct WaypointList {
std::string plan_uuid{""};
uint32_t sync_id{0};
std::vector<WaypointItem> items{}; /**< @brief The waypoint items */
};
/**
* @brief Equal operator to compare two `InspectionBase::WaypointList` objects.
*
* @return `true` if items are equal.
*/
friend bool operator==(
const InspectionBase::WaypointList& lhs, const InspectionBase::WaypointList& rhs);
/**
* @brief Stream operator to print information about a `InspectionBase::WaypointList`.
*
* @return A reference to the stream.
*/
friend std::ostream&
operator<<(std::ostream& str, InspectionBase::WaypointList const& list);
/**
* @brief Inspection progress type.
*/
struct InspectionProgress {
int32_t current{}; /**< @brief Current waypoint item index (0-based) */
int32_t reached{}; /**< @brief Reached waypoint item index (0-based) */
};
/**
* @brief Equal operator to compare two `InspectionBase::InspectionProgress` objects.
*
* @return `true` if items are equal.
*/
friend bool operator==(
const InspectionBase::InspectionProgress& lhs,
const InspectionBase::InspectionProgress& rhs);
/**
* @brief Stream operator to print information about a `InspectionBase::InspectionProgress`.
*
* @return A reference to the stream.
*/
friend std::ostream&
operator<<(std::ostream& str, InspectionBase::InspectionProgress const& progress);
/**
* @brief Possible ACKs returned for action requests.
*/
enum class Ack {
Accepted,
Error,
Unsupported,
NoSpace,
Invalid,
InvalidParam1,
InvalidParam2,
InvalidParam3,
InvalidParam4,
InvalidParam5,
InvalidParam6,
InvalidParam7,
InvalidSequence,
Cancelled,
Unknown
};
/**
* @brief Stream operator to print information about a `InspectionBase::Ack`.
*
* @return A reference to the stream.
*/
friend std::ostream& operator<<(std::ostream& str, InspectionBase::Ack const& ack);
/**
* @brief Possible results returned for action requests.
*/
enum class Result {
Unknown, /**< @brief Unknown result. */
Success, /**< @brief Request succeeded. */
ConnectionError, /**< @brief Connection error. */
ProtocolError, /**< @brief Protocol error. */
Busy, /**< @brief Vehicle is busy. */
Timeout, /**< @brief Request timed out. */
InvalidArgument, /**< @brief Invalid argument. */
TransferCancelled, /**< @brief Inspection transfer has been cancelled. */
};
/**
* @brief Stream operator to print information about a `InspectionBase::Result`.
*
* @return A reference to the stream.
*/
friend std::ostream& operator<<(std::ostream& str, InspectionBase::Result const& result);
/**
* @brief Callback type for asynchronous Inspection calls.
*/
using ResultCallback = std::function<void(Result)>;
/**
* @brief Callback type for asynchronous Inspection ACK calls.
*/
using ResultAckCallback = std::function<void(Result, Ack)>;
/**
* @brief Callback type for download_inspection_async.
*/
using DownloadInspectionCallback = std::function<void(Result, WaypointList)>;
/**
* @brief Callback type for subscribe_inspection_progress.
*/
using InspectionProgressCallback = std::function<void(InspectionProgress)>;
/**
* @brief Callback type for subscribe_inspection_set_current.
*/
using InspectionSetCurrentCallback = std::function<void(uint16_t)>;
/**
* @brief Copy constructor (object is not copyable).
*/
InspectionBase(const InspectionBase&) = delete;
/**
* @brief Assign operator (object is not copyable).
*/
const InspectionBase& operator=(const InspectionBase&) = delete;
};
} // namespace mavsdk