defaultcontrollertab.h 4.65 KB
Newer Older
beuchatp's avatar
beuchatp committed
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
//    Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
//    This file is part of D-FaLL-System.
//
//    D-FaLL-System 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.
//
//    D-FaLL-System 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 D-FaLL-System.  If not, see <http://www.gnu.org/licenses/>.
//
//
//    ----------------------------------------------------------------------------------
//    DDDD        FFFFF        L     L           SSSS  Y   Y   SSSS  TTTTT  EEEEE  M   M
//    D   D       F      aaa   L     L          S       Y Y   S        T    E      MM MM
//    D   D  ---  FFFF  a   a  L     L     ---   SSS     Y     SSS     T    EEE    M M M
//    D   D       F     a  aa  L     L              S    Y        S    T    E      M   M
//    DDDD        F      aa a  LLLL  LLLL       SSSS     Y    SSSS     T    EEEEE  M   M
//
//
//    DESCRIPTION:
//    The GUI for the Default Controller
//
//    ----------------------------------------------------------------------------------





36
37
38
39
#ifndef DEFAULTCONTROLLERTAB_H
#define DEFAULTCONTROLLERTAB_H

#include <QWidget>
40
#include <QMutex>
41
#include <QVector>
42
#include <QTextStream>
43

44
45
46
47
48
49
50
51
52
53
54
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>

// Include the standard message types
//#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>

// Include the DFALL message types
55
56
//#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/SetpointWithHeader.h"
57

58
// Include the DFALL service types
59
#include "dfall_pkg/GetSetpointService.h"
60

61
62
63
64
// Include the shared definitions
#include "nodes/Constants.h"

// SPECIFY THE PACKAGE NAMESPACE
65
//using namespace dfall_pkg;
66
67
68

#else
// Include the shared definitions
69
#include "include/Constants_for_Qt_compile.h"
70
71
72

#endif

73
74


75
76
77
78
79
80
81
82
83
84
85
86
namespace Ui {
class DefaultControllerTab;
}

class DefaultControllerTab : public QWidget
{
    Q_OBJECT

public:
    explicit DefaultControllerTab(QWidget *parent = 0);
    ~DefaultControllerTab();

87

88

89
public slots:
90
    void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
91
    void setMeasuredPose(float x , float y , float z , float roll , float pitch , float yaw , bool occluded);
92
    void poseDataUnavailableSlot();
93
94


95

96
97
98
99
100
101
102
103
private slots:
    void on_lineEdit_setpoint_new_x_returnPressed();
    void on_lineEdit_setpoint_new_y_returnPressed();
    void on_lineEdit_setpoint_new_z_returnPressed();
    void on_lineEdit_setpoint_new_yaw_returnPressed();

    void on_set_setpoint_button_clicked();

104
105
106
107
108
109
110
111
112
113
114
    void on_default_setpoint_button_clicked();

    void on_x_increment_plus_button_clicked();
    void on_x_increment_minus_button_clicked();
    void on_y_increment_plus_button_clicked();
    void on_y_increment_minus_button_clicked();
    void on_z_increment_plus_button_clicked();
    void on_z_increment_minus_button_clicked();
    void on_yaw_increment_plus_button_clicked();
    void on_yaw_increment_minus_button_clicked();

115
116


117
118
private:
    Ui::DefaultControllerTab *ui;
119

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    // --------------------------------------------------- //
    // PRIVATE VARIABLES

    // The type of this node, i.e., agent or a coordinator,
    // specified as a parameter in the "*.launch" file
    int m_type = 0;

    // The ID  of this node
    int m_ID;

    // For coordinating multiple agents
    std::vector<int> m_vector_of_agentIDs_toCoordinate;
    bool m_shouldCoordinateAll = true;
    QMutex m_agentIDs_toCoordinate_mutex;



#ifdef CATKIN_MAKE
    // PUBLISHER
    // > For requesting the setpoint to be changed
    ros::Publisher requestSetpointChangePublisher;
141
142
143
144

    // SUBSCRIBER
    // > For being notified when the setpoint is changed
    ros::Subscriber setpointChangedSubscriber;
145
146
147
#endif


148

149
150
151
152
    // --------------------------------------------------- //
    // PRIVATE FUNCTIONS


153
#ifdef CATKIN_MAKE
154
    // For receiving message that the setpoint was changed
155
    void setpointChangedCallback(const dfall_pkg::SetpointWithHeader& newSetpoint);
156

157
    // Fill the header for a message
158
    void fillSetpointMessageHeader( dfall_pkg::SetpointWithHeader & msg );
159
160
161

    // Get the paramters that specify the type and ID
    bool getTypeAndIDParameters();
162
163
164
165
#endif

    void publishSetpoint(float x, float y, float z, float yaw);

166
167
168
};

#endif // DEFAULTCONTROLLERTAB_H