@@ -95,7 +95,6 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
9595 RCLCPP_DEBUG (LOGGER, " Extract necessary information from motion plan request." );
9696
9797 info.group_name = req.group_name ;
98- std::string frame_id{ robot_model_->getModelFrame () };
9998 moveit::core::RobotState robot_state = scene->getCurrentState ();
10099
101100 // goal given in joint space
@@ -128,6 +127,7 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
128127 // goal given in Cartesian space
129128 else
130129 {
130+ std::string frame_id;
131131 info.link_name = req.goal_constraints .front ().position_constraints .front ().link_name ;
132132 if (req.goal_constraints .front ().position_constraints .front ().header .frame_id .empty () ||
133133 req.goal_constraints .front ().orientation_constraints .front ().header .frame_id .empty ())
@@ -140,39 +140,59 @@ void TrajectoryGeneratorCIRC::extractMotionPlanInfo(const planning_scene::Planni
140140 {
141141 frame_id = req.goal_constraints .front ().position_constraints .front ().header .frame_id ;
142142 }
143- info.goal_pose = getConstraintPose (req.goal_constraints .front ());
143+
144+ // goal pose with optional offset wrt. the planning frame
145+ info.goal_pose = scene->getFrameTransform (frame_id) * getConstraintPose (req.goal_constraints .front ());
146+ frame_id = robot_model_->getModelFrame ();
147+
148+ // check goal pose ik before Cartesian motion plan starts
149+ std::map<std::string, double > ik_solution;
150+ if (!computePoseIK (scene, info.group_name , info.link_name , info.goal_pose , frame_id, info.start_joint_position ,
151+ ik_solution))
152+ {
153+ // LCOV_EXCL_START
154+ std::ostringstream os;
155+ os << " Failed to compute inverse kinematics for link: " << info.link_name << " of goal pose" ;
156+ throw CircInverseForGoalIncalculable (os.str ());
157+ // LCOV_EXCL_STOP // not able to trigger here since lots of checks before
158+ // are in place
159+ }
144160 }
145161
146162 computeLinkFK (robot_state, info.link_name , info.start_joint_position , info.start_pose );
147163
148- // check goal pose ik before Cartesian motion plan starts
149- std::map<std::string, double > ik_solution;
150- if (!computePoseIK (scene, info.group_name , info.link_name , info.goal_pose , frame_id, info.start_joint_position ,
151- ik_solution))
164+ // center point with wrt. the planning frame
165+ std::string center_point_frame_id;
166+
167+ info.circ_path_point .first = req.path_constraints .name ;
168+ if (req.path_constraints .position_constraints .front ().header .frame_id .empty ())
152169 {
153- // LCOV_EXCL_START
154- std::ostringstream os;
155- os << " Failed to compute inverse kinematics for link: " << info.link_name << " of goal pose" ;
156- throw CircInverseForGoalIncalculable (os.str ());
157- // LCOV_EXCL_STOP // not able to trigger here since lots of checks before
158- // are in place
170+ RCLCPP_WARN (LOGGER, " Frame id is not set in position constraints of "
171+ " path. Use model frame as default" );
172+ center_point_frame_id = robot_model_->getModelFrame ();
159173 }
160- info.circ_path_point .first = req.path_constraints .name ;
174+ else
175+ {
176+ center_point_frame_id = req.path_constraints .position_constraints .front ().header .frame_id ;
177+ }
178+
179+ Eigen::Isometry3d center_point_pose;
180+ tf2::fromMsg (req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front (),
181+ center_point_pose);
182+
183+ center_point_pose = scene->getFrameTransform (center_point_frame_id) * center_point_pose;
184+
161185 if (!req.goal_constraints .front ().position_constraints .empty ())
162186 {
163187 const moveit_msgs::msg::Constraints& goal = req.goal_constraints .front ();
164- info.circ_path_point .second =
165- getConstraintPose (
166- req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front ().position ,
167- goal.orientation_constraints .front ().orientation , goal.position_constraints .front ().target_point_offset )
168- .translation ();
188+ geometry_msgs::msg::Point center_point = tf2::toMsg (Eigen::Vector3d (center_point_pose.translation ()));
189+ info.circ_path_point .second = getConstraintPose (center_point, goal.orientation_constraints .front ().orientation ,
190+ goal.position_constraints .front ().target_point_offset )
191+ .translation ();
169192 }
170193 else
171194 {
172- Eigen::Vector3d circ_path_point;
173- tf2::fromMsg (req.path_constraints .position_constraints .front ().constraint_region .primitive_poses .front ().position ,
174- circ_path_point);
175- info.circ_path_point .second = circ_path_point;
195+ info.circ_path_point .second = center_point_pose.translation ();
176196 }
177197}
178198
0 commit comments