Robowflex  v0.1
Making MoveIt Easy
robowflex::Scene::CollisionPluginLoader Class Reference

The actual plugin loader for collision plugins. Heavily inspired by code in moveit_ros/planning. More...

Public Member Functions

 CollisionPluginLoader ()
 Constructor. Attempts to create the pluginlib loader for collision plugins. More...
 
collision_detection::CollisionPluginPtr load (const std::string &name)
 Attempts to load the collision detector plugin by the given name. Saves the plugin in an internal map and returns it if found. More...
 
bool activate (const std::string &name, const planning_scene::PlanningScenePtr &scene, bool exclusive)
 Loads a collision detector into a planning scene instance. More...
 

Private Types

using PluginLoader = pluginlib::ClassLoader< collision_detection::CollisionPlugin >
 The pluginlib loader for collision detection plugins. More...
 

Private Attributes

std::shared_ptr< PluginLoaderloader_
 
std::map< std::string, collision_detection::CollisionPluginPtr > plugins_
 Loaded plugins. More...
 

Detailed Description

The actual plugin loader for collision plugins. Heavily inspired by code in moveit_ros/planning.

Definition at line 28 of file scene.cpp.

Member Typedef Documentation

◆ PluginLoader

The pluginlib loader for collision detection plugins.

Definition at line 32 of file scene.cpp.

Constructor & Destructor Documentation

◆ CollisionPluginLoader()

robowflex::Scene::CollisionPluginLoader::CollisionPluginLoader ( )
inline

Constructor. Attempts to create the pluginlib loader for collision plugins.

Definition at line 37 of file scene.cpp.

38  {
39  try
40  {
41  loader_.reset(new PluginLoader("moveit_core", "collision_detection::CollisionPlugin"));
42  }
43  catch (pluginlib::PluginlibException &e)
44  {
45  RBX_ERROR("Unable to construct collision plugin loader. Error: %s", e.what());
46  }
47  }
pluginlib::ClassLoader< collision_detection::CollisionPlugin > PluginLoader
The pluginlib loader for collision detection plugins.
Definition: scene.cpp:32
std::shared_ptr< PluginLoader > loader_
Definition: scene.cpp:93
#define RBX_ERROR(fmt,...)
Output a error logging message.
Definition: log.h:102
T reset(T... args)

Member Function Documentation

◆ activate()

bool robowflex::Scene::CollisionPluginLoader::activate ( const std::string name,
const planning_scene::PlanningScenePtr &  scene,
bool  exclusive 
)
inline

Loads a collision detector into a planning scene instance.

Parameters
[in]namethe plugin name
[in]scenethe planning scene instance.
[in]exclusiveIf true, the new collision detector is the only one.
Returns
True if the new collision detector is added to the scene.

Definition at line 77 of file scene.cpp.

78  {
79  auto it = plugins_.find(name);
80  if (it == plugins_.end())
81  {
82  collision_detection::CollisionPluginPtr plugin = load(name);
83  if (plugin)
84  return plugin->initialize(scene, exclusive);
85  }
86  else if (it->second)
87  return it->second->initialize(scene, exclusive);
88 
89  return false;
90  }
collision_detection::CollisionPluginPtr load(const std::string &name)
Attempts to load the collision detector plugin by the given name. Saves the plugin in an internal map...
Definition: scene.cpp:54
std::map< std::string, collision_detection::CollisionPluginPtr > plugins_
Loaded plugins.
Definition: scene.cpp:94
T end(T... args)
T find(T... args)
Functions for loading and animating scenes in Blender.

◆ load()

collision_detection::CollisionPluginPtr robowflex::Scene::CollisionPluginLoader::load ( const std::string name)
inline

Attempts to load the collision detector plugin by the given name. Saves the plugin in an internal map and returns it if found.

Parameters
[in]nameName of the plugin to load.
Returns
An allocated collision plugin.

Definition at line 54 of file scene.cpp.

55  {
56  collision_detection::CollisionPluginPtr plugin;
57 
58  try
59  {
60  plugin.reset(loader_->createUnmanagedInstance(name));
61  plugins_[name] = plugin;
62  }
63  catch (pluginlib::PluginlibException &ex)
64  {
65  RBX_ERROR("Exception while loading %s: %s", name, ex.what());
66  }
67 
68  return plugin;
69  }

Member Data Documentation

◆ loader_

std::shared_ptr<PluginLoader> robowflex::Scene::CollisionPluginLoader::loader_
private

Definition at line 93 of file scene.cpp.

◆ plugins_

std::map<std::string, collision_detection::CollisionPluginPtr> robowflex::Scene::CollisionPluginLoader::plugins_
private

Loaded plugins.

Definition at line 94 of file scene.cpp.


The documentation for this class was generated from the following file: