src
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_viz/GuiWrapper.h
"
29
#include "
rtabmap/utilite/ULogger.h
"
30
31
#include <QApplication>
32
#include <
rtabmap/gui/MainWindow.h
>
33
#include <
rtabmap/utilite/ULogger.h
>
34
#include <signal.h>
35
36
QApplication *
app
= 0;
37
ros::AsyncSpinner
*
spinner
= 0;
38
39
void
my_handler
(
int
s){
40
ROS_INFO
(
"rtabmapviz: ctrl-c catched! Exiting Qt app..."
);
41
ros::shutdown
();
42
app
->exit(-1);
43
}
44
45
int
main
(
int
argc,
char
** argv)
46
{
47
ROS_INFO
(
"Starting node..."
);
48
49
ULogger::setType
(
ULogger::kTypeConsole
);
50
ULogger::setLevel
(
ULogger::kWarning
);
51
52
ros::init
(argc,
argv
,
"rtabmap_viz"
);
53
54
app
=
new
QApplication(argc,
argv
);
55
app
->connect(
app
, SIGNAL( lastWindowClosed() ),
app
, SLOT( quit() ) );
56
57
rtabmap_viz::GuiWrapper
* gui =
new
rtabmap_viz::GuiWrapper
(argc,
argv
);
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
(
"rtabmap_viz started."
);
72
// Now wait for application to finish
73
int
r =
app
->exec();
// MUST be called by the Main Thread
74
75
ROS_INFO
(
"rtabmap_viz stopping spinner..."
);
76
delete
spinner
;
77
78
ROS_INFO
(
"rtabmap_viz deleting qt stuff..."
);
79
delete
gui;
80
delete
app
;
81
ROS_INFO
(
"rtabmap_viz: All done! Closing..."
);
82
return
r;
83
}
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
MainWindow.h
ros::AsyncSpinner::start
void start()
ULogger::kTypeConsole
kTypeConsole
ULogger::setLevel
static void setLevel(ULogger::Level level)
ros::AsyncSpinner
ros::shutdown
ROSCPP_DECL void shutdown()
main
int main(int argc, char **argv)
Definition:
GuiNode.cpp:45
GuiWrapper.h
rtabmap_viz::GuiWrapper
Definition:
GuiWrapper.h:57
spinner
ros::AsyncSpinner * spinner
Definition:
GuiNode.cpp:37
app
QApplication * app
Definition:
GuiNode.cpp:36
ULogger::kWarning
kWarning
my_handler
void my_handler(int s)
Definition:
GuiNode.cpp:39
argv
argv
ULogger::setType
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
ULogger.h
NULL
#define NULL
ROS_INFO
#define ROS_INFO(...)
rtabmap_viz
Author(s): Mathieu Labbe
autogenerated on Mon Apr 28 2025 02:45:31