Statistics
| Branch: | Revision:

root / rgbdslam / src / qtros.h @ 9240aaa3

History | View | Annotate | Download (1.66 KB)

1
/* This file is part of RGBDSLAM.
2
 * 
3
 * RGBDSLAM is free software: you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation, either version 3 of the License, or
6
 * (at your option) any later version.
7
 * 
8
 * RGBDSLAM is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 * 
13
 * You should have received a copy of the GNU General Public License
14
 * along with RGBDSLAM.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16

    
17

    
18
//!Sets up a thread for ROS event processing
19
/** 
20
 * QtThread based class encapsulating the ros basics,
21
 * i.e., init, node handle creation, spining and quitting.
22
 * To quit via qt, connect the quitNow slot to, e.g., 
23
 * the aboutToQuit-Signal of qapplication.
24
 */
25
#ifndef QT_ROS_H
26
#define QT_ROS_H
27
#include "ros/ros.h"
28
#include <QThread>
29
#include <QObject>
30

    
31
class QtROS : public QThread {
32
  Q_OBJECT
33

    
34
  public:
35
    ///Note: The constructor will block until connected with roscore
36
    ///Instead of ros::spin(), start this thread with the start() method
37
    ///to run the event loop of ros
38
    QtROS(int argc, char *argv[], const char* node_name);
39
    ros::NodeHandle getNodeHandle(){ return *n; }
40
    //! This method contains the ROS event loop. Feel free to modify 
41
    void run();
42
  public Q_SLOTS:
43
    //!Connect to aboutToQuit signals, to stop the thread
44
    void quitNow();
45
  Q_SIGNALS:
46
    //!Triggered if ros::ok() != true
47
    void rosQuits();
48
  private:
49
    bool quitfromgui;
50
    ros::NodeHandle* n;
51
};
52
#endif