|
| 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 | + |
| 15 | +/** @file |
| 16 | + * @brief moveit_msgs::srv::GetCartesianPath::Request features to key the trajectory cache on. |
| 17 | + * @see FeaturesInterface<FeatureSourceT> |
| 18 | + * |
| 19 | + * @author methylDragon |
| 20 | + */ |
| 21 | + |
| 22 | +#pragma once |
| 23 | + |
| 24 | +#include <warehouse_ros/message_collection.h> |
| 25 | +#include <moveit/move_group_interface/move_group_interface.h> |
| 26 | +#include <moveit_msgs/srv/get_cartesian_path.hpp> |
| 27 | + |
| 28 | +#include <moveit/trajectory_cache/features/features_interface.hpp> |
| 29 | + |
| 30 | +namespace moveit_ros |
| 31 | +{ |
| 32 | +namespace trajectory_cache |
| 33 | +{ |
| 34 | + |
| 35 | +// "Start" features. =============================================================================== |
| 36 | + |
| 37 | +/** @class CartesianWorkspaceFeatures |
| 38 | + * @brief Extracts group name and frame ID from the plan request. |
| 39 | + */ |
| 40 | +class CartesianWorkspaceFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 41 | +{ |
| 42 | +public: |
| 43 | + CartesianWorkspaceFeatures(); |
| 44 | + |
| 45 | + std::string getName() const override; |
| 46 | + |
| 47 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 48 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 49 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 50 | + |
| 51 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 52 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 53 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 54 | + |
| 55 | + moveit::core::MoveItErrorCode |
| 56 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 57 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 58 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 59 | + |
| 60 | +private: |
| 61 | + const std::string name_; |
| 62 | +}; |
| 63 | + |
| 64 | +/** @class CartesianStartStateJointStateFeatures |
| 65 | + * @brief Extracts details of the joint state from the `start_state` field in the plan request. |
| 66 | + * |
| 67 | + * The start state will always be re-interpreted into explicit joint state positions. |
| 68 | + * |
| 69 | + * WARNING: |
| 70 | + * MultiDOF joints and attached collision objects are not supported. |
| 71 | + */ |
| 72 | +class CartesianStartStateJointStateFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 73 | +{ |
| 74 | +public: |
| 75 | + CartesianStartStateJointStateFeatures(double match_tolerance); |
| 76 | + |
| 77 | + std::string getName() const override; |
| 78 | + |
| 79 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 80 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 81 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 82 | + |
| 83 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 84 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 85 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 86 | + |
| 87 | + moveit::core::MoveItErrorCode |
| 88 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 89 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 90 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 91 | + |
| 92 | +private: |
| 93 | + moveit::core::MoveItErrorCode appendFeaturesAsFetchQueryWithTolerance( |
| 94 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 95 | + const moveit::planning_interface::MoveGroupInterface& move_group, double match_tolerance) const; |
| 96 | + |
| 97 | + const std::string name_; |
| 98 | + const double match_tolerance_; |
| 99 | +}; |
| 100 | + |
| 101 | +// "Goal" features. ================================================================================ |
| 102 | + |
| 103 | +/** @class CartesianMaxSpeedAndAccelerationFeatures |
| 104 | + * @brief Extracts max velocity and acceleration scaling, and cartesian speed limits from the plan request. |
| 105 | + * |
| 106 | + * These features will be extracted as less-than-or-equal features. |
| 107 | + * |
| 108 | + * NOTE: In accordance with the source message's field descriptions: |
| 109 | + * If the max scaling factors are outside the range of (0, 1], they will be set to 1. |
| 110 | + * If max_cartesian_speed is <= 0, it will be ignored instead. |
| 111 | + */ |
| 112 | +class CartesianMaxSpeedAndAccelerationFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 113 | +{ |
| 114 | +public: |
| 115 | + CartesianMaxSpeedAndAccelerationFeatures(); |
| 116 | + |
| 117 | + std::string getName() const override; |
| 118 | + |
| 119 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 120 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 121 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 122 | + |
| 123 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 124 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 125 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 126 | + |
| 127 | + moveit::core::MoveItErrorCode |
| 128 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 129 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 130 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 131 | + |
| 132 | +private: |
| 133 | + const std::string name_; |
| 134 | +}; |
| 135 | + |
| 136 | +/** @class CartesianMaxStepAndJumpThresholdFeatures |
| 137 | + * @brief Extracts max step and jump thresholds from the plan request. |
| 138 | + * |
| 139 | + * These features will be extracted as less-than-or-equal features. |
| 140 | + * |
| 141 | + * NOTE: In accordance with the source message's field descriptions: |
| 142 | + * If a jump threshold is set to 0, it will be ignored instead. |
| 143 | + */ |
| 144 | +class CartesianMaxStepAndJumpThresholdFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 145 | +{ |
| 146 | +public: |
| 147 | + CartesianMaxStepAndJumpThresholdFeatures(); |
| 148 | + |
| 149 | + std::string getName() const override; |
| 150 | + |
| 151 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 152 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 153 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 154 | + |
| 155 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 156 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 157 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 158 | + |
| 159 | + moveit::core::MoveItErrorCode |
| 160 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 161 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 162 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 163 | + |
| 164 | +private: |
| 165 | + const std::string name_; |
| 166 | +}; |
| 167 | + |
| 168 | +/** @class CartesianWaypointsFeatures |
| 169 | + * @brief Extracts features fom the `waypoints` and `link_name` field in the plan request. |
| 170 | + * |
| 171 | + * `link_name` is extracted here because it is what the waypoints are stated with reference to. |
| 172 | + * Additionally, the waypoints will be restated in the robot's model frame. |
| 173 | + * |
| 174 | + * NOTE: In accordance with the source message's field descriptions: |
| 175 | + * If link_name is empty, uses move_group.getEndEffectorLink(). |
| 176 | + * |
| 177 | + * @see appendConstraintsAsFetchQueryWithTolerance |
| 178 | + * @see appendConstraintsAsInsertMetadata |
| 179 | + */ |
| 180 | +class CartesianWaypointsFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 181 | +{ |
| 182 | +public: |
| 183 | + CartesianWaypointsFeatures(double match_tolerance); |
| 184 | + |
| 185 | + std::string getName() const override; |
| 186 | + |
| 187 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 188 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 189 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 190 | + |
| 191 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 192 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 193 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 194 | + |
| 195 | + moveit::core::MoveItErrorCode |
| 196 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 197 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 198 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 199 | + |
| 200 | +private: |
| 201 | + moveit::core::MoveItErrorCode appendFeaturesAsFetchQueryWithTolerance( |
| 202 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 203 | + const moveit::planning_interface::MoveGroupInterface& move_group, double match_tolerance) const; |
| 204 | + |
| 205 | + const std::string name_; |
| 206 | + const double match_tolerance_; |
| 207 | +}; |
| 208 | + |
| 209 | +/** @class CartesianPathConstraintsFeatures |
| 210 | + * @brief Extracts features fom the `path_constraints` field in the plan request. |
| 211 | + * |
| 212 | + * @see appendConstraintsAsFetchQueryWithTolerance |
| 213 | + * @see appendConstraintsAsInsertMetadata |
| 214 | + */ |
| 215 | +class CartesianPathConstraintsFeatures : public FeaturesInterface<moveit_msgs::srv::GetCartesianPath::Request> |
| 216 | +{ |
| 217 | +public: |
| 218 | + CartesianPathConstraintsFeatures(double match_tolerance); |
| 219 | + |
| 220 | + std::string getName() const override; |
| 221 | + |
| 222 | + moveit::core::MoveItErrorCode appendFeaturesAsFuzzyFetchQuery( |
| 223 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 224 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 225 | + |
| 226 | + moveit::core::MoveItErrorCode appendFeaturesAsExactFetchQuery( |
| 227 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 228 | + const moveit::planning_interface::MoveGroupInterface& move_group, double exact_match_precision) const override; |
| 229 | + |
| 230 | + moveit::core::MoveItErrorCode |
| 231 | + appendFeaturesAsInsertMetadata(warehouse_ros::Metadata& metadata, |
| 232 | + const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 233 | + const moveit::planning_interface::MoveGroupInterface& move_group) const override; |
| 234 | + |
| 235 | +private: |
| 236 | + moveit::core::MoveItErrorCode appendFeaturesAsFetchQueryWithTolerance( |
| 237 | + warehouse_ros::Query& query, const moveit_msgs::srv::GetCartesianPath::Request& source, |
| 238 | + const moveit::planning_interface::MoveGroupInterface& move_group, double match_tolerance) const; |
| 239 | + |
| 240 | + const std::string name_; |
| 241 | + const double match_tolerance_; |
| 242 | +}; |
| 243 | + |
| 244 | +} // namespace trajectory_cache |
| 245 | +} // namespace moveit_ros |
0 commit comments