@@ -97,7 +97,6 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
97
97
RCLCPP_DEBUG (getLogger (), " Extract necessary information from motion plan request." );
98
98
99
99
info.group_name = req.group_name ;
100
- std::string frame_id{ robot_model_->getModelFrame () };
101
100
moveit::core::RobotState robot_state = scene->getCurrentState ();
102
101
103
102
// goal given in joint space
@@ -130,6 +129,7 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
130
129
// goal given in Cartesian space
131
130
else
132
131
{
132
+ std::string frame_id;
133
133
info.link_name = req.goal_constraints .front ().position_constraints .front ().link_name ;
134
134
if (req.goal_constraints .front ().position_constraints .front ().header .frame_id .empty () ||
135
135
req.goal_constraints .front ().orientation_constraints .front ().header .frame_id .empty ())
@@ -142,39 +142,59 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
142
142
{
143
143
frame_id = req.goal_constraints .front ().position_constraints .front ().header .frame_id ;
144
144
}
145
- info.goal_pose = getConstraintPose (req.goal_constraints .front ());
145
+
146
+ // goal pose with optional offset wrt. the planning frame
147
+ info.goal_pose = scene->getFrameTransform (frame_id) * getConstraintPose (req.goal_constraints .front ());
148
+ frame_id = robot_model_->getModelFrame ();
149
+
150
+ // check goal pose ik before Cartesian motion plan starts
151
+ std::map<std::string, double > ik_solution;
152
+ if (!computePoseIK (scene, info.group_name , info.link_name , info.goal_pose , frame_id, info.start_joint_position ,
153
+ ik_solution))
154
+ {
155
+ // LCOV_EXCL_START
156
+ std::ostringstream os;
157
+ os << " Failed to compute inverse kinematics for link: " << info.link_name << " of goal pose" ;
158
+ throw CircInverseForGoalIncalculable (os.str ());
159
+ // LCOV_EXCL_STOP // not able to trigger here since lots of checks before
160
+ // are in place
161
+ }
146
162
}
147
163
148
164
computeLinkFK (robot_state, info.link_name , info.start_joint_position , info.start_pose );
149
165
150
- // check goal pose ik before Cartesian motion plan starts
151
- std::map<std::string, double > ik_solution;
152
- if (!computePoseIK (scene, info.group_name , info.link_name , info.goal_pose , frame_id, info.start_joint_position ,
153
- ik_solution))
166
+ // center point with wrt. the planning frame
167
+ std::string center_point_frame_id;
168
+
169
+ info.circ_path_point .first = req.path_constraints .name ;
170
+ if (req.path_constraints .position_constraints .front ().header .frame_id .empty ())
154
171
{
155
- // LCOV_EXCL_START
156
- std::ostringstream os;
157
- os << " Failed to compute inverse kinematics for link: " << info.link_name << " of goal pose" ;
158
- throw CircInverseForGoalIncalculable (os.str ());
159
- // LCOV_EXCL_STOP // not able to trigger here since lots of checks before
160
- // are in place
172
+ RCLCPP_WARN (getLogger (), " Frame id is not set in position constraints of "
173
+ " path. Use model frame as default" );
174
+ center_point_frame_id = robot_model_->getModelFrame ();
161
175
}
162
- info.circ_path_point .first = req.path_constraints .name ;
176
+ else
177
+ {
178
+ center_point_frame_id = req.path_constraints .position_constraints .front ().header .frame_id ;
179
+ }
180
+
181
+ Eigen::Isometry3d center_point_pose;
182
+ tf2::fromMsg (req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front (),
183
+ center_point_pose);
184
+
185
+ center_point_pose = scene->getFrameTransform (center_point_frame_id) * center_point_pose;
186
+
163
187
if (!req.goal_constraints .front ().position_constraints .empty ())
164
188
{
165
189
const moveit_msgs::msg::Constraints& goal = req.goal_constraints .front ();
166
- info.circ_path_point .second =
167
- getConstraintPose (
168
- req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front ().position ,
169
- goal.orientation_constraints .front ().orientation , goal.position_constraints .front ().target_point_offset )
170
- .translation ();
190
+ geometry_msgs::msg::Point center_point = tf2::toMsg (Eigen::Vector3d (center_point_pose.translation ()));
191
+ info.circ_path_point .second = getConstraintPose (center_point, goal.orientation_constraints .front ().orientation ,
192
+ goal.position_constraints .front ().target_point_offset )
193
+ .translation ();
171
194
}
172
195
else
173
196
{
174
- Eigen::Vector3d circ_path_point;
175
- tf2::fromMsg (req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front ().position ,
176
- circ_path_point);
177
- info.circ_path_point .second = circ_path_point;
197
+ info.circ_path_point .second = center_point_pose.translation ();
178
198
}
179
199
}
180
200
0 commit comments