25 moveit::planning_interface::MoveGroupInterface move_group(*(this->
group_));
41 geometry_msgs::Vector3 &offset)
43 std::vector<geometry_msgs::Pose> waypoints;
49 auto referenceStartPose = movegroupClient->getCurrentPose();
50 movegroupClient->setPoseReferenceFrame(referenceStartPose.header.frame_id);
52 ROS_INFO_STREAM(
"[CbMoveCartesianRelative] RELATIVE MOTION, SOURCE POSE: " << referenceStartPose);
53 ROS_INFO_STREAM(
"[CbMoveCartesianRelative] Offset: " << offset);
55 waypoints.push_back(referenceStartPose.pose);
57 auto endPose = referenceStartPose.pose;
59 endPose.position.x += offset.x;
60 endPose.position.y += offset.y;
61 endPose.position.z += offset.z;
63 ROS_INFO_STREAM(
"[CbMoveCartesianRelative] DESTINY POSE: " << endPose);
66 waypoints.push_back(endPose);
68 movegroupClient->setPoseTarget(endPose);
74 ROS_INFO_STREAM(
"[CbMoveCartesianRelative] Using scaling factor: " << scalinf);
75 movegroupClient->setMaxVelocityScalingFactor(scalinf);
77 moveit_msgs::RobotTrajectory trajectory;
78 double fraction = movegroupClient->computeCartesianPath(waypoints,
83 moveit::core::MoveItErrorCode behaviorResult;
84 if (fraction != 1.0 || fraction == -1)
86 ROS_WARN_STREAM(
"[CbMoveCartesianRelative] Cartesian plan joint-continuity percentaje. Execution skipped because not 100% of cartesian motion: " << fraction*100<<
"%");
87 behaviorResult = moveit::core::MoveItErrorCode::PLANNING_FAILED;
91 ROS_INFO_STREAM(
"[CbMoveCartesianRelative] Cartesian plan joint-continuity percentaje: " << fraction);
93 moveit::planning_interface::MoveGroupInterface::Plan grasp_pose_plan;
96 grasp_pose_plan.trajectory_ = trajectory;
97 behaviorResult = movegroupClient->execute(grasp_pose_plan);
100 if (behaviorResult == moveit_msgs::MoveItErrorCodes::SUCCESS)
102 ROS_INFO(
"[CbMoveCartesianRelative] relative motion execution succeeded: fraction %lf.", fraction);
108 movegroupClient->setPoseTarget(referenceStartPose);
109 ROS_INFO(
"[CbMoveCartesianRelative] relative motion execution failed: fraction %lf.", fraction);
boost::optional< std::string > group_
CbMoveCartesianRelative()
boost::optional< double > scalingFactor_
virtual void onExit() override
virtual void onEntry() override
geometry_msgs::Vector3 offset_
ClMoveGroup * moveGroupSmaccClient_
void moveRelativeCartesian(moveit::planning_interface::MoveGroupInterface *movegroupClient, geometry_msgs::Vector3 &offset)
void postEventMotionExecutionFailed()
moveit::planning_interface::MoveGroupInterface moveGroupClientInterface
void postEventMotionExecutionSucceded()
void requiresClient(SmaccClientType *&storage)