moveit2
The MoveIt Motion Planning Framework for ROS 2.
constant_features.hpp
Go to the documentation of this file.
1 // Copyright 2024 Intrinsic Innovation LLC.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
26 #pragma once
27 
28 #include <utility>
29 
31 
32 namespace moveit_ros
33 {
34 namespace trajectory_cache
35 {
36 
37 // Queries. ========================================================================================
38 
42 template <typename AppendT, typename FeatureSourceT>
43 class QueryOnlyEqFeature final : public FeaturesInterface<FeatureSourceT>
44 {
45 public:
46  QueryOnlyEqFeature(std::string name, AppendT value) : name_(std::move(name)), value_(value)
47  {
48  }
49 
50  std::string getName() const override
51  {
52  return "QueryOnlyEqFeature." + name_;
53  }
54 
56  appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& source,
58  double exact_match_precision) const override
59  {
60  return appendFeaturesAsExactFetchQuery(query, source, move_group, exact_match_precision);
61  }
62 
64  appendFeaturesAsExactFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& /*source*/,
66  double /*exact_match_precision*/) const override
67  {
68  query.append(name_, value_);
69  return moveit::core::MoveItErrorCode::SUCCESS;
70  }
71 
73  appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& /*metadata*/, const FeatureSourceT& /*source*/,
74  const moveit::planning_interface::MoveGroupInterface& /*move_group*/) const override
75  {
76  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
77  }
78 
79 private:
80  std::string name_;
81  AppendT value_;
82 };
83 
87 template <typename AppendT, typename FeatureSourceT>
88 class QueryOnlyLTEFeature final : public FeaturesInterface<FeatureSourceT>
89 {
90 public:
91  QueryOnlyLTEFeature(std::string name, AppendT value) : name_(std::move(name)), value_(value)
92  {
93  }
94 
95  std::string getName() const override
96  {
97  return "QueryOnlyLTEFeature." + name_;
98  }
99 
101  appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& source,
103  double exact_match_precision) const override
104  {
105  return appendFeaturesAsExactFetchQuery(query, source, move_group, exact_match_precision);
106  }
107 
109  appendFeaturesAsExactFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& /*source*/,
111  double /*exact_match_precision*/) const override
112  {
113  query.appendLTE(name_, value_);
114  return moveit::core::MoveItErrorCode::SUCCESS;
115  }
116 
118  appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& /*metadata*/, const FeatureSourceT& /*source*/,
119  const moveit::planning_interface::MoveGroupInterface& /*move_group*/) const override
120  {
121  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
122  }
123 
124 private:
125  std::string name_;
126  AppendT value_;
127 };
128 
132 template <typename AppendT, typename FeatureSourceT>
133 class QueryOnlyGTEFeature final : public FeaturesInterface<FeatureSourceT>
134 {
135 public:
136  QueryOnlyGTEFeature(std::string name, AppendT value) : name_(std::move(name)), value_(value)
137  {
138  }
139 
140  std::string getName() const override
141  {
142  return "QueryOnlyGTEFeature." + name_;
143  }
144 
146  appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& source,
148  double exact_match_precision) const override
149  {
150  return appendFeaturesAsExactFetchQuery(query, source, move_group, exact_match_precision);
151  }
152 
154  appendFeaturesAsExactFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& /*source*/,
156  double /*exact_match_precision*/) const override
157  {
158  query.appendGTE(name_, value_);
159  return moveit::core::MoveItErrorCode::SUCCESS;
160  }
161 
163  appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& /*metadata*/, const FeatureSourceT& /*source*/,
164  const moveit::planning_interface::MoveGroupInterface& /*move_group*/) const override
165  {
166  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
167  }
168 
169 private:
170  std::string name_;
171  AppendT value_;
172 };
173 
177 template <typename AppendT, typename FeatureSourceT>
179 {
180 public:
181  QueryOnlyRangeInclusiveWithToleranceFeature(std::string name, AppendT lower, AppendT upper)
182  : name_(std::move(name)), lower_(lower), upper_(upper)
183  {
184  }
185 
186  std::string getName() const override
187  {
188  return "QueryOnlyRangeInclusiveWithToleranceFeature." + name_;
189  }
190 
192  appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& source,
194  double exact_match_precision) const override
195  {
196  return appendFeaturesAsExactFetchQuery(query, source, move_group, exact_match_precision);
197  }
198 
200  appendFeaturesAsExactFetchQuery(warehouse_ros::Query& query, const FeatureSourceT& /*source*/,
202  double /*exact_match_precision*/) const override
203  {
204  query.appendRangeInclusive(name_, lower_, upper_);
205  return moveit::core::MoveItErrorCode::SUCCESS;
206  }
207 
209  appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& /*metadata*/, const FeatureSourceT& /*source*/,
210  const moveit::planning_interface::MoveGroupInterface& /*move_group*/) const override
211  {
212  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
213  }
214 
215 private:
216  std::string name_;
217  AppendT lower_;
218  AppendT upper_;
219 };
220 
221 // Metadata. =======================================================================================
222 
226 template <typename AppendT, typename FeatureSourceT>
227 class MetadataOnlyFeature final : public FeaturesInterface<FeatureSourceT>
228 {
229 public:
230  MetadataOnlyFeature(std::string name, AppendT value) : name_(std::move(name)), value_(value)
231  {
232  }
233 
234  std::string getName() const override
235  {
236  return "MetadataOnlyFeature." + name_;
237  }
238 
240  appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query& /*query*/, const FeatureSourceT& /*source*/,
242  double /*exact_match_precision*/) const override
243  {
244  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
245  }
246 
248  appendFeaturesAsExactFetchQuery(warehouse_ros::Query& /*query*/, const FeatureSourceT& /*source*/,
250  double /*exact_match_precision*/) const override
251  {
252  return moveit::core::MoveItErrorCode::SUCCESS; // No-op.
253  }
254 
256  appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, const FeatureSourceT& /*source*/,
257  const moveit::planning_interface::MoveGroupInterface& /*move_group*/) const override
258  {
259  metadata.append(name_, value_);
260  return moveit::core::MoveItErrorCode::SUCCESS;
261  }
262 
263 private:
264  std::string name_;
265  AppendT value_;
266 };
267 
268 } // namespace trajectory_cache
269 } // namespace moveit_ros
a wrapper around moveit_msgs::MoveItErrorCodes to make it easier to return an error code message from...
Client class to conveniently use the ROS interfaces provided by the move_group node.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &metadata, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
MetadataOnlyFeature(std::string name, AppendT value)
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with fuzzy matching.
std::string getName() const override
Gets the name of the features implementation.
QueryOnlyEqFeature(std::string name, AppendT value)
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &source, const moveit::planning_interface::MoveGroupInterface &move_group, double exact_match_precision) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with fuzzy matching.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with exact matching.
std::string getName() const override
Gets the name of the features implementation.
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
QueryOnlyGTEFeature(std::string name, AppendT value)
std::string getName() const override
Gets the name of the features implementation.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &source, const moveit::planning_interface::MoveGroupInterface &move_group, double exact_match_precision) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with fuzzy matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &source, const moveit::planning_interface::MoveGroupInterface &move_group, double exact_match_precision) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with fuzzy matching.
std::string getName() const override
Gets the name of the features implementation.
QueryOnlyLTEFeature(std::string name, AppendT value)
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
QueryOnlyRangeInclusiveWithToleranceFeature(std::string name, AppendT lower, AppendT upper)
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &, double) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &, const FeatureSourceT &, const moveit::planning_interface::MoveGroupInterface &) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const FeatureSourceT &source, const moveit::planning_interface::MoveGroupInterface &move_group, double exact_match_precision) const override
Extracts relevant features from FeatureSourceT, to be appended to a fetch query, with fuzzy matching.
std::string getName() const override
Gets the name of the features implementation.
Abstract template class for extracting features from some FeatureSourceT.
name
Definition: setup.py:7