-
Notifications
You must be signed in to change notification settings - Fork 15
/
Station.h
129 lines (101 loc) · 3.22 KB
/
Station.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
/***************************************************************************
* *
* Copyright (C) 2017 by University of Illinois *
* *
* http://illinois.edu *
* *
***************************************************************************/
/**
* @file Station.h
*
* A Station object organizes drones and senders, communicates with Vicon and
* updates measurements for drones using a separate thread.
*
* A StationWindow is the main GUI.
*
* This is the Model of the
* Model(Station)-View(StationWindow)-Controller(StationController) pattern.
*
* @author Bo Liu <[email protected]>
*
*/
#ifndef STATION_H
#define STATION_H
#include <QObject>
#include <QString>
#include <QHostAddress>
#include <QMap>
#include <QList>
#include "DataStreamClient.h"
#include <iostream>
#include "Drone.h"
#include <QReadWriteLock>
#include <QtConcurrent/QtConcurrent>
#include <GeographicLib/LocalCartesian.hpp>
class Station : public QObject
{
Q_OBJECT
public:
explicit Station(QObject *parent = 0);
virtual ~Station();
QHostAddress getHostAddress() const;
void setHostAddress(const QHostAddress &value);
quint16 getHostPort() const;
void setHostPort(const quint16 &value);
double getRate() const;
void setRate(double value);
void connectVicon();
void disconnectVicon();
void addDrone(const QString& name, double x, double y, double z,
double q_0, double q_1, double q_2, double q_3);
void addDrone(const QString& name);
mavlink_vicon_position_estimate_t getViconMeas(const QString& name);
void removeDrone(const QString& name);
void dataStream();
QMap<QString, Drone> droneCollection;
QReadWriteLock lock;
QString getOriginGPS() const;
void setOriginGPS(const QString &q_gps);
GeographicLib::LocalCartesian getGpsToLocal() const;
void setNorth(const QString &axis);
double getdt() const;
void setdt(double value);
long long getFrame() const;
void setFrame(long long value);
mavlink_att_pos_mocap_t getMeas(const QString &name, long long& frame);
signals:
void ViconConnected();
void ViconDisconnected();
void droneAdded(QString name);
void droneRemoved(QString name);
void dtUpdated(double dt);
public slots:
private:
double dt; // seconds/frame
long long frame;
double rate;
int vicon_x_mapping;
int vicon_y_mapping;
int vicon_z_mapping;
ViconDataStreamSDK::CPP::Client vicon_;
bool shouldExit;
bool isInitialized;
QHostAddress hostAddress;
quint16 hostPort;
struct originGPS {
double lat;
double lon;
double alt;
GeographicLib::LocalCartesian gps_to_local;
} originGPS;
QString north;
QFuture<void> dataStreamFuture;
QFuture<void> viconConnectFuture;
void _connectVicon();
void _dataStream();
void setupConnections();
void initialize();
// helpers
QString _Adapt( const ViconDataStreamSDK::CPP::Direction::Enum i_Direction );
};
#endif // STATION_H