-
Notifications
You must be signed in to change notification settings - Fork 400
/
qtros.h
52 lines (48 loc) · 1.66 KB
/
qtros.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* This file is part of RGBDSLAM.
*
* RGBDSLAM 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.
*
* RGBDSLAM 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 RGBDSLAM. If not, see <http://www.gnu.org/licenses/>.
*/
//!Sets up a thread for ROS event processing
/**
* QtThread based class encapsulating the ros basics,
* i.e., init, node handle creation, spining and quitting.
* To quit via qt, connect the quitNow slot to, e.g.,
* the aboutToQuit-Signal of qapplication.
*/
#ifndef QT_ROS_H
#define QT_ROS_H
#include "ros/ros.h"
#include <QThread>
#include <QObject>
class QtROS : public QThread {
Q_OBJECT
public:
///Note: The constructor will block until connected with roscore
///Instead of ros::spin(), start this thread with the start() method
///to run the event loop of ros
QtROS(int argc, char *argv[], const char* node_name);
ros::NodeHandle getNodeHandle(){ return *n; }
//! This method contains the ROS event loop. Feel free to modify
void run();
public Q_SLOTS:
//!Connect to aboutToQuit signals, to stop the thread
void quitNow();
Q_SIGNALS:
//!Triggered if ros::ok() != true
void rosQuits();
private:
bool quitfromgui;
ros::NodeHandle* n;
};
#endif