Fawkes API  Fawkes Development Version
amcl_plugin.cpp
1 
2 /***************************************************************************
3  * amcl_plugin.cpp - Adaptive Monte Carlo Localization plugin
4  *
5  * Created: Wed May 16 16:02:15 2012
6  * Copyright 2012 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include <core/plugin.h>
24 
25 #include "amcl_thread.h"
26 #ifdef HAVE_ROS
27 # include "ros_thread.h"
28 # include "amcl_utils.h"
29 #endif
30 
31 using namespace fawkes;
32 
33 /** Adaptive Monte Carlo Localization plugin.
34  * @author Tim Niemueller
35  */
36 class AmclPlugin : public fawkes::Plugin
37 {
38  public:
39  /** Constructor.
40  * @param config Fawkes configuration
41  */
43  : Plugin(config)
44  {
45 #ifdef HAVE_ROS
46  AmclROSThread *rt = NULL;
47  bool ros_enabled = true;
48  try {
49  ros_enabled = config->get_bool(AMCL_CFG_PREFIX"ros/enable");
50  } catch (Exception &e) {} // ignore, use default
51  if (ros_enabled) {
52  rt = new AmclROSThread();
53  thread_list.push_back(rt);
54  }
55  thread_list.push_back(new AmclThread(rt));
56 #else
57  thread_list.push_back(new AmclThread());
58 #endif
59  }
60 };
61 
62 PLUGIN_DESCRIPTION("Adaptive Monte Carlo Localization")
63 EXPORT_PLUGIN(AmclPlugin)
Plugin interface class.
Definition: plugin.h:33
Fawkes library namespace.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
Thread to perform Adaptive Monte Carlo Localization.
Definition: amcl_thread.h:68
Base class for exceptions in Fawkes.
Definition: exception.h:36
AmclPlugin(Configuration *config)
Constructor.
Definition: amcl_plugin.cpp:42
Adaptive Monte Carlo Localization plugin.
Definition: amcl_plugin.cpp:36
Thread for ROS integration of the Adaptive Monte Carlo Localization.
Definition: ros_thread.h:51
Interface for configuration handling.
Definition: config.h:67