72 moveit::planning_interface::MoveGroupInterface & moveGroupInterface,
73 geometry_msgs::msg::PoseStamped & targetObjectPose)
75 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
76 rclcpp::sleep_for(500ms);
82 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
85 getLogger(),
"[CbMoveEndEffector] Target End effector Pose: " << targetObjectPose);
87 if (motionPlanner !=
nullptr)
90 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Using CpMotionPlanner component for planning");
96 std::optional<std::string> tipLinkOpt;
102 auto result = motionPlanner->
planToPose(targetObjectPose, tipLinkOpt, options);
104 success = result.success;
107 computedMotionPlan = result.plan;
108 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Planning succeeded (via CpMotionPlanner)");
113 getLogger(),
"[CbMoveEndEffector] Planning failed (via CpMotionPlanner): %s",
114 result.errorMessage.c_str());
122 "[CbMoveEndEffector] CpMotionPlanner component not available, using legacy planning "
123 "(consider adding CpMotionPlanner component)");
125 moveGroupInterface.setPlanningTime(1.0);
126 moveGroupInterface.setPoseTarget(targetObjectPose,
tip_link_);
127 moveGroupInterface.setPoseReferenceFrame(targetObjectPose.header.frame_id);
130 (moveGroupInterface.plan(computedMotionPlan) == moveit::core::MoveItErrorCode::SUCCESS);
132 getLogger(),
"[CbMoveEndEffector] Planning %s (legacy mode)",
133 success ?
"succeeded" :
"FAILED");
142 bool executionSuccess =
false;
144 if (trajectoryExecutor !=
nullptr)
148 getLogger(),
"[CbMoveEndEffector] Using CpTrajectoryExecutor component for execution");
153 auto execResult = trajectoryExecutor->
executePlan(computedMotionPlan, execOptions);
154 executionSuccess = execResult.success;
156 if (executionSuccess)
159 getLogger(),
"[CbMoveEndEffector] Execution succeeded (via CpTrajectoryExecutor)");
164 getLogger(),
"[CbMoveEndEffector] Execution failed (via CpTrajectoryExecutor): %s",
165 execResult.errorMessage.c_str());
173 "[CbMoveEndEffector] CpTrajectoryExecutor component not available, using legacy "
175 "(consider adding CpTrajectoryExecutor component)");
177 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
178 executionSuccess = (executionResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
181 getLogger(),
"[CbMoveEndEffector] Execution %s (legacy mode)",
182 executionSuccess ?
"succeeded" :
"failed");
186 if (executionSuccess)
197 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] planning failed, skipping execution");
201 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
202 rclcpp::sleep_for(500ms);