73 moveit::planning_interface::MoveGroupInterface & moveGroupInterface,
74 geometry_msgs::msg::PoseStamped & targetObjectPose)
76 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
77 rclcpp::sleep_for(500ms);
83 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
86 getLogger(),
"[CbMoveEndEffector] Target End effector Pose: " << targetObjectPose);
88 if (motionPlanner !=
nullptr)
91 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Using CpMotionPlanner component for planning");
97 std::optional<std::string> tipLinkOpt;
103 auto result = motionPlanner->
planToPose(targetObjectPose, tipLinkOpt, options);
105 success = result.success;
108 computedMotionPlan = result.plan;
109 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Planning succeeded (via CpMotionPlanner)");
114 getLogger(),
"[CbMoveEndEffector] Planning failed (via CpMotionPlanner): %s",
115 result.errorMessage.c_str());
123 "[CbMoveEndEffector] CpMotionPlanner component not available, using legacy planning "
124 "(consider adding CpMotionPlanner component)");
126 moveGroupInterface.setPlanningTime(1.0);
127 moveGroupInterface.setPoseTarget(targetObjectPose,
tip_link_);
128 moveGroupInterface.setPoseReferenceFrame(targetObjectPose.header.frame_id);
131 (moveGroupInterface.plan(computedMotionPlan) == moveit::core::MoveItErrorCode::SUCCESS);
133 getLogger(),
"[CbMoveEndEffector] Planning %s (legacy mode)",
134 success ?
"succeeded" :
"FAILED");
143 bool executionSuccess =
false;
145 if (trajectoryExecutor !=
nullptr)
149 getLogger(),
"[CbMoveEndEffector] Using CpTrajectoryExecutor component for execution");
154 auto execResult = trajectoryExecutor->
executePlan(computedMotionPlan, execOptions);
155 executionSuccess = execResult.success;
157 if (executionSuccess)
160 getLogger(),
"[CbMoveEndEffector] Execution succeeded (via CpTrajectoryExecutor)");
165 getLogger(),
"[CbMoveEndEffector] Execution failed (via CpTrajectoryExecutor): %s",
166 execResult.errorMessage.c_str());
174 "[CbMoveEndEffector] CpTrajectoryExecutor component not available, using legacy "
176 "(consider adding CpTrajectoryExecutor component)");
178 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
179 executionSuccess = (executionResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
182 getLogger(),
"[CbMoveEndEffector] Execution %s (legacy mode)",
183 executionSuccess ?
"succeeded" :
"failed");
187 if (executionSuccess)
198 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] planning failed, skipping execution");
202 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
203 rclcpp::sleep_for(500ms);