Skip to content

Commit 77789f3

Browse files
committed
Add GetCartesianPlanRequest features
Signed-off-by: methylDragon <[email protected]>
1 parent 4489676 commit 77789f3

File tree

10 files changed

+915
-45
lines changed

10 files changed

+915
-45
lines changed

moveit_ros/trajectory_cache/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ ament_target_dependencies(moveit_ros_trajectory_cache_utils_lib
4747

4848
# Features library
4949
add_library(moveit_ros_trajectory_features_lib
50-
src/features/motion_plan_request_features.cpp)
50+
src/features/motion_plan_request_features.cpp
51+
src/features/get_cartesian_path_request_features.cpp)
5152
generate_export_header(moveit_ros_trajectory_features_lib)
5253
target_link_libraries(moveit_ros_trajectory_features_lib
5354
moveit_ros_trajectory_cache_utils_lib)
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
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

moveit_ros/trajectory_cache/include/moveit/trajectory_cache/trajectory_cache.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,6 @@ class TrajectoryCache
286286
*/
287287
/**@{*/
288288

289-
/**
290-
* @brief Constructs a GetCartesianPath request.
291-
*
292-
* This mimics the move group computeCartesianPath signature (without path constraints).
293-
*
294-
* @param[in] move_group. The manipulator move group, used to get its state, frames, and link.
295-
* @param[in] waypoints. The cartesian waypoints to request the path for.
296-
* @param[in] max_step. The value to populate into the `GetCartesianPath` request's max_step field.
297-
* @param[in] jump_threshold. The value to populate into the `GetCartesianPath` request's jump_threshold field.
298-
* @param[in] avoid_collisions. The value to populate into the `GetCartesianPath` request's avoid_collisions field.
299-
* @returns
300-
*/
301-
moveit_msgs::srv::GetCartesianPath::Request
302-
constructGetCartesianPathRequest(moveit::planning_interface::MoveGroupInterface& move_group,
303-
const std::vector<geometry_msgs::msg::Pose>& waypoints, double max_step,
304-
double jump_threshold, bool avoid_collisions = true);
305-
306289
/**
307290
* @brief Fetches all cartesian trajectories that fit within the requested tolerances for start and goal conditions,
308291
* returning them as a vector, sorted by some cache column.

moveit_ros/trajectory_cache/include/moveit/trajectory_cache/utils/utils.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ std::string getWorkspaceFrameId(const moveit::planning_interface::MoveGroupInter
4747
std::string getCartesianPathRequestFrameId(const moveit::planning_interface::MoveGroupInterface& move_group,
4848
const moveit_msgs::srv::GetCartesianPath::Request& path_request);
4949

50+
// Request Construction. ===========================================================================
51+
52+
/**
53+
* @brief Constructs a GetCartesianPath request.
54+
*
55+
* This is a convenience function.
56+
* This mimics the move group computeCartesianPath signature (without path constraints).
57+
*
58+
* WARNING: The following fields are not supported, if you want to specify them, add them in yourself.
59+
* - prismatic_jump_threshold
60+
* - revolute_jump_threshold
61+
* - cartesian_speed_limited_link
62+
* - max_cartesian_speed
63+
*
64+
* @param[in] move_group. The manipulator move group, used to get its state, frames, and link.
65+
* @param[in] waypoints. The cartesian waypoints to request the path for.
66+
* @param[in] max_step. The value to populate into the `GetCartesianPath` request's max_step field.
67+
* @param[in] jump_threshold. The value to populate into the `GetCartesianPath` request's jump_threshold field.
68+
* @param[in] avoid_collisions. The value to populate into the `GetCartesianPath` request's avoid_collisions field.
69+
* @returns
70+
*/
71+
moveit_msgs::srv::GetCartesianPath::Request
72+
constructGetCartesianPathRequest(moveit::planning_interface::MoveGroupInterface& move_group,
73+
const std::vector<geometry_msgs::msg::Pose>& waypoints, double max_step,
74+
double jump_threshold, bool avoid_collisions = true);
75+
5076
// Queries. ========================================================================================
5177

5278
/** @brief Appends a range inclusive query with some tolerance about some center value. */

0 commit comments

Comments
 (0)