-
Notifications
You must be signed in to change notification settings - Fork 83
/
carinterface.h
177 lines (157 loc) · 5.67 KB
/
carinterface.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
/*
Copyright 2016 - 2019 Benjamin Vedder benjamin@vedder.se
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CARINTERFACE_H
#define CARINTERFACE_H
#include <QWidget>
#include <QVector>
#include <QTimer>
#include <QUdpSocket>
#include <QElapsedTimer>
#include "datatypes.h"
#include "mapwidget.h"
#include "packetinterface.h"
#include "tcpserversimple.h"
#include "imagewidget.h"
#ifdef HAS_OPENGL
#include "orientationwidget.h"
#endif
namespace Ui {
class CarInterface;
}
class CarInterface : public QWidget
{
Q_OBJECT
public:
explicit CarInterface(QWidget *parent = 0);
~CarInterface();
void setID(int id);
int getId();
bool pollData();
void setPollData(bool poll);
bool updateRouteFromMap();
void setOrientation(double roll, double pitch, double yaw);
void setStateData(CAR_STATE data);
void setMap(MapWidget *map);
void setPacketInterface(PacketInterface *packetInterface);
void setControlValues(double throttle, double steering, double max, bool currentMode);
void emergencyStop();
void setCtrlAp();
void setCtrlKb();
bool getCtrlKb();
bool setAp(bool on, bool resetState = false);
void disableKbBox();
void toggleCameraFullscreen();
void showAutoPilotConfiguration();
QPair<int,int> getFirmwareVersion();
bool getResetApOnEmergencyStop() const;
void setResetApOnEmergencyStop(bool value);
signals:
void terminalCmd(quint8 id, QString cmd);
void forwardVesc(quint8 id, QByteArray data);
void setRcCurrent(quint8 id, double current, double steering);
void setRcDuty(quint8 id, double duty, double steering);
void showStatusInfo(QString str, bool isGood);
void setServoDirect(quint8 id, double value);
void ioBoardSetPwm(quint8 id, quint8 board, double value);
private slots:
void timerSlot();
void udpReadReady();
void tcpRx(QByteArray &data);
void terminalPrint(quint8 id, QString str);
void vescFwdReceived(quint8 id, QByteArray data);
void routePointSet(LocPoint pos);
void lastRoutePointRemoved();
void nmeaReceived(quint8 id, QByteArray nmea_msg);
void configurationReceived(quint8 id, MAIN_CONFIG config);
void plotInitReceived(quint8 id, QString xLabel, QString yLabel);
void plotDataReceived(quint8 id, double x, double y);
void plotAddGraphReceived(quint8 id, QString name);
void plotSetGraphReceived(quint8 id, int graph);
void loadMagCal();
void cameraImageReceived(quint8 id, QImage image, int bytes);
void on_terminalSendButton_clicked();
void on_terminalSendVescButton_clicked();
void on_terminalClearButton_clicked();
void on_idBox_valueChanged(int arg1);
void on_vescToolTcpBox_toggled(bool checked);
void on_autopilotBox_toggled(bool checked);
void on_clearRouteButton_clicked();
void on_servoDirectSlider_valueChanged(int value);
void on_servoMappedSlider_valueChanged(int value);
void on_confReadButton_clicked();
void on_confReadDefaultButton_clicked();
void on_confWriteButton_clicked();
void on_setClockButton_clicked();
void on_setClockPiButton_clicked();
void on_rebootPiButton_clicked();
void on_shutdownPiButton_clicked();
void on_experimentSavePngButton_clicked();
void on_experimentSavePdfButton_clicked();
void on_experimentSaveXmlButton_clicked();
void on_experimentLoadXmlButton_clicked();
void on_experimentHZoomButton_toggled(bool checked);
void on_experimentVZoomButton_toggled(bool checked);
void on_camStartButton_clicked();
void on_camStopButton_clicked();
void on_camShowMapBox_toggled(bool checked);
void on_ubxVersionButton_clicked();
void on_ubxNavSatButton_clicked();
void on_ubxSolButton_clicked();
void on_ubxRelPosNedButton_clicked();
void on_ubxCfgGnssButton_clicked();
void on_uwbResetPosButton_clicked();
void on_uwbUptimeButton_clicked();
void on_zeroGyroButton_clicked();
void on_uwbRebootButton_clicked();
void on_uwbListAnchorsButton_clicked();
void on_ioBoardPwmSlider_valueChanged(int value);
private:
typedef struct {
QString label;
QString color;
QVector<double> xData;
QVector<double> yData;
} EXPERIMENT_PLOT;
Ui::CarInterface *ui;
QVector<EXPERIMENT_PLOT> mExperimentPlots;
int mExperimentPlotNow;
MapWidget *mMap;
PacketInterface *mPacketInterface;
#ifdef HAS_OPENGL
OrientationWidget *mOrientationWidget;
#endif
int mId;
bool resetApOnEmergencyStop;
CAR_STATE mLastCarState;
QTimer *mTimer;
QUdpSocket *mUdpSocket;
QHostAddress mLastHostAddress;
quint16 mUdpPort;
TcpServerSimple *mTcpServer;
bool mExperimentReplot;
QString mFaultLast;
bool mSettingsReadDone;
int mImageByteCnt;
int mImageCnt;
QElapsedTimer mImageTimer;
double mImageFpsFilter;
ImageWidget *mFullscreenImage;
MAIN_CONFIG mConfigLast;
QPair<int,int> mFirmwareVersion;
void getConfGui(MAIN_CONFIG &conf);
void setConfGui(MAIN_CONFIG &conf);
void updateExperimentZoom();
void setFirmwareVersion(QPair<int,int> firmwareVersion);
};
#endif // CARINTERFACE_H