collision_plugin_loader.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2014 Fetch Robotics Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Fetch Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
36 
37 static const std::string LOGNAME = "collision_detection";
38 namespace collision_detection
39 {
40 void CollisionPluginLoader::setupScene(ros::NodeHandle& nh, const planning_scene::PlanningScenePtr& scene)
41 {
42  if (!scene)
43  {
44  ROS_WARN_NAMED(LOGNAME, "Cannot setup scene, PlanningScenePtr is null.");
45  return;
46  }
47 
48  std::string param_name;
49  std::string collision_detector_name;
50 
51  if (nh.searchParam("collision_detector", param_name))
52  {
53  nh.getParam(param_name, collision_detector_name);
54  }
55  else if (nh.hasParam("/move_group/collision_detector"))
56  {
57  // Check for existence in move_group namespace
58  // mainly for rviz plugins to get same collision detector.
59  nh.getParam("/move_group/collision_detector", collision_detector_name);
60  }
61  else
62  {
63  return;
64  }
65 
66  if (collision_detector_name.empty())
67  {
68  // This is not a valid name for a collision detector plugin
69  return;
70  }
71 
72  activate(collision_detector_name, scene, true);
73  ROS_INFO_STREAM("Using collision detector:" << scene->getActiveCollisionDetectorName().c_str());
74 }
75 
76 } // namespace collision_detection
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
collision_detection::LOGNAME
constexpr char LOGNAME[]
collision_detection::CollisionPluginCache::activate
bool activate(const std::string &name, const planning_scene::PlanningScenePtr &scene, bool exclusive)
ros::NodeHandle::searchParam
bool searchParam(const std::string &key, std::string &result) const
ros::NodeHandle::hasParam
bool hasParam(const std::string &key) const
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
LOGNAME
static const std::string LOGNAME
Definition: collision_plugin_loader.cpp:37
ROS_WARN_NAMED
#define ROS_WARN_NAMED(name,...)
collision_detection::CollisionPluginLoader::setupScene
void setupScene(ros::NodeHandle &nh, const planning_scene::PlanningScenePtr &scene)
Fetch plugin name from parameter server and activate the plugin for the given scene.
Definition: collision_plugin_loader.cpp:40
collision_plugin_loader.h
ros::NodeHandle
collision_detection


planning
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Wed Sep 15 2021 02:23:57