moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
trajectory_cache.cpp
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
19
20#include <chrono>
21#include <cstdint>
22#include <memory>
23#include <vector>
24
25#include <rclcpp/rclcpp.hpp>
26#include <rclcpp/logging.hpp>
27
28#include <warehouse_ros/message_collection.h>
29#include <warehouse_ros/database_connection.h>
30
31#include <geometry_msgs/msg/pose.hpp>
32#include <geometry_msgs/msg/pose_stamped.hpp>
33
34#include <moveit_msgs/msg/motion_plan_request.hpp>
35#include <moveit_msgs/msg/robot_trajectory.hpp>
36#include <moveit_msgs/srv/get_cartesian_path.hpp>
37
44
45// Cache insert policies.
48
49// Features.
54
56
57namespace moveit_ros
58{
59namespace trajectory_cache
60{
61
62using ::warehouse_ros::MessageCollection;
63using ::warehouse_ros::MessageWithMetadata;
64using ::warehouse_ros::Metadata;
65using ::warehouse_ros::Query;
66
67using ::moveit::core::MoveItErrorCode;
68using ::moveit::planning_interface::MoveGroupInterface;
69
70using ::moveit_msgs::msg::MotionPlanRequest;
71using ::moveit_msgs::msg::RobotTrajectory;
72using ::moveit_msgs::srv::GetCartesianPath;
73
74using ::moveit_ros::trajectory_cache::BestSeenExecutionTimePolicy;
75using ::moveit_ros::trajectory_cache::CacheInsertPolicyInterface;
76using ::moveit_ros::trajectory_cache::CartesianBestSeenExecutionTimePolicy;
77
78using ::moveit_ros::trajectory_cache::FeaturesInterface;
79
80namespace
81{
82
83const std::string EXECUTION_TIME = "execution_time_s";
84
85} // namespace
86
87// =================================================================================================
88// Default Behavior Helpers.
89// =================================================================================================
90
91std::vector<std::unique_ptr<FeaturesInterface<MotionPlanRequest>>>
92TrajectoryCache::getDefaultFeatures(double start_tolerance, double goal_tolerance)
93{
94 return BestSeenExecutionTimePolicy::getSupportedFeatures(start_tolerance, goal_tolerance);
95}
96
97std::unique_ptr<CacheInsertPolicyInterface<MotionPlanRequest, MoveGroupInterface::Plan, RobotTrajectory>>
99{
100 return std::make_unique<BestSeenExecutionTimePolicy>();
101}
102
103std::vector<std::unique_ptr<FeaturesInterface<GetCartesianPath::Request>>>
104TrajectoryCache::getDefaultCartesianFeatures(double start_tolerance, double goal_tolerance, double min_fraction)
105{
106 return CartesianBestSeenExecutionTimePolicy::getSupportedFeatures(start_tolerance, goal_tolerance, min_fraction);
107}
108
109std::unique_ptr<CacheInsertPolicyInterface<GetCartesianPath::Request, GetCartesianPath::Response, RobotTrajectory>>
111{
112 return std::make_unique<CartesianBestSeenExecutionTimePolicy>();
113}
114
116{
117 return EXECUTION_TIME;
118}
119
120// =================================================================================================
121// Cache Configuration.
122// =================================================================================================
123
124TrajectoryCache::TrajectoryCache(const rclcpp::Node::SharedPtr& node)
125 : node_(node), logger_(moveit::getLogger("moveit.ros.trajectory_cache"))
126{
127}
128
130{
131 RCLCPP_DEBUG(logger_, "Opening trajectory cache database at: %s (Port: %d, Precision: %f)", options.db_path.c_str(),
132 options.db_port, options.exact_match_precision);
133
134 // If the `warehouse_plugin` parameter isn't set, defaults to warehouse_ros'
135 // default.
137 options_ = options;
138
139 db_->setParams(options.db_path, options.db_port);
140 return db_->connect();
141}
142
143// =================================================================================================
144// Getters and Setters.
145// =================================================================================================
146
147unsigned TrajectoryCache::countTrajectories(const std::string& cache_namespace)
148{
149 MessageCollection<RobotTrajectory> coll =
150 db_->openCollection<RobotTrajectory>("move_group_trajectory_cache", cache_namespace);
151 return coll.count();
152}
153
154unsigned TrajectoryCache::countCartesianTrajectories(const std::string& cache_namespace)
155{
156 MessageCollection<RobotTrajectory> coll =
157 db_->openCollection<RobotTrajectory>("move_group_cartesian_trajectory_cache", cache_namespace);
158 return coll.count();
159}
160
161std::string TrajectoryCache::getDbPath() const
162{
163 return options_.db_path;
164}
165
167{
168 return options_.db_port;
169}
170
172{
173 return options_.exact_match_precision;
174}
175
176void TrajectoryCache::setExactMatchPrecision(double exact_match_precision)
177{
178 options_.exact_match_precision = exact_match_precision;
179}
180
182{
183 return options_.num_additional_trajectories_to_preserve_when_pruning_worse;
184}
185
187 size_t num_additional_trajectories_to_preserve_when_pruning_worse)
188{
189 options_.num_additional_trajectories_to_preserve_when_pruning_worse =
190 num_additional_trajectories_to_preserve_when_pruning_worse;
191}
192
193// =================================================================================================
194// Motion Plan Trajectory Caching.
195// =================================================================================================
196
197std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> TrajectoryCache::fetchAllMatchingTrajectories(
198 const MoveGroupInterface& move_group, const std::string& cache_namespace, const MotionPlanRequest& plan_request,
199 const std::vector<std::unique_ptr<FeaturesInterface<MotionPlanRequest>>>& features, const std::string& sort_by,
200 bool ascending, bool metadata_only) const
201{
202 MessageCollection<RobotTrajectory> coll =
203 db_->openCollection<RobotTrajectory>("move_group_trajectory_cache", cache_namespace);
204
205 Query::Ptr query = coll.createQuery();
206 for (const auto& feature : features)
207 {
208 if (MoveItErrorCode ret =
209 feature->appendFeaturesAsFuzzyFetchQuery(*query, plan_request, move_group,
210 /*exact_match_precision=*/options_.exact_match_precision);
211 !ret)
212 {
213 RCLCPP_ERROR_STREAM(logger_, "Could not construct trajectory query: " << ret.message);
214 return {};
215 }
216 }
217 return coll.queryList(query, metadata_only, sort_by, ascending);
218}
219
220MessageWithMetadata<RobotTrajectory>::ConstPtr TrajectoryCache::fetchBestMatchingTrajectory(
221 const MoveGroupInterface& move_group, const std::string& cache_namespace, const MotionPlanRequest& plan_request,
222 const std::vector<std::unique_ptr<FeaturesInterface<MotionPlanRequest>>>& features, const std::string& sort_by,
223 bool ascending, bool metadata_only) const
224{
225 // Find all matching, with metadata only. We'll use the ID of the best trajectory to pull it.
226 std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> matching_trajectories =
227 this->fetchAllMatchingTrajectories(move_group, cache_namespace, plan_request, features, sort_by, ascending,
228 /*metadata_only=*/true);
229 if (matching_trajectories.empty())
230 {
231 RCLCPP_DEBUG(logger_, "No matching trajectories found.");
232 return nullptr;
233 }
234
235 MessageCollection<RobotTrajectory> coll =
236 db_->openCollection<RobotTrajectory>("move_group_trajectory_cache", cache_namespace);
237
238 // Best trajectory is at first index, since the lookup query was sorted.
239 int best_trajectory_id = matching_trajectories.at(0)->lookupInt("id");
240 Query::Ptr best_query = coll.createQuery();
241 best_query->append("id", best_trajectory_id);
242
243 return coll.findOne(best_query, metadata_only);
244}
245
247 const MoveGroupInterface& move_group, const std::string& cache_namespace, const MotionPlanRequest& plan_request,
248 const MoveGroupInterface::Plan& plan,
250 bool prune_worse_trajectories,
251 const std::vector<std::unique_ptr<FeaturesInterface<MotionPlanRequest>>>& additional_features)
252{
253 MessageCollection<RobotTrajectory> coll =
254 db_->openCollection<RobotTrajectory>("move_group_trajectory_cache", cache_namespace);
255
256 // Check pre-preconditions.
257 if (MoveItErrorCode ret = cache_insert_policy.checkCacheInsertInputs(move_group, coll, plan_request, plan); !ret)
258 {
259 RCLCPP_ERROR_STREAM(logger_, "Skipping trajectory insert, invalid inputs: " << ret.message);
260 cache_insert_policy.reset();
261 return false;
262 }
263
264 std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> matching_entries =
265 cache_insert_policy.fetchMatchingEntries(move_group, coll, plan_request, plan, options_.exact_match_precision);
266
267 // Prune.
268 if (prune_worse_trajectories)
269 {
270 size_t preserved_count = 0;
271 for (const auto& matching_entry : matching_entries)
272 {
273 std::string prune_reason;
274 if (++preserved_count > options_.num_additional_trajectories_to_preserve_when_pruning_worse &&
275 cache_insert_policy.shouldPruneMatchingEntry(move_group, plan_request, plan, matching_entry, &prune_reason))
276 {
277 int delete_id = matching_entry->lookupInt("id");
278 RCLCPP_DEBUG_STREAM(logger_, "Pruning plan (id: `" << delete_id << "`): " << prune_reason);
279
280 Query::Ptr delete_query = coll.createQuery();
281 delete_query->append("id", delete_id);
282 coll.removeMessages(delete_query);
283 }
284 }
285 }
286
287 // Insert.
288 std::string insert_reason;
289 if (cache_insert_policy.shouldInsert(move_group, plan_request, plan, &insert_reason))
290 {
291 Metadata::Ptr insert_metadata = coll.createMetadata();
292
293 if (MoveItErrorCode ret = cache_insert_policy.appendInsertMetadata(*insert_metadata, move_group, plan_request, plan);
294 !ret)
295 {
296 RCLCPP_ERROR_STREAM(logger_,
297 "Skipping trajectory insert: Could not construct insert metadata from cache_insert_policy: "
298 << cache_insert_policy.getName() << ": " << ret.message);
299 cache_insert_policy.reset();
300 return false;
301 }
302
303 for (const auto& additional_feature : additional_features)
304 {
305 if (MoveItErrorCode ret =
306 additional_feature->appendFeaturesAsInsertMetadata(*insert_metadata, plan_request, move_group);
307 !ret)
308 {
309 RCLCPP_ERROR_STREAM(logger_,
310 "Skipping trajectory insert: Could not construct insert metadata additional_feature: "
311 << additional_feature->getName() << ": " << ret.message);
312 cache_insert_policy.reset();
313 return false;
314 }
315 }
316
317 RCLCPP_DEBUG_STREAM(logger_, "Inserting trajectory:" << insert_reason);
318 coll.insert(plan.trajectory, insert_metadata);
319 cache_insert_policy.reset();
320 return true;
321 }
322 else
323 {
324 RCLCPP_DEBUG_STREAM(logger_, "Skipping trajectory insert:" << insert_reason);
325 cache_insert_policy.reset();
326 return false;
327 }
328}
329
330// =================================================================================================
331// Cartesian Trajectory Caching.
332// =================================================================================================
333
334std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> TrajectoryCache::fetchAllMatchingCartesianTrajectories(
335 const MoveGroupInterface& move_group, const std::string& cache_namespace,
336 const GetCartesianPath::Request& plan_request,
337 const std::vector<std::unique_ptr<FeaturesInterface<GetCartesianPath::Request>>>& features,
338 const std::string& sort_by, bool ascending, bool metadata_only) const
339{
340 MessageCollection<RobotTrajectory> coll =
341 db_->openCollection<RobotTrajectory>("move_group_cartesian_trajectory_cache", cache_namespace);
342
343 Query::Ptr query = coll.createQuery();
344 for (const auto& feature : features)
345 {
346 if (MoveItErrorCode ret =
347 feature->appendFeaturesAsFuzzyFetchQuery(*query, plan_request, move_group,
348 /*exact_match_precision=*/options_.exact_match_precision);
349 !ret)
350 {
351 RCLCPP_ERROR_STREAM(logger_, "Could not construct cartesian trajectory query: " << ret.message);
352 return {};
353 }
354 }
355 return coll.queryList(query, metadata_only, sort_by, ascending);
356}
357
358MessageWithMetadata<RobotTrajectory>::ConstPtr TrajectoryCache::fetchBestMatchingCartesianTrajectory(
359 const MoveGroupInterface& move_group, const std::string& cache_namespace,
360 const GetCartesianPath::Request& plan_request,
361 const std::vector<std::unique_ptr<FeaturesInterface<GetCartesianPath::Request>>>& features,
362 const std::string& sort_by, bool ascending, bool metadata_only) const
363{
364 // Find all matching, with metadata only. We'll use the ID of the best trajectory to pull it.
365 std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> matching_trajectories =
366 this->fetchAllMatchingCartesianTrajectories(move_group, cache_namespace, plan_request, features, sort_by,
367 ascending, /*metadata_only=*/true);
368 if (matching_trajectories.empty())
369 {
370 RCLCPP_DEBUG(logger_, "No matching cartesian trajectories found.");
371 return nullptr;
372 }
373
374 MessageCollection<RobotTrajectory> coll =
375 db_->openCollection<RobotTrajectory>("move_group_cartesian_trajectory_cache", cache_namespace);
376
377 // Best trajectory is at first index, since the lookup query was sorted.
378 int best_trajectory_id = matching_trajectories.at(0)->lookupInt("id");
379 Query::Ptr best_query = coll.createQuery();
380 best_query->append("id", best_trajectory_id);
381
382 return coll.findOne(best_query, metadata_only);
383}
384
386 const MoveGroupInterface& move_group, const std::string& cache_namespace,
387 const GetCartesianPath::Request& plan_request, const GetCartesianPath::Response& plan,
389 cache_insert_policy,
390 bool prune_worse_trajectories,
391 const std::vector<std::unique_ptr<FeaturesInterface<GetCartesianPath::Request>>>& additional_features)
392{
393 MessageCollection<RobotTrajectory> coll =
394 db_->openCollection<RobotTrajectory>("move_group_cartesian_trajectory_cache", cache_namespace);
395
396 // Check pre-preconditions.
397 if (MoveItErrorCode ret = cache_insert_policy.checkCacheInsertInputs(move_group, coll, plan_request, plan); !ret)
398 {
399 RCLCPP_ERROR_STREAM(logger_, "Skipping cartesian trajectory insert, invalid inputs: " << ret.message);
400 cache_insert_policy.reset();
401 return false;
402 }
403
404 std::vector<MessageWithMetadata<RobotTrajectory>::ConstPtr> matching_entries =
405 cache_insert_policy.fetchMatchingEntries(move_group, coll, plan_request, plan, options_.exact_match_precision);
406
407 // Prune.
408 if (prune_worse_trajectories)
409 {
410 size_t preserved_count = 0;
411 for (const auto& matching_entry : matching_entries)
412 {
413 std::string prune_reason;
414 if (++preserved_count > options_.num_additional_trajectories_to_preserve_when_pruning_worse &&
415 cache_insert_policy.shouldPruneMatchingEntry(move_group, plan_request, plan, matching_entry, &prune_reason))
416 {
417 int delete_id = matching_entry->lookupInt("id");
418 RCLCPP_DEBUG_STREAM(logger_, "Pruning cartesian trajectory (id: `" << delete_id << "`): " << prune_reason);
419
420 Query::Ptr delete_query = coll.createQuery();
421 delete_query->append("id", delete_id);
422 coll.removeMessages(delete_query);
423 }
424 }
425 }
426
427 // Insert.
428 std::string insert_reason;
429 if (cache_insert_policy.shouldInsert(move_group, plan_request, plan, &insert_reason))
430 {
431 Metadata::Ptr insert_metadata = coll.createMetadata();
432
433 if (MoveItErrorCode ret = cache_insert_policy.appendInsertMetadata(*insert_metadata, move_group, plan_request, plan);
434 !ret)
435 {
436 RCLCPP_ERROR_STREAM(logger_, "Skipping cartesian trajectory insert: Could not construct insert metadata from "
437 "cache_insert_policy: "
438 << cache_insert_policy.getName() << ": " << ret.message);
439 cache_insert_policy.reset();
440 return false;
441 }
442
443 for (const auto& additional_feature : additional_features)
444 {
445 if (MoveItErrorCode ret =
446 additional_feature->appendFeaturesAsInsertMetadata(*insert_metadata, plan_request, move_group);
447 !ret)
448 {
449 RCLCPP_ERROR_STREAM(
450 logger_, "Skipping cartesian trajectory insert: Could not construct insert metadata additional_feature: "
451 << additional_feature->getName() << ": " << ret.message);
452 cache_insert_policy.reset();
453 return false;
454 }
455 }
456
457 RCLCPP_DEBUG_STREAM(logger_, "Inserting cartesian trajectory:" << insert_reason);
458 coll.insert(plan.solution, insert_metadata);
459 cache_insert_policy.reset();
460 return true;
461 }
462 else
463 {
464 RCLCPP_DEBUG_STREAM(logger_, "Skipping cartesian insert:" << insert_reason);
465 cache_insert_policy.reset();
466 return false;
467 }
468}
469
470} // namespace trajectory_cache
471} // namespace moveit_ros
A cache insertion policy that only decides to insert if the motion plan is the one with the shortest ...
Abstract template class for injecting logic for determining when to prune and insert a cache entry,...
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.
static std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::msg::MotionPlanRequest > > > getSupportedFeatures(double start_tolerance, double goal_tolerance)
Configures and returns a vector of feature extractors that can be used with this policy.
virtual bool shouldInsert(const moveit::planning_interface::MoveGroupInterface &move_group, const KeyT &key, const ValueT &value, std::string *reason)=0
Returns whether the insertion candidate should be inserted into the cache.
virtual bool shouldPruneMatchingEntry(const moveit::planning_interface::MoveGroupInterface &move_group, const KeyT &key, const ValueT &value, const typename warehouse_ros::MessageWithMetadata< CacheEntryT >::ConstPtr &matching_entry, std::string *reason)=0
Returns whether a matched cache entry should be pruned.
virtual moveit::core::MoveItErrorCode appendInsertMetadata(warehouse_ros::Metadata &metadata, const moveit::planning_interface::MoveGroupInterface &move_group, const KeyT &key, const ValueT &value)=0
Appends the insert metadata with the features supported by the policy.
virtual void reset()=0
Resets the state of the policy.
virtual std::vector< typename warehouse_ros::MessageWithMetadata< CacheEntryT >::ConstPtr > fetchMatchingEntries(const moveit::planning_interface::MoveGroupInterface &move_group, const warehouse_ros::MessageCollection< CacheEntryT > &coll, const KeyT &key, const ValueT &value, double exact_match_precision)=0
Fetches all "matching" cache entries for comparison for pruning.
virtual std::string getName() const =0
Gets the name of the cache insert policy.
virtual moveit::core::MoveItErrorCode checkCacheInsertInputs(const moveit::planning_interface::MoveGroupInterface &move_group, const warehouse_ros::MessageCollection< CacheEntryT > &coll, const KeyT &key, const ValueT &value)=0
Checks inputs to the cache insert call to see if we should abort instead.
static std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::srv::GetCartesianPath::Request > > > getSupportedFeatures(double start_tolerance, double goal_tolerance, double min_fraction)
Configures and returns a vector of feature extractors that can be used with this policy.
unsigned countCartesianTrajectories(const std::string &cache_namespace)
Count the number of cartesian trajectories for a particular cache namespace.
static std::unique_ptr< CacheInsertPolicyInterface< moveit_msgs::msg::MotionPlanRequest, moveit::planning_interface::MoveGroupInterface::Plan, moveit_msgs::msg::RobotTrajectory > > getDefaultCacheInsertPolicy()
Gets the default cache insert policy for MotionPlanRequest messages.
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::RobotTrajectory >::ConstPtr fetchBestMatchingTrajectory(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::msg::MotionPlanRequest &plan_request, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::msg::MotionPlanRequest > > > &features, const std::string &sort_by, bool ascending=true, bool metadata_only=false) const
Fetches the best trajectory keyed on user-specified features, with respect to some cache feature.
size_t getNumAdditionalTrajectoriesToPreserveWhenPruningWorse() const
Get the number of trajectories to preserve when pruning worse trajectories.
unsigned countTrajectories(const std::string &cache_namespace)
Count the number of non-cartesian trajectories for a particular cache namespace.
static std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::srv::GetCartesianPath::Request > > > getDefaultCartesianFeatures(double start_tolerance, double goal_tolerance, double min_fraction)
Gets the default features for GetCartesianPath requests.
TrajectoryCache(const rclcpp::Node::SharedPtr &node)
Constructs a TrajectoryCache.
static std::string getDefaultSortFeature()
Gets the default sort feature.
double getExactMatchPrecision() const
Gets the exact match precision.
std::vector< warehouse_ros::MessageWithMetadata< moveit_msgs::msg::RobotTrajectory >::ConstPtr > fetchAllMatchingTrajectories(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::msg::MotionPlanRequest &plan_request, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::msg::MotionPlanRequest > > > &features, const std::string &sort_by, bool ascending=true, bool metadata_only=false) const
Fetches all trajectories keyed on user-specified features, returning them as a vector,...
bool insertCartesianTrajectory(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::srv::GetCartesianPath::Request &plan_request, const moveit_msgs::srv::GetCartesianPath::Response &plan, CacheInsertPolicyInterface< moveit_msgs::srv::GetCartesianPath::Request, moveit_msgs::srv::GetCartesianPath::Response, moveit_msgs::msg::RobotTrajectory > &cache_insert_policy, bool prune_worse_trajectories=true, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::srv::GetCartesianPath::Request > > > &additional_features={})
Inserts a cartesian trajectory into the database, with user-specified insert policy.
void setNumAdditionalTrajectoriesToPreserveWhenPruningWorse(size_t num_additional_trajectories_to_preserve_when_pruning_worse)
Set the number of additional trajectories to preserve when pruning worse trajectories.
static std::unique_ptr< CacheInsertPolicyInterface< moveit_msgs::srv::GetCartesianPath::Request, moveit_msgs::srv::GetCartesianPath::Response, moveit_msgs::msg::RobotTrajectory > > getDefaultCartesianCacheInsertPolicy()
Gets the default cache insert policy for GetCartesianPath requests.
void setExactMatchPrecision(double exact_match_precision)
Sets the exact match precision.
bool insertTrajectory(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::msg::MotionPlanRequest &plan_request, const moveit::planning_interface::MoveGroupInterface::Plan &plan, CacheInsertPolicyInterface< moveit_msgs::msg::MotionPlanRequest, moveit::planning_interface::MoveGroupInterface::Plan, moveit_msgs::msg::RobotTrajectory > &cache_insert_policy, bool prune_worse_trajectories=true, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::msg::MotionPlanRequest > > > &additional_features={})
Inserts a trajectory into the database, with user-specified insert policy.
std::string getDbPath() const
Gets the database path.
static std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::msg::MotionPlanRequest > > > getDefaultFeatures(double start_tolerance, double goal_tolerance)
Gets the default features for MotionPlanRequest messages.
bool init(const Options &options)
Initializes the TrajectoryCache.
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::RobotTrajectory >::ConstPtr fetchBestMatchingCartesianTrajectory(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::srv::GetCartesianPath::Request &plan_request, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::srv::GetCartesianPath::Request > > > &features, const std::string &sort_by, bool ascending=true, bool metadata_only=false) const
Fetches the best cartesian trajectory keyed on user-specified features, with respect to some cache fe...
uint32_t getDbPort() const
Gets the database port.
std::vector< warehouse_ros::MessageWithMetadata< moveit_msgs::msg::RobotTrajectory >::ConstPtr > fetchAllMatchingCartesianTrajectories(const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &cache_namespace, const moveit_msgs::srv::GetCartesianPath::Request &plan_request, const std::vector< std::unique_ptr< FeaturesInterface< moveit_msgs::srv::GetCartesianPath::Request > > > &features, const std::string &sort_by, bool ascending=true, bool metadata_only=false) const
Fetches all cartesian trajectories keyed on user-specified features, returning them as a vector,...
User-specified constant features to key the trajectory cache on.
Abstract template class for extracting features from some FeatureSourceT.
moveit_msgs::srv::GetCartesianPath::Request features to key the trajectory cache on.
moveit_msgs::msg::MotionPlanRequest features to key the trajectory cache on.
Utilities used by the trajectory_cache package.
warehouse_ros::DatabaseConnection::Ptr loadDatabase(const rclcpp::Node::SharedPtr &node)
Load a database connection.
Main namespace for MoveIt.
The representation of a motion plan (as ROS messages).
robot_trajectory::RobotTrajectoryPtr trajectory
Fuzzy-Matching Trajectory Cache.