moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
configuration_files.cpp
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
38
39namespace moveit_setup
40{
41namespace core
42{
47
49{
50 auto& variables = TemplatedGeneratedFile::variables;
51 variables.clear();
52 for (const auto& config : config_data_->getConfigured())
53 {
54 config->collectVariables(variables);
55 }
56}
57
59{
60 package_settings_->loadDependencies();
62 std::filesystem::path package_path = package_settings_->getPackagePath();
63 auto gen_time = package_settings_->getGenerationTime();
64
65 // Check if we are 'editing' a prev generated config pkg
66 if (package_path.empty())
67 {
68 return; // this is not configured yet
69 }
70
71 gen_files_.clear();
72
73 for (const auto& config : config_data_->getConfigured())
74 {
75 config->collectFiles(package_path, gen_time, gen_files_);
76 }
77}
78
80{
81 for (const auto& gen_file : gen_files_)
82 {
83 if (gen_file->getStatus() == status)
84 {
85 return true;
86 }
87 }
88 return false;
89}
90
91void ConfigurationFiles::setShouldGenerate(const std::string& rel_path, bool should_generate)
92{
93 should_generate_[rel_path] = should_generate;
94}
95
97{
98 // if the folder doesn't exist or is empty
99 std::filesystem::path package_path(getPackagePath());
100 return std::filesystem::is_directory(package_path) && !std::filesystem::is_empty(package_path);
101}
102
104{
105 if (!isExistingConfig())
106 {
107 return true;
108 }
109 return std::filesystem::is_regular_file(getPackagePath() / SETUP_ASSISTANT_FILE);
110}
111
112std::vector<std::string> ConfigurationFiles::getIncompleteWarnings() const
113{
114 // There may be a better way to generalize this, but for now, we add some manual checks of the srdf/author info
115 std::vector<std::string> warnings;
116
117 auto srdf_config = config_data_->get<SRDFConfig>("srdf");
118 // Check that at least 1 planning group exists
119 if (srdf_config->getGroups().empty())
120 {
121 warnings.push_back("No robot model planning groups have been created");
122 }
123
124 // Check that at least 1 link pair is disabled from collision checking
125 if (srdf_config->getDisabledCollisions().empty())
126 {
127 warnings.push_back("No self-collisions have been disabled");
128 }
129
130 // Check that there is at least 1 end effector added
131 if (srdf_config->getEndEffectors().empty())
132 {
133 warnings.push_back("No end effectors have been added");
134 }
135
136 // Check that there is at least 1 virtual joint added
137 if (srdf_config->getVirtualJoints().empty())
138 {
139 warnings.push_back("No virtual joints have been added");
140 }
141
142 // Check that there is a author name
143 if (!package_settings_->hasValidName())
144 {
145 warnings.push_back("<b>No author name added</b>");
146 }
147
148 // Check that email information is filled
149 if (!package_settings_->hasValidEmail())
150 {
151 warnings.push_back("<b>No valid email address added</b>");
152 }
153
154 return warnings;
155}
156
158{
159 auto srdf_config = config_data_->get<SRDFConfig>("srdf");
160 for (const auto& group : srdf_config->getGroups())
161 {
162 // Whenever 1 of the 4 component types are found, stop checking this group
163 if (!group.joints_.empty())
164 continue;
165 if (!group.links_.empty())
166 continue;
167 if (!group.chains_.empty())
168 continue;
169 if (!group.subgroups_.empty())
170 continue;
171 return group.name_;
172 }
173 return "";
174}
175
176} // namespace core
177} // namespace moveit_setup
void collectVariables(std::vector< TemplateVariable > &variables) override
Collect key/value pairs for use in templates.
DataWarehousePtr config_data_
static std::vector< TemplateVariable > variables
Definition templates.hpp:72
void loadFiles()
Populate the 'Files to be generated' list.
void setShouldGenerate(const std::string &rel_path, bool should_generate)
const std::filesystem::path & getPackagePath()
void onInit() override
Overridable initialization method.
std::vector< std::string > getIncompleteWarnings() const
std::unordered_map< std::string, bool > should_generate_
std::vector< GeneratedFilePtr > gen_files_
Vector of all files to be generated.
bool hasMatchingFileStatus(FileStatus status) const
std::shared_ptr< PackageSettingsConfig > package_settings_
FileStatus
Status associated with each GeneratedFile.