moveit2
The MoveIt Motion Planning Framework for ROS 2.
group_meta_config.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2022, Metro Robots
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 Metro Robots 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 
39 #include <map>
40 #include <string>
41 
42 namespace moveit_setup
43 {
44 namespace srdf_setup
45 {
46 // Default kin solver values
47 static const double DEFAULT_KIN_SOLVER_SEARCH_RESOLUTION = 0.005;
48 static const double DEFAULT_KIN_SOLVER_TIMEOUT = 0.005;
49 
54 {
55  std::string kinematics_solver_; // Name of kinematics plugin to use
56  double kinematics_solver_search_resolution_{ DEFAULT_KIN_SOLVER_SEARCH_RESOLUTION }; // resolution to use with solver
57  double kinematics_solver_timeout_{ DEFAULT_KIN_SOLVER_TIMEOUT }; // solver timeout
58  std::string kinematics_parameters_file_; // file for additional kinematics parameters
59  std::string default_planner_; // Name of the default planner to use
60 };
61 
62 static const std::string KINEMATICS_FILE = "config/kinematics.yaml";
63 
65 {
66 public:
67  bool isConfigured() const override;
68  void loadPrevious(const std::filesystem::path& package_path, const YAML::Node& node) override;
69 
70  void deleteGroup(const std::string& group_name);
71  void renameGroup(const std::string& old_group_name, const std::string& new_group_name);
72 
73  const GroupMetaData& getMetaData(const std::string& group_name) const;
74  void setMetaData(const std::string& group_name, const GroupMetaData& meta_data);
75 
77  {
78  public:
79  GeneratedGroupMetaConfig(const std::filesystem::path& package_path, const GeneratedTime& last_gen_time,
80  GroupMetaConfig& parent)
81  : YamlGeneratedFile(package_path, last_gen_time), parent_(parent)
82  {
83  }
84 
85  std::filesystem::path getRelativePath() const override
86  {
87  return KINEMATICS_FILE;
88  }
89 
90  std::string getDescription() const override
91  {
92  return "Specifies which kinematic solver plugin to use for each planning group in the SRDF, as well as "
93  "the kinematic solver search resolution.";
94  }
95 
96  bool hasChanges() const override
97  {
98  return parent_.changed_;
99  }
100 
101  bool writeYaml(YAML::Emitter& emitter) override;
102 
103  protected:
105  };
106 
107  void collectFiles(const std::filesystem::path& package_path, const GeneratedTime& last_gen_time,
108  std::vector<GeneratedFilePtr>& files) override
109  {
110  files.push_back(std::make_shared<GeneratedGroupMetaConfig>(package_path, last_gen_time, *this));
111  }
112 
113  void collectVariables(std::vector<TemplateVariable>& variables) override;
114 
115 protected:
116  // Helper method with old name that conveniently returns a bool
117  bool inputKinematicsYAML(const std::filesystem::path& file_path);
118 
120  std::map<std::string, GroupMetaData> group_meta_data_;
121 
123 
124  bool changed_{ false };
125 };
126 } // namespace srdf_setup
127 } // namespace moveit_setup
where all the data for each part of the configuration is stored.
Definition: config.hpp:58
std::filesystem::path getRelativePath() const override
Returns the path relative to the configuration package root.
std::string getDescription() const override
Returns an English description of this file's purpose.
GeneratedGroupMetaConfig(const std::filesystem::path &package_path, const GeneratedTime &last_gen_time, GroupMetaConfig &parent)
bool hasChanges() const override
Returns true if this file will have changes when it is written to file.
void setMetaData(const std::string &group_name, const GroupMetaData &meta_data)
bool inputKinematicsYAML(const std::filesystem::path &file_path)
const GroupMetaData & getMetaData(const std::string &group_name) const
std::map< std::string, GroupMetaData > group_meta_data_
Planning groups extra data not found in srdf but used in config files.
void collectVariables(std::vector< TemplateVariable > &variables) override
Collect key/value pairs for use in templates.
void loadPrevious(const std::filesystem::path &package_path, const YAML::Node &node) override
Loads the configuration from an existing MoveIt configuration.
void collectFiles(const std::filesystem::path &package_path, const GeneratedTime &last_gen_time, std::vector< GeneratedFilePtr > &files) override
Collect the files generated by this configuration and add them to the vector.
void renameGroup(const std::string &old_group_name, const std::string &new_group_name)
bool isConfigured() const override
Return true if this part of the configuration is completely set up.
void deleteGroup(const std::string &group_name)
std::filesystem::file_time_type GeneratedTime