mrpt_graphslam_2d_node.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+
9  */
10 
11 // MRPT headers
12 #include <mrpt/system/COutputLogger.h>
13 #include <mrpt/graphslam/CGraphSlamEngine.h>
14 #include <mrpt/system/string_utils.h>
15 
16 #include <cstdlib>
17 #include <cstring>
18 
19 // ROS headers
21 
22 using namespace mrpt;
23 using namespace mrpt::poses;
24 using namespace mrpt::obs;
25 using namespace mrpt::system;
26 using namespace mrpt::graphs;
27 using namespace mrpt::math;
28 using namespace mrpt::opengl;
29 using namespace mrpt::graphslam;
30 using namespace mrpt::graphslam::deciders;
31 using namespace mrpt::graphslam::optimizers;
32 using namespace mrpt::graphslam::apps;
33 
34 using namespace std;
35 
37 int main(int argc, char** argv)
38 {
39  std::string node_name = "mrpt_graphslam_2d";
40 
41  COutputLogger logger;
42  logger.setLoggerName(node_name);
43  logger.logFmt(LVL_WARN, "Initializing %s node...\n", node_name.c_str());
44 
45  ros::init(argc, argv, node_name);
46  ros::NodeHandle nh;
47 
48  ros::Rate loop_rate(10);
49 
50  try
51  {
52  // Initialization
55  &logger, &options_checker, &nh);
56  graphslam_handler.readParams();
57  graphslam_handler.initEngine_ROS();
58  graphslam_handler.setupComm();
59 
60  // print the parameters just for verification
61  graphslam_handler.printParams();
62 
63  bool cont_exec = true;
64  while (ros::ok() && cont_exec)
65  {
66  cont_exec = graphslam_handler.usePublishersBroadcasters();
67 
68  ros::spinOnce();
69  loop_rate.sleep();
70  }
71  }
72  catch (exception& e)
73  {
75  "Finished with a (known) exception!" << std::endl
76  << e.what() << std::endl);
77  mrpt::system::pause();
78  return -1;
79  }
80  catch (...)
81  {
82  ROS_ERROR_STREAM("Finished with a (unknown) exception!" << std::endl);
83  mrpt::system::pause();
84  return -1;
85  }
86 }
void readParams()
Read the problem configuration parameters.
bool usePublishersBroadcasters()
Provide feedback about the SLAM operation using ROS publilshers, update the registered frames using t...
void initEngine_ROS()
Initialize the CGraphslamEngine_* object.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ROSCPP_DECL bool ok()
void setupComm()
Wrapper method around the protected setup* class methods.
bool sleep()
void printParams()
Print in a compact manner the overall problem configuration parameters.
Manage variables, ROS parameters and everything else related to the graphslam-engine ROS wrapper...
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL void spinOnce()


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sun Jun 26 2022 02:12:26