77 moveit::planning_interface::MoveGroupInterface & moveGroupInterface,
78 geometry_msgs::msg::PoseStamped & targetObjectPose)
80 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
81 rclcpp::sleep_for(500ms);
89 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
92 getLogger(),
"[CbMoveEndEffector] Target End effector Pose: " << targetObjectPose);
94 if (motionPlanner !=
nullptr)
97 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Using CpMotionPlanner component for planning");
103 std::optional<std::string> tipLinkOpt;
109 auto result = motionPlanner->
planToPose(targetObjectPose, tipLinkOpt, options);
111 success = result.success;
114 computedMotionPlan = result.plan;
115 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Planning succeeded (via CpMotionPlanner)");
120 getLogger(),
"[CbMoveEndEffector] Planning failed (via CpMotionPlanner): %s",
121 result.errorMessage.c_str());
129 "[CbMoveEndEffector] CpMotionPlanner component not available, using legacy planning "
130 "(consider adding CpMotionPlanner component)");
132 moveGroupInterface.setPlanningTime(1.0);
133 moveGroupInterface.setPoseTarget(targetObjectPose,
tip_link_);
134 moveGroupInterface.setPoseReferenceFrame(targetObjectPose.header.frame_id);
137 (moveGroupInterface.plan(computedMotionPlan) == moveit::core::MoveItErrorCode::SUCCESS);
139 getLogger(),
"[CbMoveEndEffector] Planning %s (legacy mode)",
140 success ?
"succeeded" :
"FAILED");
151 bool executionSuccess =
false;
153 if (trajectoryExecutor !=
nullptr)
157 getLogger(),
"[CbMoveEndEffector] Using CpTrajectoryExecutor component for execution");
162 auto execResult = trajectoryExecutor->
executePlan(computedMotionPlan, execOptions);
163 executionSuccess = execResult.success;
165 if (executionSuccess)
168 getLogger(),
"[CbMoveEndEffector] Execution succeeded (via CpTrajectoryExecutor)");
173 getLogger(),
"[CbMoveEndEffector] Execution failed (via CpTrajectoryExecutor): %s",
174 execResult.errorMessage.c_str());
182 "[CbMoveEndEffector] CpTrajectoryExecutor component not available, using legacy "
184 "(consider adding CpTrajectoryExecutor component)");
186 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
187 executionSuccess = (executionResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
190 getLogger(),
"[CbMoveEndEffector] Execution %s (legacy mode)",
191 executionSuccess ?
"succeeded" :
"failed");
195 if (executionSuccess)
208 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] planning failed, skipping execution");
213 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
214 rclcpp::sleep_for(500ms);