36 #include <pluginlib/class_loader.hpp>
37 #include <rclcpp/logger.hpp>
38 #include <rclcpp/logging.hpp>
59 cache_ = std::make_shared<pluginlib::ClassLoader<CollisionPlugin>>(
"moveit_core",
60 "collision_detection::CollisionPlugin");
62 catch (pluginlib::PluginlibException& e)
64 RCLCPP_ERROR(
getLogger(),
"Unable to construct collision plugin loader. Error: %s", e.what());
68 CollisionPluginPtr
load(
const std::string&
name)
70 CollisionPluginPtr plugin;
73 plugin = cache_->createUniqueInstance(
name);
74 plugins_[
name] = plugin;
76 catch (pluginlib::PluginlibException& ex)
78 RCLCPP_ERROR_STREAM(
getLogger(),
"Exception while loading " <<
name <<
": " << ex.what());
83 bool activate(
const std::string&
name,
const planning_scene::PlanningScenePtr& scene)
85 std::map<std::string, CollisionPluginPtr>::iterator it = plugins_.find(
name);
86 if (it == plugins_.end())
88 const CollisionPluginPtr plugin =
load(
name);
91 return plugin->initialize(scene);
97 return it->second->initialize(scene);
103 std::shared_ptr<pluginlib::ClassLoader<CollisionPlugin>> cache_;
104 std::map<std::string, CollisionPluginPtr> plugins_;
109 cache_ = std::make_shared<CollisionPluginCacheImpl>();
116 return cache_->activate(
name, scene);
bool activate(const std::string &name, const planning_scene::PlanningScenePtr &scene)
CollisionPluginCacheImpl()
CollisionPluginPtr load(const std::string &name)
bool activate(const std::string &name, const planning_scene::PlanningScenePtr &scene)
Activate a specific collision plugin for the given planning scene instance.
rclcpp::Logger getLogger()
rclcpp::Logger getLogger(const std::string &name)
Creates a namespaced logger.