21#include <gtest/gtest.h>
22#include <warehouse_ros/message_collection.h>
24#include <geometry_msgs/msg/point.hpp>
28#include "../fixtures/move_group_fixture.hpp"
33using ::geometry_msgs::msg::Point;
35using ::warehouse_ros::MessageCollection;
36using ::warehouse_ros::Metadata;
37using ::warehouse_ros::Query;
39using ::moveit_ros::trajectory_cache::QueryOnlyEqFeature;
40using ::moveit_ros::trajectory_cache::QueryOnlyGTEFeature;
41using ::moveit_ros::trajectory_cache::QueryOnlyLTEFeature;
42using ::moveit_ros::trajectory_cache::QueryOnlyRangeInclusiveWithToleranceFeature;
44using ::moveit_ros::trajectory_cache::MetadataOnlyFeature;
48 MessageCollection<Point> coll = db_->openCollection<Point>(
"test_db",
"test_collection");
50 Query::Ptr query = coll.createQuery();
51 Metadata::Ptr metadata = coll.createMetadata();
52 ASSERT_EQ(metadata->lookupFieldNames().size(), 0);
58 MetadataOnlyFeature<std::string, Point> string_metadata_feature(
"string_metadata",
"test_string");
59 MetadataOnlyFeature<double, Point> double_metadata_feature(
"double_metadata", 1.0);
60 MetadataOnlyFeature<int, Point> int_metadata_feature(
"int_metadata", 2);
61 MetadataOnlyFeature<bool, Point> bool_metadata_feature(
"bool_metadata",
true);
64 EXPECT_EQ(string_metadata_feature.getName(),
"MetadataOnlyFeature.string_metadata");
65 EXPECT_EQ(double_metadata_feature.getName(),
"MetadataOnlyFeature.double_metadata");
66 EXPECT_EQ(int_metadata_feature.getName(),
"MetadataOnlyFeature.int_metadata");
67 EXPECT_EQ(bool_metadata_feature.getName(),
"MetadataOnlyFeature.bool_metadata");
70 EXPECT_EQ(string_metadata_feature.appendFeaturesAsFuzzyFetchQuery(*query, msg, *move_group_, 0.0),
71 moveit::core::MoveItErrorCode::SUCCESS);
72 EXPECT_EQ(string_metadata_feature.appendFeaturesAsExactFetchQuery(*query, msg, *move_group_, 0.0),
73 moveit::core::MoveItErrorCode::SUCCESS);
76 string_metadata_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
77 EXPECT_EQ(metadata->lookupFieldNames().size(), 1);
78 EXPECT_TRUE(metadata->lookupField(
"string_metadata"));
79 EXPECT_EQ(metadata->lookupString(
"string_metadata"),
"test_string");
81 double_metadata_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
82 EXPECT_EQ(metadata->lookupFieldNames().size(), 2);
83 EXPECT_TRUE(metadata->lookupField(
"double_metadata"));
84 EXPECT_EQ(metadata->lookupDouble(
"double_metadata"), 1.0);
86 int_metadata_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
87 EXPECT_EQ(metadata->lookupFieldNames().size(), 3);
88 EXPECT_TRUE(metadata->lookupField(
"int_metadata"));
89 EXPECT_EQ(metadata->lookupInt(
"int_metadata"), 2);
91 bool_metadata_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
92 EXPECT_EQ(metadata->lookupFieldNames().size(), 4);
93 EXPECT_TRUE(metadata->lookupField(
"bool_metadata"));
94 EXPECT_TRUE(metadata->lookupBool(
"bool_metadata"));
99 MessageCollection<Point> coll = db_->openCollection<Point>(
"test_db",
"test_collection");
101 Metadata::Ptr metadata = coll.createMetadata();
102 metadata->append(
"test_metadata",
"test_metadata");
105 coll.insert(msg, metadata);
107 QueryOnlyEqFeature<std::string, Point> eq_feature(
"test_metadata",
"test_metadata");
108 QueryOnlyEqFeature<std::string, Point> unrelated_eq_feature(
"unrelated",
"test_metadata");
109 QueryOnlyEqFeature<std::string, Point> mismatched_eq_feature(
"test_metadata",
"mismatched");
112 EXPECT_EQ(eq_feature.getName(),
"QueryOnlyEqFeature.test_metadata");
113 EXPECT_EQ(unrelated_eq_feature.getName(),
"QueryOnlyEqFeature.unrelated");
117 Metadata::Ptr noop_metadata = coll.createMetadata();
118 eq_feature.appendFeaturesAsInsertMetadata(*noop_metadata, msg, *move_group_);
119 EXPECT_TRUE(noop_metadata->lookupFieldNames().empty());
124 Query::Ptr fuzzy_query = coll.createQuery();
125 eq_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
126 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
128 Query::Ptr exact_query = coll.createQuery();
129 eq_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
130 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
135 Query::Ptr fuzzy_query = coll.createQuery();
136 unrelated_eq_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
137 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
139 Query::Ptr exact_query = coll.createQuery();
140 unrelated_eq_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
141 EXPECT_TRUE(coll.queryList(exact_query).empty());
146 Query::Ptr fuzzy_query = coll.createQuery();
147 mismatched_eq_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
148 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
150 Query::Ptr exact_query = coll.createQuery();
151 mismatched_eq_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
152 EXPECT_TRUE(coll.queryList(exact_query).empty());
158 MessageCollection<Point> coll = db_->openCollection<Point>(
"test_db",
"test_collection");
160 Metadata::Ptr metadata = coll.createMetadata();
161 metadata->append(
"test_metadata", 5.0);
164 coll.insert(msg, metadata);
166 metadata = coll.createMetadata();
167 metadata->append(
"unrelated", 5.0);
168 coll.insert(msg, metadata);
170 QueryOnlyGTEFeature<double, Point> gte_feature(
"test_metadata", 4.0);
171 QueryOnlyGTEFeature<double, Point> gte_eq_feature(
"test_metadata", 5.0);
172 QueryOnlyGTEFeature<double, Point> unrelated_gte_feature(
"unrelated", 6.0);
173 QueryOnlyGTEFeature<double, Point> mismatched_gte_feature(
"test_metadata", 6.0);
176 EXPECT_EQ(gte_feature.getName(),
"QueryOnlyGTEFeature.test_metadata");
177 EXPECT_EQ(unrelated_gte_feature.getName(),
"QueryOnlyGTEFeature.unrelated");
181 Metadata::Ptr metadata = coll.createMetadata();
182 gte_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
183 EXPECT_TRUE(metadata->lookupFieldNames().empty());
188 Query::Ptr fuzzy_query = coll.createQuery();
189 gte_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
190 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
192 Query::Ptr exact_query = coll.createQuery();
193 gte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
194 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
198 Query::Ptr fuzzy_query = coll.createQuery();
199 gte_eq_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
200 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
202 Query::Ptr exact_query = coll.createQuery();
203 gte_eq_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
204 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
209 Query::Ptr unrelated_fuzzy_query = coll.createQuery();
210 unrelated_gte_feature.appendFeaturesAsFuzzyFetchQuery(*unrelated_fuzzy_query, msg, *move_group_, 0.0);
211 EXPECT_TRUE(coll.queryList(unrelated_fuzzy_query).empty());
213 Query::Ptr exact_query = coll.createQuery();
214 unrelated_gte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
215 EXPECT_TRUE(coll.queryList(exact_query).empty());
220 Query::Ptr fuzzy_query = coll.createQuery();
221 mismatched_gte_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
222 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
224 Query::Ptr exact_query = coll.createQuery();
225 mismatched_gte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
226 EXPECT_TRUE(coll.queryList(exact_query).empty());
232 MessageCollection<Point> coll = db_->openCollection<Point>(
"test_db",
"test_collection");
234 Metadata::Ptr metadata = coll.createMetadata();
235 metadata->append(
"test_metadata", 5.0);
238 coll.insert(msg, metadata);
240 QueryOnlyLTEFeature<double, Point> lte_feature(
"test_metadata", 6.0);
241 QueryOnlyLTEFeature<double, Point> lte_eq_feature(
"test_metadata", 5.0);
242 QueryOnlyLTEFeature<double, Point> unrelated_lte_feature(
"unrelated", 6.0);
243 QueryOnlyLTEFeature<double, Point> mismatched_lte_feature(
"test_metadata", 4.0);
246 EXPECT_EQ(lte_feature.getName(),
"QueryOnlyLTEFeature.test_metadata");
247 EXPECT_EQ(unrelated_lte_feature.getName(),
"QueryOnlyLTEFeature.unrelated");
251 Metadata::Ptr metadata = coll.createMetadata();
252 lte_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
253 EXPECT_TRUE(metadata->lookupFieldNames().empty());
258 Query::Ptr fuzzy_query = coll.createQuery();
259 lte_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
260 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
262 Query::Ptr exact_query = coll.createQuery();
263 lte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
264 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
268 Query::Ptr fuzzy_query = coll.createQuery();
269 lte_eq_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
270 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
272 Query::Ptr exact_query = coll.createQuery();
273 lte_eq_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
274 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
279 Query::Ptr fuzzy_query = coll.createQuery();
280 unrelated_lte_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
281 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
283 Query::Ptr exact_query = coll.createQuery();
284 unrelated_lte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
285 EXPECT_TRUE(coll.queryList(exact_query).empty());
290 Query::Ptr fuzzy_query = coll.createQuery();
291 mismatched_lte_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
292 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
294 Query::Ptr exact_query = coll.createQuery();
295 mismatched_lte_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
296 EXPECT_TRUE(coll.queryList(exact_query).empty());
302 MessageCollection<Point> coll = db_->openCollection<Point>(
"test_db",
"test_collection");
304 Metadata::Ptr metadata = coll.createMetadata();
305 metadata->append(
"test_metadata", 5.0);
308 coll.insert(msg, metadata);
310 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> exact_range_feature(
"test_metadata", 5.0, 5.0);
311 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> lower_range_feature(
"test_metadata", 4.0, 5.0);
312 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> upper_range_feature(
"test_metadata", 5.0, 6.0);
313 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> over_range_feature(
"test_metadata", 4.5, 5.5);
315 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> unrelated_range_feature(
"unrelated", 5.5, 6.0);
316 QueryOnlyRangeInclusiveWithToleranceFeature<double, Point> mismatched_range_feature(
"test_metadata", 5.5, 6.0);
319 EXPECT_EQ(exact_range_feature.getName(),
"QueryOnlyRangeInclusiveWithToleranceFeature.test_metadata");
320 EXPECT_EQ(unrelated_range_feature.getName(),
"QueryOnlyRangeInclusiveWithToleranceFeature.unrelated");
324 Metadata::Ptr metadata = coll.createMetadata();
325 exact_range_feature.appendFeaturesAsInsertMetadata(*metadata, msg, *move_group_);
326 EXPECT_TRUE(metadata->lookupFieldNames().empty());
331 Query::Ptr fuzzy_query = coll.createQuery();
332 exact_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
333 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
335 Query::Ptr exact_query = coll.createQuery();
336 exact_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
337 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
341 Query::Ptr fuzzy_query = coll.createQuery();
342 lower_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
343 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
345 Query::Ptr exact_query = coll.createQuery();
346 lower_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
347 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
351 Query::Ptr fuzzy_query = coll.createQuery();
352 upper_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
353 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
355 Query::Ptr exact_query = coll.createQuery();
356 upper_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
357 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
361 Query::Ptr fuzzy_query = coll.createQuery();
362 over_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
363 EXPECT_EQ(coll.queryList(fuzzy_query).size(), 1);
365 Query::Ptr exact_query = coll.createQuery();
366 over_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
367 EXPECT_EQ(coll.queryList(exact_query).size(), 1);
372 Query::Ptr fuzzy_query = coll.createQuery();
373 unrelated_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
374 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
376 Query::Ptr exact_query = coll.createQuery();
377 unrelated_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
378 EXPECT_TRUE(coll.queryList(exact_query).empty());
383 Query::Ptr fuzzy_query = coll.createQuery();
384 mismatched_range_feature.appendFeaturesAsFuzzyFetchQuery(*fuzzy_query, msg, *move_group_, 0.0);
385 EXPECT_TRUE(coll.queryList(fuzzy_query).empty());
387 Query::Ptr exact_query = coll.createQuery();
388 mismatched_range_feature.appendFeaturesAsExactFetchQuery(*exact_query, msg, *move_group_, 0.0);
389 EXPECT_TRUE(coll.queryList(exact_query).empty());
397 rclcpp::init(argc, argv);
398 ::testing::InitGoogleTest(&argc, argv);
399 int result = RUN_ALL_TESTS();
Test fixture to spin up a node to start a move group with.
User-specified constant features to key the trajectory cache on.
TEST_F(BulletCollisionDetectionTester, DISABLED_ContinuousCollisionSelf)
Continuous self collision checks are not supported yet by the bullet integration.
int main(int argc, char **argv)