Repository navigation
Expand file tree
/
Copy pathMainApp.h
More file actions
81 lines (62 loc) · 1.72 KB
/
Copy pathMainApp.h
File metadata and controls
81 lines (62 loc) · 1.72 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
//
// Created by abiel on 3/5/21.
//
#ifndef MICRODRONITESM_GUI_MAINAPP_H
#define MICRODRONITESM_GUI_MAINAPP_H
#include "imgui-SFML.h"
#include "imgui.h"
#include "MicroDron/MicroDronInterfaceUDP.h"
#include "MicroDron/LuaMicroDronInterface.h"
#include "PlotVar.h"
#include "implot.h"
#include "Utils/SFMLController.h"
#include <boost/circular_buffer.hpp>
struct ScrollingBuffer {
size_t MaxSize;
int Offset;
std::vector<ImVec2> Data;
ScrollingBuffer(size_t max_size = 2500) {
MaxSize = max_size;
Offset = 0;
Data.reserve(MaxSize);
}
void AddPoint(float x, float y) {
auto l = Data.size();
if (Data.size() < MaxSize)
Data.emplace_back(x,y);
else {
Data[Offset] = ImVec2(x,y);
Offset = (Offset + 1) % MaxSize;
}
}
void Erase() {
return;
if (Data.size() > 0) {
Data.resize(0);
Offset = 0;
}
}
};
class MainApp {
public:
MainApp();
~MainApp();
void update();
private:
MicroDronInterfaceUDP interface;
float pitch, roll, yaw, thrust, feedForward;
bool feedForwardEnabled;
bool closedLoopEnabled;
lua_State *luaState;
bool refreshParams = true;
SFMLControllerConfig tarranisConfig;
std::unique_ptr<SFMLController> controller;
bool lastScriptButton = false;
void createPIDConfigMenu(const std::string &name, SimplePID &pid, const std::function<void(const SimplePID &pid)> &setFun, int id);
void createPIDStatus(const std::string &name, const SimplePID &pid);
void drawParamWindow();
void drawIMUPlots();
void showDroneControl();
void showScriptsWindow();
};
#endif //MICRODRONITESM_GUI_MAINAPP_H