Repository navigation
Expand file tree
/
Copy pathMicroDronInterface.h
More file actions
197 lines (164 loc) · 4.54 KB
/
Copy pathMicroDronInterface.h
File metadata and controls
197 lines (164 loc) · 4.54 KB
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
//
// Created by abiel on 8/19/20.
//
#ifndef MICRODRONITESM_GUI_MICRODRONINTERFACE_H
#define MICRODRONITESM_GUI_MICRODRONINTERFACE_H
#include "SimplePID.h"
#include <iostream>
#include <fmt/format.h>
enum class ConnectionState{
SettingUp,
Connecting,
Connected
};
class MicroDronInterface {
public:
/**
* Retrieves last valid Pitch PID read from drone
* @return
*/
virtual SimplePID getPitchPid() const = 0;
/**
* Retrieves last valid Roll PID read from drone
* @return
*/
virtual SimplePID getRollPid() const = 0;
/**
* Retrieves last valid Yaw PID read from drone
* @return
*/
virtual SimplePID getYawPid() const = 0;
/**
* Retrieves last valid Height PID read from drone
* @return
*/
virtual SimplePID getHeightPid() const = 0;
/**
* Attempts to send a new pitch PID to drone
* @return
*/
virtual void setPitchPid(SimplePID pitchPid) = 0;
/**
* Attempts to send a new roll PID to drone
* @return
*/
virtual void setRollPid(SimplePID rollPid) = 0;
/**
* Attempts to send a new yaw PID to drone
* @return
*/
virtual void setYawPid(SimplePID yawPid) = 0;
/**
* Attempts to send a new height PID to drone
* @return
*/
virtual void setHeightPid(SimplePID heightPid) = 0;
/**
* Updates heartbeat of program, the drone keeps track of how often it is received, if it does not
* receive this message often enough the dron will stop for safety.
* @return
*/
virtual void sendHeartBeat() = 0;
/**
* Retrieve last valid pitch read from drone
* @return
*/
virtual float getPitch() const = 0;
/**
* Retrieve last valid roll read from drone
* @return
*/
virtual float getRoll() const = 0;
/**
* Retrieve last valid yaw read from drone
* @return
*/
virtual float getYaw() const = 0;
/**
* Retrieve last valid height read from drone
* @return
*/
virtual float getHeight() const = 0;
/**
* Retrieve last valid operation mode read from drone
* @return
*/
virtual int getMode() const = 0;
/**
* Retrieve last K value read from drone, this represents the biggest motor output the drone will attempt to use
* Range from 0 to 5000
* @return
*/
virtual float getK() const = 0;
/**
* Retrieve last motor1 output read from drone
* @return
*/
virtual float getMotorOutput1() const = 0;
/**
* Retrieve last motor2 output read from drone
* @return
*/
virtual float getMotorOutput2() const = 0;
/**
* Retrieve last motor3 output read from drone
* @return
*/
virtual float getMotorOutput3() const = 0;
/**
* Retrieve last motor4 output read from drone
* @return
*/
virtual float getMotorOutput4() const = 0;
/**
* Attempts to send all manual motor outputs at once
* Range from 0 to 5000
* @return
*/
virtual void setAllMotorOutput(float output) = 0;
/**
* Attempts to send individual motor outputs to all motors
* Range from 0 to 5000
* @param output1
* @param output2
* @param output3
* @param output4
*/
virtual void setAllMotorOutput(float output1, float output2, float output3, float output4) = 0;
/**
* Attempts to update the PID Setpoints on the drone
* @param pitch
* @param roll
* @param yaw
* @param height
*/
virtual void setManualSetpoint(float pitch, float roll, float yaw, float height, bool applyFeedForward) = 0;
/**
* Attempts to update K value, this represents the biggest motor output the drone will attempt to use
* @param pitch
* @param roll
* @param yaw
* @param height
*/
virtual void setK(float newK) = 0;
/**
* Immediately send command to stop all motors
*/
virtual void emergencyStop(bool state) = 0;
virtual bool isEmergencyStopped() const = 0;
/**
* Report whether a valid message has been read from the drone recently
* @return
*/
virtual bool isConnected() const = 0;
/**
* Retrieve the time between heartbeats that the drone has received
* @return
*/
virtual float getHeartbeatTime() const = 0;
virtual void sendJoystickControl(int16_t x, int16_t y, int16_t z, int16_t r) = 0;
virtual void takeoff(double height){
std::cout << fmt::format("Taking off to height: {}", height) << std::endl;
}
};
#endif //MICRODRONITESM_GUI_MICRODRONINTERFACE_H