76 moveit::planning_interface::MoveGroupInterface & moveGroupInterface,
77 geometry_msgs::msg::PoseStamped & targetObjectPose)
79 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
80 rclcpp::sleep_for(500ms);
88 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
91 getLogger(),
"[CbMoveEndEffector] Target End effector Pose: " << targetObjectPose);
93 if (motionPlanner !=
nullptr)
96 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Using CpMotionPlanner component for planning");
102 std::optional<std::string> tipLinkOpt;
108 auto result = motionPlanner->
planToPose(targetObjectPose, tipLinkOpt, options);
110 success = result.success;
113 computedMotionPlan = result.plan;
114 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] Planning succeeded (via CpMotionPlanner)");
119 getLogger(),
"[CbMoveEndEffector] Planning failed (via CpMotionPlanner): %s",
120 result.errorMessage.c_str());
128 "[CbMoveEndEffector] CpMotionPlanner component not available, using legacy planning "
129 "(consider adding CpMotionPlanner component)");
131 moveGroupInterface.setPlanningTime(1.0);
132 moveGroupInterface.setPoseTarget(targetObjectPose,
tip_link_);
133 moveGroupInterface.setPoseReferenceFrame(targetObjectPose.header.frame_id);
136 (moveGroupInterface.plan(computedMotionPlan) == moveit::core::MoveItErrorCode::SUCCESS);
138 getLogger(),
"[CbMoveEndEffector] Planning %s (legacy mode)",
139 success ?
"succeeded" :
"FAILED");
150 bool executionSuccess =
false;
152 if (trajectoryExecutor !=
nullptr)
156 getLogger(),
"[CbMoveEndEffector] Using CpTrajectoryExecutor component for execution");
161 auto execResult = trajectoryExecutor->
executePlan(computedMotionPlan, execOptions);
162 executionSuccess = execResult.success;
164 if (executionSuccess)
167 getLogger(),
"[CbMoveEndEffector] Execution succeeded (via CpTrajectoryExecutor)");
172 getLogger(),
"[CbMoveEndEffector] Execution failed (via CpTrajectoryExecutor): %s",
173 execResult.errorMessage.c_str());
181 "[CbMoveEndEffector] CpTrajectoryExecutor component not available, using legacy "
183 "(consider adding CpTrajectoryExecutor component)");
185 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
186 executionSuccess = (executionResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
189 getLogger(),
"[CbMoveEndEffector] Execution %s (legacy mode)",
190 executionSuccess ?
"succeeded" :
"failed");
194 if (executionSuccess)
207 RCLCPP_INFO(
getLogger(),
"[CbMoveEndEffector] planning failed, skipping execution");
212 RCLCPP_DEBUG(
getLogger(),
"[CbMoveEndEffector] Synchronous sleep of 1 seconds");
213 rclcpp::sleep_for(500ms);