simple_navigation_server.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018, Magazino GmbH, Sebastian Pütz, Jorge Santos Simón
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * simple_navigation_server.cpp
34  *
35  * authors:
36  * Sebastian Pütz <spuetz@uni-osnabrueck.de>
37  * Jorge Santos Simón <santos@magazino.eu>
38  *
39  */
40 
42 
43 namespace mbf_simple_nav
44 {
45 
47  mbf_abstract_nav::AbstractNavigationServer(tf_listener_ptr),
48  planner_plugin_loader_("mbf_abstract_core", "mbf_abstract_core::AbstractPlanner"),
49  controller_plugin_loader_("mbf_abstract_core", "mbf_abstract_core::AbstractController"),
50  recovery_plugin_loader_("mbf_abstract_core", "mbf_abstract_core::AbstractRecovery")
51 {
52  // initialize all plugins
54 
55  // start all action servers
57 }
58 
60 {
62  ROS_INFO("Load global planner plugin.");
63  try
64  {
65  planner_ptr = planner_plugin_loader_.createInstance(planner_type);
66  }
67  catch (const pluginlib::PluginlibException &ex)
68  {
69  ROS_FATAL_STREAM("Failed to load the " << planner_type << " planner, are you sure it is properly registered"
70  << " and that the containing library is built? Exception: " << ex.what());
71  }
72  ROS_INFO("Global planner plugin loaded.");
73 
74  return planner_ptr;
75 }
76 
78  const std::string& name,
80 )
81 {
82  return true;
83 }
84 
85 
87  const std::string& controller_type)
88 {
90  ROS_DEBUG("Load controller plugin.");
91  try
92  {
93  controller_ptr = controller_plugin_loader_.createInstance(controller_type);
94  ROS_INFO_STREAM("MBF_core-based local planner plugin " << controller_type << " loaded");
95  }
96  catch (const pluginlib::PluginlibException &ex)
97  {
98  ROS_FATAL_STREAM("Failed to load the " << controller_type
99  << " local planner, are you sure it's properly registered"
100  << " and that the containing library is built? Exception: " << ex.what());
101  }
102  return controller_ptr;
103 }
104 
106  const std::string& name,
107  const mbf_abstract_core::AbstractController::Ptr& controller_ptr)
108 {
109  return true;
110 }
111 
113  const std::string& recovery_type)
114 {
116 
117  try
118  {
119  recovery_ptr = boost::static_pointer_cast<mbf_abstract_core::AbstractRecovery>(
120  recovery_plugin_loader_.createInstance(recovery_type));
121  }
123  {
124  ROS_FATAL_STREAM("Failed to load the " << recovery_type << " recovery behavior, are you sure it's properly registered"
125  << " and that the containing library is built? Exception: " << ex.what());
126  }
127  return recovery_ptr;
128 }
129 
131  const std::string& name,
132  const mbf_abstract_core::AbstractRecovery::Ptr& behavior_ptr)
133 {
134  return true;
135 }
136 
137 
139 {
140 }
141 
142 } /* namespace mbf_simple_nav */
virtual bool initializeRecoveryPlugin(const std::string &name, const mbf_abstract_core::AbstractRecovery::Ptr &behavior_ptr)
Pure virtual method, the derived class has to implement. Depending on the plugin base class...
virtual mbf_abstract_core::AbstractRecovery::Ptr loadRecoveryPlugin(const std::string &recovery_type)
Loads a Recovery plugin associated with given recovery type parameter.
virtual bool initializePlannerPlugin(const std::string &name, const mbf_abstract_core::AbstractPlanner::Ptr &planner_ptr)
Empty init method. Nothing to initialize.
pluginlib::ClassLoader< mbf_abstract_core::AbstractPlanner > planner_plugin_loader_
pluginlib::ClassLoader< mbf_abstract_core::AbstractController > controller_plugin_loader_
#define ROS_FATAL_STREAM(args)
virtual mbf_abstract_core::AbstractController::Ptr loadControllerPlugin(const std::string &controller_type)
Loads the plugin associated with the given controller type parameter.
#define ROS_INFO(...)
virtual mbf_abstract_core::AbstractPlanner::Ptr loadPlannerPlugin(const std::string &planner_type)
Loads the plugin associated with the given planner_type parameter.
#define ROS_INFO_STREAM(args)
SimpleNavigationServer(const TFPtr &tf_listener_ptr)
Constructor.
virtual bool initializeControllerPlugin(const std::string &name, const mbf_abstract_core::AbstractController::Ptr &controller_ptr)
Empty init method. Nothing to initialize.
pluginlib::ClassLoader< mbf_abstract_core::AbstractRecovery > recovery_plugin_loader_
#define ROS_DEBUG(...)


mbf_simple_nav
Author(s): Sebastian Pütz
autogenerated on Fri Nov 6 2020 03:56:31