moveit2
The MoveIt Motion Planning Framework for ROS 2.
planning_groups.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2021, PickNik Robotics
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 PickNik 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 
35 /* Author: David V. Lu!! */
36 #pragma once
37 
41 #include <vector>
42 
43 namespace moveit_setup
44 {
45 namespace srdf_setup
46 {
48 {
49 public:
50  std::string data;
51  std::vector<LinkNameTree> children;
52 };
53 
55 {
56  LinkNameTree node;
57  node.data = link->getName();
58 
59  for (const auto& child_joint : link->getChildJointModels())
60  {
61  node.children.push_back(buildLinkNameTree(child_joint->getChildLinkModel()));
62  }
63  return node;
64 }
65 
66 class PlanningGroups : public SuperSRDFStep<srdf::Model::Group>
67 {
68 public:
69  std::string getName() const override
70  {
71  return "Planning Groups";
72  }
73 
74  std::vector<srdf::Model::Group>& getContainer() override
75  {
76  return srdf_config_->getGroups();
77  }
78 
80  {
81  return GROUPS;
82  }
83 
84  void onInit() override;
85 
86  std::vector<srdf::Model::Group>& getGroups()
87  {
88  return srdf_config_->getGroups();
89  }
90 
91  void renameGroup(const std::string& old_group_name, const std::string& new_group_name);
92  void deleteGroup(const std::string& group_name);
93 
97  void setJoints(const std::string& group_name, const std::vector<std::string>& joint_names);
98 
102  void setLinks(const std::string& group_name, const std::vector<std::string>& link_names);
103 
108  void setChain(const std::string& group_name, const std::string& base, const std::string& tip);
109 
114  void setSubgroups(const std::string& selected_group_name, const std::vector<std::string>& subgroups);
115 
116  const GroupMetaData& getMetaData(const std::string& group_name) const
117  {
118  return group_meta_config_->getMetaData(group_name);
119  }
120 
121  void setMetaData(const std::string& group_name, const GroupMetaData& meta_data)
122  {
123  group_meta_config_->setMetaData(group_name, meta_data);
124  }
125 
126  std::vector<std::string> getGroupNames() const
127  {
128  return srdf_config_->getGroupNames();
129  }
130 
131  const std::vector<std::string>& getJointNames() const
132  {
133  return srdf_config_->getRobotModel()->getJointModelNames();
134  }
135 
136  const std::vector<std::string>& getLinkNames() const
137  {
138  return srdf_config_->getRobotModel()->getLinkModelNames();
139  }
140 
141  std::string getChildOfJoint(const std::string& joint_name) const;
142  std::string getJointType(const std::string& joint_name) const;
144  std::vector<std::string> getPosesByGroup(const std::string& group_name) const;
145  std::vector<std::string> getEndEffectorsByGroup(const std::string& group_name) const;
146  std::vector<std::string> getKinematicPlanners() const;
147  std::vector<std::string> getOMPLPlanners() const;
148 
149 protected:
150  std::shared_ptr<GroupMetaConfig> group_meta_config_;
151 };
152 } // namespace srdf_setup
153 } // namespace moveit_setup
A link from the robot. Contains the constant transform applied to the link and its geometry.
Definition: link_model.h:72
const std::string & getName() const
The name of this link.
Definition: link_model.h:86
const std::vector< const JointModel * > & getChildJointModels() const
A link may have 0 or more child joints. From those joints there will certainly be other descendant li...
Definition: link_model.h:128
std::vector< LinkNameTree > children
std::vector< srdf::Model::Group > & getContainer() override
Returns the reference to the vector in the SRDF.
void setChain(const std::string &group_name, const std::string &base, const std::string &tip)
Set the specified group's kinematic chain.
void onInit() override
Overridable initialization method.
const std::vector< std::string > & getLinkNames() const
void setLinks(const std::string &group_name, const std::vector< std::string > &link_names)
Set the specified group's link names.
void setSubgroups(const std::string &selected_group_name, const std::vector< std::string > &subgroups)
Set the specified group's subgroups.
const std::vector< std::string > & getJointNames() const
std::vector< srdf::Model::Group > & getGroups()
void renameGroup(const std::string &old_group_name, const std::string &new_group_name)
std::string getName() const override
Returns the name of the setup step.
std::string getChildOfJoint(const std::string &joint_name) const
void deleteGroup(const std::string &group_name)
std::vector< std::string > getPosesByGroup(const std::string &group_name) const
std::string getJointType(const std::string &joint_name) const
std::shared_ptr< GroupMetaConfig > group_meta_config_
std::vector< std::string > getGroupNames() const
std::vector< std::string > getKinematicPlanners() const
InformationFields getInfoField() const override
Returns the info field associated with this part of the SRDF.
std::vector< std::string > getOMPLPlanners() const
std::vector< std::string > getEndEffectorsByGroup(const std::string &group_name) const
void setJoints(const std::string &group_name, const std::vector< std::string > &joint_names)
Set the specified group's joint names.
const GroupMetaData & getMetaData(const std::string &group_name) const
void setMetaData(const std::string &group_name, const GroupMetaData &meta_data)
std::shared_ptr< SRDFConfig > srdf_config_
Definition: srdf_step.hpp:67
This class provides a number of standard operations based on srdf's vector members.
Definition: srdf_step.hpp:83
LinkNameTree buildLinkNameTree(const moveit::core::LinkModel *link)