moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
chomp_plugin.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Willow Garage, 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 Willow Garage 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
41
42#include <pluginlib/class_list_macros.hpp>
43#include <vector>
44
45namespace chomp_interface
46{
47namespace
48{
49rclcpp::Logger getLogger()
50{
51 return moveit::getLogger("moveit.planners.chomp.planner_manager");
52}
53} // namespace
54
56{
57public:
61
62 bool initialize(const moveit::core::RobotModelConstPtr& model, const rclcpp::Node::SharedPtr& node,
63 const std::string& /* unused */) override
64 {
65 for (const std::string& group : model->getJointModelGroupNames())
66 {
67 planning_contexts_[group] = std::make_shared<CHOMPPlanningContext>("chomp_planning_context", group, model, node);
68 }
69 return true;
70 }
71
72 planning_interface::PlanningContextPtr
73 getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene,
75 moveit_msgs::msg::MoveItErrorCodes& error_code) const override
76 {
77 error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
78
79 if (req.group_name.empty())
80 {
81 RCLCPP_ERROR(getLogger(), "No group specified to plan for");
82 error_code.val = moveit_msgs::msg::MoveItErrorCodes::INVALID_GROUP_NAME;
83 return planning_interface::PlanningContextPtr();
84 }
85
86 if (!planning_scene)
87 {
88 RCLCPP_ERROR(getLogger(), "No planning scene supplied as input");
89 error_code.val = moveit_msgs::msg::MoveItErrorCodes::FAILURE;
90 return planning_interface::PlanningContextPtr();
91 }
92
93 // create PlanningScene using hybrid collision detector
94 planning_scene::PlanningScenePtr ps = planning_scene->diff();
96
97 // retrieve and configure existing context
98 const CHOMPPlanningContextPtr& context = planning_contexts_.at(req.group_name);
99 context->setPlanningScene(ps);
100 context->setMotionPlanRequest(req);
101 error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
102 return context;
103 }
104
106 {
107 // TODO: this is a dummy implementation
108 // capabilities.dummy = false;
109 return true;
110 }
111
112 std::string getDescription() const override
113 {
114 return "CHOMP";
115 }
116
117 void getPlanningAlgorithms(std::vector<std::string>& algs) const override
118 {
119 algs.resize(1);
120 algs[0] = "CHOMP";
121 }
122
123protected:
124 std::map<std::string, CHOMPPlanningContextPtr> planning_contexts_;
125};
126
127} // namespace chomp_interface
128
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
std::string getDescription() const override
Get a short string that identifies the planning interface.
bool canServiceRequest(const planning_interface::MotionPlanRequest &) const override
Determine whether this plugin instance is able to represent this planning request.
void getPlanningAlgorithms(std::vector< std::string > &algs) const override
Get the names of the known planning algorithms (values that can be filled as planner_id in the planni...
std::map< std::string, CHOMPPlanningContextPtr > planning_contexts_
bool initialize(const moveit::core::RobotModelConstPtr &model, const rclcpp::Node::SharedPtr &node, const std::string &) override
planning_interface::PlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req, moveit_msgs::msg::MoveItErrorCodes &error_code) const override
Construct a planning context given the current scene and a planning request. If a problem is encounte...
Base class for a MoveIt planner.
rclcpp::Logger getLogger(const std::string &name)
Creates a namespaced logger.
Definition logger.cpp:79
This namespace includes the base class for MoveIt planners.
moveit_msgs::msg::MotionPlanRequest MotionPlanRequest
This namespace includes the central class for representing planning contexts.