mainguiwindow.h 3.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#ifndef MAINGUIWINDOW_H
#define MAINGUIWINDOW_H

#define DEBUG_GUI

#include <QMainWindow>
#include <QTimer>
#include <QGridLayout>
#include <QGraphicsRectItem>

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
#ifndef DEBUG_GUI
#include "ros/callback_queue.h"
#include "ros/ros.h"
#include "CrazyFlieTypes.h"
#endif
#include "ui_mainguiwindow.h"
#include "myGraphicsScene.h"

namespace Ui {
class MainGUIWindow;
}


#ifndef DEBUG_GUI
struct setpoint
{
    double x;
    double y;
    double z;
    double yaw;

};

class CSetpointQueue
{
public:
    CSetpointQueue();
    void insert(setpoint newElem);
    setpoint getNext();
    void print();

private:
    struct QueueElem
    {
        QueueElem(setpoint newElem) {elem.x=newElem.x; elem.y=newElem.y; elem.z=newElem.z; elem.yaw=newElem.yaw; next=NULL;}
        setpoint elem;
        QueueElem* next;
    };

    QueueElem* startElem;
    QueueElem* currElem;
    QueueElem* lastElem;
};
#endif

class MainGUIWindow : public QMainWindow
{
    Q_OBJECT

public:
    #ifdef DEBUG_GUI
    explicit MainGUIWindow(/*ros::NodeHandle* ,*/ /*ros::CallbackQueue* callbackQueue, ros::Publisher* publisherMotorCommandsGUI,*/ QWidget *parent = 0);
    #else
    explicit MainGUIWindow(ros::NodeHandle* , /*ros::CallbackQueue* callbackQueue, ros::Publisher* publisherMotorCommandsGUI,*/ QWidget *parent = 0);
    #endif
    ~MainGUIWindow();
    #ifndef DEBUG_GUI
    void init();
    #endif

public slots:
    #ifndef DEBUG_GUI
    void runCallbacks();
    #endif
private slots:
    #ifndef DEBUG_GUI
78
    #endif
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

    void set_tabs(int n);
    void transitionToMode(int mode);
    void on_removeTable_clicked();

    void on_radioButton_table_mode_toggled(bool checked);

    void on_radioButton_crazyfly_zones_mode_toggled(bool checked);
    void handleTablePiecesNumChanged(int newNum);

    void on_radioButton_lock_mode_toggled(bool checked);

    void on_checkBox_grid_toggled(bool checked);

    void on_checkBox_table_toggled(bool checked);

    void on_checkBox_crazyfly_zones_toggled(bool checked);

    void on_tabWidget_currentChanged(int index);

    void centerViewIndex(int index);

    void on_pushButton_fitAll_clicked();

private:

    Ui::MainGUIWindow *ui;
    myGraphicsScene* scene;
    QGraphicsRectItem* item1;

    void _init();

    #ifndef DEBUG_GUI
    void readDefaultParameters();
    ros::CallbackQueue m_CallbackQueue;
    ros::NodeHandle* m_pNodeHandle;

    // publishers
    // ros::Publisher* m_pPublisherMotorCommandsGUI;
    ros::Publisher* m_pPublisherControllerParam;
    ros::Publisher* m_pPublisherPositionSetpoint;
    ros::Publisher* m_pPublisherSampleTime;
    ros::Publisher* m_pPublisherControllerType;
    ros::Publisher* m_pPublisherDoSomething;
    ros::Publisher* m_pPublisherFeedforwardCmd;

    crazypkg::ControllerParam m_controllerParam;
    crazypkg::PositionSetpoint m_positionSetpoint;
    crazypkg::MotorCommands m_DummyCommands;
    crazypkg::SampleTimeParam m_sampleTimeParam;
    std_msgs::Int32 m_controllerType;
    std_msgs::Int32 m_DoSomething;
    crazypkg::MotorCommands m_feedforwardCmd;

    //subscribers
    ros::Subscriber* m_pSubscriberControllerOutput;
    ros::Subscriber* m_pSubscriberViconData;
    ros::Subscriber* m_pSubscriberCntViconDataMissed;

    // crazypkg::MotorCommands m_MotorCommands;
    // crazypkg::ViconData m_ViconData;

    // params
    // PIDParams m_PIDParams [countPIDControllers];

    // default params
    PIDParams m_DefaultPIDParams[countPIDControllers];
    PIDParams m_DefaultRateParams[countRateControllers];
    double m_DefaultSampleTime[countSampleTimeTypes];
    crazypkg::MotorCommands m_DefaultFeedforwardCmd;

    CSetpointQueue m_trajCircle;
    CSetpointQueue m_trajSquare;
    setpoint m_currSetpoint;

    bool m_isStopButtonActive;
    bool m_isCalActive;

    enum ETrajectoryType
    {
        eTrajCustom,
        eTrajCircle,
        eTrajSquare
    };

    ETrajectoryType m_trajectoryType;

    #endif
};



#endif // MAINGUIWINDOW_H