enablecontrollerloadyamlbar.h 4.69 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
36
37
//    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 bar for selecting which controller is active, and
//    for request that paramters are loaded from the respective
//    YAML files.
//
//    ----------------------------------------------------------------------------------





38
39
40
41
#ifndef ENABLECONTROLLERLOADYAMLBAR_H
#define ENABLECONTROLLERLOADYAMLBAR_H

#include <QWidget>
42
#include <QMutex>
43

44
45
46
47
48
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>

49
50
51
// Include the standard message types
#include "std_msgs/Int32.h"
#include "std_msgs/Float32.h"
52
#include <std_msgs/String.h>
53
54

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

// Include the DFALL service types
59
60
61
// #include "dfall_pkg/AreaBounds.h"
// #include "dfall_pkg/CrazyflieContext.h"
// #include "dfall_pkg/CMQuery.h"
62

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

66
// using namespace dfall_pkg;
67
68
69
70
71

#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"

72
73
74
#endif


75

76
77


78
79
80
81
82
83
84
85
86
87
88
89
namespace Ui {
class EnableControllerLoadYamlBar;
}

class EnableControllerLoadYamlBar : public QWidget
{
    Q_OBJECT

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

90
91
92
93
    // PUBLIC METHODS FOR TOGGLING THE VISISBLE CONTROLLERS
    void showHideController_default_changed();
    void showHideController_student_changed();
    void showHideController_picker_changed();
94
    void showHideController_tuning_changed();
95
    void showHideController_template_changed();
96

beuchatp's avatar
beuchatp committed
97
98
    void testMotors_changed();

99
100
101
102
103

public slots:
    void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);


104
105
106
private slots:

    // ENABLE CONTROLLER BUTTONS ON-CLICK CALLBACK
107
    void on_enable_default_button_clicked();
108
109
110
111
    void on_enable_student_button_clicked();
    void on_enable_picker_button_clicked();
    void on_enable_tuning_button_clicked();
    void on_enable_template_button_clicked();
112
113

    // LOAD YAML BUTTONS ON-CLICK CALLBACK
114
    void on_load_yaml_default_button_clicked();
115
116
117
118
119
    void on_load_yaml_student_button_clicked();
    void on_load_yaml_picker_button_clicked();
    void on_load_yaml_tuning_button_clicked();
    void on_load_yaml_template_button_clicked();

120
121
122

private:
    Ui::EnableControllerLoadYamlBar *ui;
123

124

125
    // --------------------------------------------------- //
126
    // PRIVATE VARIABLES
127

128
129
130
131
132
133
134
    // 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;

135
136
137
138
139
140
    // For coordinating multiple agents
    std::vector<int> m_vector_of_agentIDs_toCoordinate;
    bool m_shouldCoordinateAll = true;
    QMutex m_agentIDs_toCoordinate_mutex;


141
#ifdef CATKIN_MAKE
142
    // PUBLISHERS AND SUBSRIBERS
143
144
    // > For {take-off,land,motors-off} and controller selection
    ros::Publisher commandPublisher;
145
146
147
    // > For requesting the loading of yaml files
    ros::Publisher m_requestLoadYamlFilenamePublisher;

148
#endif
149
150

    // --------------------------------------------------- //
151
    // PRIVATE FUNCTIONS
152

153
#ifdef CATKIN_MAKE
154
    // Fill the header for a message
155
156
    void fillIntMessageHeader( dfall_pkg::IntWithHeader & msg );
    void fillStringMessageHeader( dfall_pkg::StringWithHeader & msg );
157
158
159

    // Get the paramters that specify the type and ID
    bool getTypeAndIDParameters();
160
#endif
161
162


163
164
165
};

#endif // ENABLECONTROLLERLOADYAMLBAR_H