rosNodeThread.h 3.44 KB
Newer Older
1
2
3
4
5
6
//    Copyright (C) 2018, ETH Zurich, D-ITET
//          Yvan Bosshard           byvan       @ee.ethz.ch
//          Michael Rogenmoser      michaero    @ee.ethz.ch
//          Tiago Salzmann          tiagos      @ee.ethz.ch
//    
//    Adapted from rosNodeThread of Angel Romero.
roangel's avatar
roangel committed
7
//
8
9
10
//    This file is part of D-FaLL-System.
//    
//    D-FaLL-System is free software: you can redistribute it and/or modify
roangel's avatar
roangel committed
11
12
13
//    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.
14
15
//    
//    D-FaLL-System is distributed in the hope that it will be useful,
roangel's avatar
roangel committed
16
17
18
//    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.
19
//    
roangel's avatar
roangel committed
20
//    You should have received a copy of the GNU General Public License
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//    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:
//    Creates a thread that runs the ros node.
//
//    ----------------------------------------------------------------------------------

roangel's avatar
roangel committed
37

38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ___ROSNODETHREAD_H___
#define ___ROSNODETHREAD_H___

#include <QtCore>
#include <QThread>
#include <QStringList>
#include <stdlib.h>
#include <QMutex>
#include <iostream>
#include "assert.h"

#include <ros/ros.h>
#include <ros/network.h>
roangel's avatar
roangel committed
51
#include "d_fall_pps/UnlabeledMarker.h"
muelmarc's avatar
merging    
muelmarc committed
52
#include "d_fall_pps/CrazyflieData.h"
53
#include "d_fall_pps/CrazyfliePositionData.h"
muelmarc's avatar
merging    
muelmarc committed
54
#include "d_fall_pps/ViconData.h"
55

56
57
#include <std_msgs/Int32MultiArray.h>

58
59
using namespace d_fall_pps;

muelmarc's avatar
merging    
muelmarc committed
60
typedef ViconData::ConstPtr ptrToMessage;
61
62
63
64

Q_DECLARE_METATYPE(ptrToMessage)


65
66
67
class rosNodeThread : public QObject {
	Q_OBJECT
public:
68
    explicit rosNodeThread(int argc, char **pArgv, const char * node_name, QObject *parent = 0);
69
70
71
72
    virtual ~rosNodeThread();

    bool init();

roangel's avatar
roangel committed
73
    // void messageCallback(const ViconData& data);
muelmarc's avatar
merging    
muelmarc committed
74
    void messageCallback(const ptrToMessage& p_msg);
75
76
    void studentIDCallback(const std_msgs::Int32MultiArray &ids);
    void positionDataCallback(const CrazyfliePositionData& data);
77
    //void positionDataCallback(const CrazyflieData& data);
78

79
    ros::ServiceClient m_read_db_client;
80
81
    ros::ServiceClient m_update_db_client;
    ros::ServiceClient m_command_db_client;
82

83
signals:
roangel's avatar
roangel committed
84

85
    void newViconData(const ptrToMessage& p_msg);
86
87
    void newStudentIDs(const std_msgs::Int32MultiArray &ids);
    void newPositionData(const CrazyfliePositionData& data);
88
    //void newPositionData(const CrazyflieData& data);
89
90
91
92

public slots:
    void run();

93
94
95
private:
    int m_Init_argc;
    char** m_pInit_argv;
96
    const char * m_node_name;
97
98
99

    QThread * m_pThread;

100
101
    ViconData m_vicon_data;

tiagos's avatar
tiagos committed
102
    ros::NodeHandle* nh;
103
    ros::Subscriber m_vicon_subscriber;
104
105
    ros::Subscriber studentID_subscriber;
    ros::Subscriber positionData_subscriber;
106
107
108
109
    // ros::Publisher  sim_velocity;
};
#endif