54 moveit::planning_interface::MoveGroupInterface * movegroupClient,
55 geometry_msgs::msg::Vector3 & offset)
57 std::vector<geometry_msgs::msg::Pose> waypoints;
63 auto referenceStartPose = movegroupClient->getCurrentPose();
64 movegroupClient->setPoseReferenceFrame(referenceStartPose.header.frame_id);
67 getLogger(),
"[CbMoveCartesianRelative] RELATIVE MOTION, SOURCE POSE: " << referenceStartPose);
68 RCLCPP_INFO_STREAM(
getLogger(),
"[CbMoveCartesianRelative] Offset: " << offset);
70 waypoints.push_back(referenceStartPose.pose);
72 auto endPose = referenceStartPose.pose;
74 endPose.position.x += offset.x;
75 endPose.position.y += offset.y;
76 endPose.position.z += offset.z;
78 RCLCPP_INFO_STREAM(
getLogger(),
"[CbMoveCartesianRelative] DESTINY POSE: " << endPose);
81 waypoints.push_back(endPose);
83 movegroupClient->setPoseTarget(endPose);
88 RCLCPP_INFO_STREAM(
getLogger(),
"[CbMoveCartesianRelative] Using scaling factor: " << scalinf);
89 movegroupClient->setMaxVelocityScalingFactor(scalinf);
91 moveit_msgs::msg::RobotTrajectory trajectory;
92 double fraction = movegroupClient->computeCartesianPath(
98 moveit::core::MoveItErrorCode behaviorResult;
99 if (fraction != 1.0 || fraction == -1)
103 "[CbMoveCartesianRelative] Cartesian plan joint-continuity percentaje. Execution skipped "
104 "because not 100% of cartesian motion: "
105 << fraction * 100 <<
"%");
106 behaviorResult = moveit::core::MoveItErrorCode::PLANNING_FAILED;
112 "[CbMoveCartesianRelative] Cartesian plan joint-continuity percentaje: " << fraction);
114 moveit::planning_interface::MoveGroupInterface::Plan grasp_pose_plan;
117 grasp_pose_plan.trajectory_ = trajectory;
118 behaviorResult = movegroupClient->execute(grasp_pose_plan);
121 if (behaviorResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS)
124 getLogger(),
"[CbMoveCartesianRelative] relative motion execution succeeded: fraction %lf.",
131 movegroupClient->setPoseTarget(
134 getLogger(),
"[CbMoveCartesianRelative] relative motion execution failed: fraction %lf.",