22#include <rclcpp/logging.hpp>
23#include <warehouse_ros/message_collection.h>
28#include <moveit_msgs/msg/motion_plan_request.hpp>
35namespace trajectory_cache
38using ::warehouse_ros::Metadata;
39using ::warehouse_ros::Query;
41using ::moveit::core::MoveItErrorCode;
42using ::moveit::planning_interface::MoveGroupInterface;
44using ::moveit_msgs::msg::MotionPlanRequest;
61 double exact_match_precision)
const
70 query.append(name_ +
".group_name", source.group_name);
71 query.append(name_ +
".workspace_parameters.header.frame_id",
73 query.appendGTE(name_ +
".workspace_parameters.min_corner.x", source.workspace_parameters.min_corner.x);
74 query.appendGTE(name_ +
".workspace_parameters.min_corner.y", source.workspace_parameters.min_corner.y);
75 query.appendGTE(name_ +
".workspace_parameters.min_corner.z", source.workspace_parameters.min_corner.z);
76 query.appendLTE(name_ +
".workspace_parameters.max_corner.x", source.workspace_parameters.max_corner.x);
77 query.appendLTE(name_ +
".workspace_parameters.max_corner.y", source.workspace_parameters.max_corner.y);
78 query.appendLTE(name_ +
".workspace_parameters.max_corner.z", source.workspace_parameters.max_corner.z);
79 return MoveItErrorCode::SUCCESS;
85 metadata.append(name_ +
".group_name", source.group_name);
86 metadata.append(name_ +
".workspace_parameters.header.frame_id",
88 metadata.append(name_ +
".workspace_parameters.min_corner.x", source.workspace_parameters.min_corner.x);
89 metadata.append(name_ +
".workspace_parameters.min_corner.y", source.workspace_parameters.min_corner.y);
90 metadata.append(name_ +
".workspace_parameters.min_corner.z", source.workspace_parameters.min_corner.z);
91 metadata.append(name_ +
".workspace_parameters.max_corner.x", source.workspace_parameters.max_corner.x);
92 metadata.append(name_ +
".workspace_parameters.max_corner.y", source.workspace_parameters.max_corner.y);
93 metadata.append(name_ +
".workspace_parameters.max_corner.z", source.workspace_parameters.max_corner.z);
94 return MoveItErrorCode::SUCCESS;
100 : name_(
"StartStateJointStateFeatures"), match_tolerance_(match_tolerance)
110 const MotionPlanRequest& source,
112 double exact_match_precision)
const
114 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, match_tolerance_ + exact_match_precision);
118 const MotionPlanRequest& source,
120 double exact_match_precision)
const
122 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, exact_match_precision);
126 const MotionPlanRequest& source,
132MoveItErrorCode StartStateJointStateFeatures::appendFeaturesAsFetchQueryWithTolerance(
133 Query& query,
const MotionPlanRequest& source,
const MoveGroupInterface&
move_group,
double match_tolerance)
const
136 name_ +
".start_state");
153 const MotionPlanRequest& source,
155 double exact_match_precision)
const
162 const MoveGroupInterface& ,
165 if (source.max_velocity_scaling_factor <= 0 || source.max_velocity_scaling_factor > 1.0)
167 query.appendLTE(name_ +
".max_velocity_scaling_factor", 1.0);
171 query.appendLTE(name_ +
".max_velocity_scaling_factor", source.max_velocity_scaling_factor);
174 if (source.max_acceleration_scaling_factor <= 0 || source.max_acceleration_scaling_factor > 1.0)
176 query.appendLTE(name_ +
".max_acceleration_scaling_factor", 1.0);
180 query.appendLTE(name_ +
".max_acceleration_scaling_factor", source.max_acceleration_scaling_factor);
183 if (source.max_cartesian_speed > 0)
185 query.append(name_ +
".cartesian_speed_limited_link", source.cartesian_speed_limited_link);
186 query.appendLTE(name_ +
".max_cartesian_speed", source.max_cartesian_speed);
189 return MoveItErrorCode::SUCCESS;
194 const MoveGroupInterface& )
const
196 if (source.max_velocity_scaling_factor <= 0 || source.max_velocity_scaling_factor > 1.0)
198 metadata.append(name_ +
".max_velocity_scaling_factor", 1.0);
202 metadata.append(name_ +
".max_velocity_scaling_factor", source.max_velocity_scaling_factor);
205 if (source.max_acceleration_scaling_factor <= 0 || source.max_acceleration_scaling_factor > 1.0)
207 metadata.append(name_ +
".max_acceleration_scaling_factor", 1.0);
211 metadata.append(name_ +
".max_acceleration_scaling_factor", source.max_acceleration_scaling_factor);
214 if (source.max_cartesian_speed > 0)
216 metadata.append(name_ +
".cartesian_speed_limited_link", source.cartesian_speed_limited_link);
217 metadata.append(name_ +
".max_cartesian_speed", source.max_cartesian_speed);
220 return MoveItErrorCode::SUCCESS;
226 : name_(
"GoalConstraintsFeatures"), match_tolerance_(match_tolerance)
237 double exact_match_precision)
const
239 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, match_tolerance_ + exact_match_precision);
244 double exact_match_precision)
const
246 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, exact_match_precision);
250 const MotionPlanRequest& source,
255 name_ +
".goal_constraints");
258MoveItErrorCode GoalConstraintsFeatures::appendFeaturesAsFetchQueryWithTolerance(Query& query,
259 const MotionPlanRequest& source,
261 double match_tolerance)
const
265 workspace_id, name_ +
".goal_constraints");
271 : name_(
"PathConstraintsFeatures"), match_tolerance_(match_tolerance)
282 double exact_match_precision)
const
284 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, match_tolerance_ + exact_match_precision);
289 double exact_match_precision)
const
291 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, exact_match_precision);
295 const MotionPlanRequest& source,
300 name_ +
".path_constraints");
303MoveItErrorCode PathConstraintsFeatures::appendFeaturesAsFetchQueryWithTolerance(Query& query,
304 const MotionPlanRequest& source,
306 double match_tolerance)
const
310 workspace_id, name_ +
".path_constraints");
316 : name_(
"TrajectoryConstraintsFeatures"), match_tolerance_(match_tolerance)
326 const MotionPlanRequest& source,
328 double exact_match_precision)
const
330 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, match_tolerance_ + exact_match_precision);
334 const MotionPlanRequest& source,
336 double exact_match_precision)
const
338 return appendFeaturesAsFetchQueryWithTolerance(query, source,
move_group, exact_match_precision);
347 workspace_id, name_ +
".trajectory_constraints.constraints");
350MoveItErrorCode TrajectoryConstraintsFeatures::appendFeaturesAsFetchQueryWithTolerance(
351 Query& query,
const MotionPlanRequest& source,
const MoveGroupInterface&
move_group,
double match_tolerance)
const
355 match_tolerance, workspace_id,
356 name_ +
".trajectory_constraints.constraints");
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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.
GoalConstraintsFeatures(double match_tolerance)
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
std::string getName() const override
Gets the name of the features implementation.
MaxSpeedAndAccelerationFeatures()
std::string getName() const override
Gets the name of the features implementation.
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) 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 moveit_msgs::msg::MotionPlanRequest &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 exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
PathConstraintsFeatures(double match_tolerance)
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 exact matching.
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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.
StartStateJointStateFeatures(double match_tolerance)
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) const override
Extracts relevant features from FeatureSourceT, to be appended to a cache entry's metadata.
std::string getName() const override
Gets the name of the features implementation.
TrajectoryConstraintsFeatures(double match_tolerance)
moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) 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 moveit_msgs::msg::MotionPlanRequest &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 exact matching.
std::string getName() const override
Gets the name of the features implementation.
moveit::core::MoveItErrorCode appendFeaturesAsInsertMetadata(warehouse_ros::Metadata &metadata, const moveit_msgs::msg::MotionPlanRequest &source, const moveit::planning_interface::MoveGroupInterface &move_group) 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 moveit_msgs::msg::MotionPlanRequest &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.
moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery(warehouse_ros::Query &query, const moveit_msgs::msg::MotionPlanRequest &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 exact matching.
moveit_msgs::msg::MotionPlanRequest features to key the trajectory cache on.
Utilities used by the trajectory_cache package.
moveit::core::MoveItErrorCode appendConstraintsAsFetchQueryWithTolerance(warehouse_ros::Query &query, std::vector< moveit_msgs::msg::Constraints > constraints, const moveit::planning_interface::MoveGroupInterface &move_group, double match_tolerance, const std::string &reference_frame_id, const std::string &prefix)
Extracts relevant features from a vector of moveit_msgs::msg::Constraints messages to a fetch query,...
std::string getWorkspaceFrameId(const moveit::planning_interface::MoveGroupInterface &move_group, const moveit_msgs::msg::WorkspaceParameters &workspace_parameters)
Gets workspace frame ID. If workspace_parameters has no frame ID, fetch it from move_group.
moveit::core::MoveItErrorCode appendConstraintsAsInsertMetadata(warehouse_ros::Metadata &metadata, std::vector< moveit_msgs::msg::Constraints > constraints, const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &reference_frame_id, const std::string &prefix)
Extracts relevant features from a vector of moveit_msgs::msg::Constraints messages to a cache entry's...
moveit::core::MoveItErrorCode appendRobotStateJointStateAsInsertMetadata(warehouse_ros::Metadata &metadata, const moveit_msgs::msg::RobotState &robot_state, const moveit::planning_interface::MoveGroupInterface &move_group, const std::string &prefix)
Extracts relevant features from a vector of moveit_msgs::msg::Constraints messages to a cache entry's...
moveit::core::MoveItErrorCode appendRobotStateJointStateAsFetchQueryWithTolerance(warehouse_ros::Query &query, const moveit_msgs::msg::RobotState &robot_state, const moveit::planning_interface::MoveGroupInterface &move_group, double match_tolerance, const std::string &prefix)
Extracts relevant features from a vector of moveit_msgs::msg::Constraints messages to a fetch query,...