GuiNode.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include "rtabmap_ros/GuiWrapper.h"
30 
31 #include <QApplication>
32 #include <rtabmap/gui/MainWindow.h>
34 #include <signal.h>
35 
36 QApplication * app = 0;
38 
39 void my_handler(int s){
40  ROS_INFO("rtabmapviz: ctrl-c catched! Exiting Qt app...");
41  spinner->stop();
42  exit(-1);
43 }
44 
45 int main(int argc, char** argv)
46 {
47  ROS_INFO("Starting node...");
48 
51 
52  ros::init(argc, argv, "rtabmapviz");
53 
54  app = new QApplication(argc, argv);
55  app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) );
56 
58 
59  // Catch ctrl-c to close the gui
60  // (Place this after QApplication's constructor)
61  struct sigaction sigIntHandler;
62  sigIntHandler.sa_handler = my_handler;
63  sigemptyset(&sigIntHandler.sa_mask);
64  sigIntHandler.sa_flags = 0;
65  sigaction(SIGINT, &sigIntHandler, NULL);
66 
67  // Here start the ROS events loop
68  spinner = new ros::AsyncSpinner(1); // Use 1 thread
69  spinner->start();
70 
71  ROS_INFO("rtabmapviz started.");
72  // Now wait for application to finish
73  int r = app->exec();// MUST be called by the Main Thread
74 
75  spinner->stop();
76  delete spinner;
77 
78  delete gui;
79  delete app;
80  ROS_INFO("rtabmapviz: All done! Closing...");
81  return r;
82 }
#define NULL
QApplication * app
Definition: GuiNode.cpp:36
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static void setLevel(ULogger::Level level)
#define ROS_INFO(...)
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
bool gui
void my_handler(int s)
Definition: GuiNode.cpp:39
ros::AsyncSpinner * spinner
Definition: GuiNode.cpp:37
int main(int argc, char **argv)
Definition: GuiNode.cpp:45
r


rtabmap_ros
Author(s): Mathieu Labbe
autogenerated on Fri Jun 7 2019 21:55:03