src
octomap_server_node.cpp
Go to the documentation of this file.
1
9
/*
10
* Copyright (c) 2009-2012, A. Hornung, University of Freiburg
11
* All rights reserved.
12
*
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following conditions are met:
15
*
16
* * Redistributions of source code must retain the above copyright
17
* notice, this list of conditions and the following disclaimer.
18
* * Redistributions in binary form must reproduce the above copyright
19
* notice, this list of conditions and the following disclaimer in the
20
* documentation and/or other materials provided with the distribution.
21
* * Neither the name of the University of Freiburg nor the names of its
22
* contributors may be used to endorse or promote products derived from
23
* this software without specific prior written permission.
24
*
25
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*/
37
38
39
#include <
ros/ros.h
>
40
#include <
octomap_server/OctomapServer.h
>
41
42
#define USAGE "\nUSAGE: octomap_server <map.[bt|ot]>\n" \
43
" map.bt: inital octomap 3D map file to read\n"
44
45
using namespace
octomap_server
;
46
47
int
main
(
int
argc,
char
** argv){
48
ros::init
(argc, argv,
"octomap_server"
);
49
const
ros::NodeHandle
nh;
50
const
ros::NodeHandle
private_nh(
"~"
);
51
std::string mapFilename(
""
), mapFilenameParam(
""
);
52
53
if
(argc > 2 || (argc == 2 && std::string(argv[1]) ==
"-h"
)){
54
ROS_ERROR
(
"%s"
,
USAGE
);
55
exit(-1);
56
}
57
58
OctomapServer
server(private_nh, nh);
59
ros::spinOnce
();
60
61
if
(argc == 2){
62
mapFilename = std::string(argv[1]);
63
}
64
65
if
(private_nh.
getParam
(
"map_file"
, mapFilenameParam)) {
66
if
(mapFilename !=
""
) {
67
ROS_WARN
(
"map_file is specified by the argument '%s' and rosparam '%s'. now loads '%s'"
, mapFilename.c_str(), mapFilenameParam.c_str(), mapFilename.c_str());
68
}
else
{
69
mapFilename = mapFilenameParam;
70
}
71
}
72
73
if
(mapFilename !=
""
) {
74
if
(!server.
openFile
(mapFilename)){
75
ROS_ERROR
(
"Could not open file %s"
, mapFilename.c_str());
76
exit(1);
77
}
78
}
79
80
try
{
81
ros::spin
();
82
}
catch
(std::runtime_error& e){
83
ROS_ERROR
(
"octomap_server exception: %s"
, e.what());
84
return
-1;
85
}
86
87
return
0;
88
}
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
octomap_server::OctomapServer::openFile
virtual bool openFile(const std::string &filename)
Definition:
OctomapServer.cpp:210
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
ros.h
ros::spinOnce
ROSCPP_DECL void spinOnce()
OctomapServer.h
USAGE
#define USAGE
Definition:
octomap_server_node.cpp:42
ROS_WARN
#define ROS_WARN(...)
octomap_server
Definition:
OctomapServer.h:80
main
int main(int argc, char **argv)
Definition:
octomap_server_node.cpp:47
ROS_ERROR
#define ROS_ERROR(...)
octomap_server::OctomapServer
Definition:
OctomapServer.h:81
ros::spin
ROSCPP_DECL void spin()
ros::NodeHandle
octomap_server
Author(s): Armin Hornung
autogenerated on Mon Jan 2 2023 03:18:15