rosNodeThread.h 1.95 KB
Newer Older
roangel's avatar
roangel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//    Creates a thread that runs the ros node.
//
//    Copyright (C) 2017  Angel Romero
//
//    This program 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.
//
//    This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

18
19
20
21
22
23
24
25
26
27
28
29
30
#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
31
#include "d_fall_pps/UnlabeledMarker.h"
muelmarc's avatar
merging    
muelmarc committed
32
33
#include "d_fall_pps/CrazyflieData.h"
#include "d_fall_pps/ViconData.h"
34
35
36

using namespace d_fall_pps;

muelmarc's avatar
merging    
muelmarc committed
37
typedef ViconData::ConstPtr ptrToMessage;
38
39
40
41

Q_DECLARE_METATYPE(ptrToMessage)


42
43
44
class rosNodeThread : public QObject {
	Q_OBJECT
public:
45
    explicit rosNodeThread(int argc, char **pArgv, const char * node_name, QObject *parent = 0);
46
47
48
49
    virtual ~rosNodeThread();

    bool init();

roangel's avatar
roangel committed
50
    // void messageCallback(const ViconData& data);
muelmarc's avatar
merging    
muelmarc committed
51
    void messageCallback(const ptrToMessage& p_msg);
52

53
    ros::ServiceClient m_read_db_client;
54
55
    ros::ServiceClient m_update_db_client;
    ros::ServiceClient m_command_db_client;
56

57
signals:
roangel's avatar
roangel committed
58

59
    void newViconData(const ptrToMessage& p_msg);
60
61
62
63

public slots:
    void run();

64
65
66
private:
    int m_Init_argc;
    char** m_pInit_argv;
67
    const char * m_node_name;
68
69
70

    QThread * m_pThread;

71
72
73
    ViconData m_vicon_data;

    ros::Subscriber m_vicon_subscriber;
74
75
76
77
    // ros::Publisher  sim_velocity;
};
#endif