SMACC
Loading...
Searching...
No Matches
cb_move_end_effector.cpp
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018-2020
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6
8// #include <moveit/kinematic_constraints/kinematic_constraint.h>
9#include <moveit/kinematic_constraints/utils.h>
10#include <future>
11
13{
15{
16}
17
18CbMoveEndEffector::CbMoveEndEffector(geometry_msgs::PoseStamped target_pose, std::string tip_link)
19 : targetPose(target_pose)
20{
21 tip_link_ = tip_link;
22}
23
25{
27
28 if (this->group_)
29 {
30 ROS_DEBUG("[CbMoveEndEfector] new thread started to move absolute end effector");
31 moveit::planning_interface::MoveGroupInterface move_group(*(this->group_));
32 this->moveToAbsolutePose(move_group, targetPose);
33 ROS_DEBUG("[CbMoveEndEfector] to move absolute end effector thread destroyed");
34 }
35 else
36 {
37 ROS_DEBUG("[CbMoveEndEfector] new thread started to move absolute end effector");
39 ROS_DEBUG("[CbMoveEndEfector] to move absolute end effector thread destroyed");
40 }
41}
42
43bool CbMoveEndEffector::moveToAbsolutePose(moveit::planning_interface::MoveGroupInterface &moveGroupInterface,
44 geometry_msgs::PoseStamped &targetObjectPose)
45{
46 auto& planningSceneInterface = movegroupClient_->planningSceneInterface;
47 ROS_DEBUG("[CbMoveEndEffector] Synchronous sleep of 1 seconds");
48 ros::Duration(0.5).sleep();
49
50 moveGroupInterface.setPlanningTime(1.0);
51
52 ROS_INFO_STREAM("[CbMoveEndEffector] Target End efector Pose: " << targetObjectPose);
53
54 moveGroupInterface.setPoseTarget(targetObjectPose, tip_link_);
55 moveGroupInterface.setPoseReferenceFrame(targetObjectPose.header.frame_id);
56
57 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
58 bool success = (moveGroupInterface.plan(computedMotionPlan) == moveit::core::MoveItErrorCode::SUCCESS);
59 ROS_INFO_NAMED("CbMoveEndEffector", "Success Visualizing plan 1 (pose goal) %s", success ? "" : "FAILED");
60
61 if (success)
62 {
63 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
64
65 if (executionResult == moveit_msgs::MoveItErrorCodes::SUCCESS)
66 {
67 ROS_INFO("[CbMoveEndEffector] motion execution succeeded");
69 this->postSuccessEvent();
70
71 }
72 else
73 {
74 ROS_INFO("[CbMoveEndEffector] motion execution failed");
76 this->postFailureEvent();
77 }
78 }
79 else
80 {
81 ROS_INFO("[CbMoveEndEffector] motion execution failed");
83 this->postFailureEvent();
84 }
85
86 ROS_DEBUG("[CbMoveEndEffector] Synchronous sleep of 1 seconds");
87 ros::Duration(0.5).sleep();
88
89 return success;
90}
91
92} // namespace cl_move_group_interface
bool moveToAbsolutePose(moveit::planning_interface::MoveGroupInterface &moveGroupInterface, geometry_msgs::PoseStamped &targetObjectPose)
moveit::planning_interface::PlanningSceneInterface planningSceneInterface
Definition: cl_movegroup.h:76
moveit::planning_interface::MoveGroupInterface moveGroupClientInterface
Definition: cl_movegroup.h:74
void requiresClient(SmaccClientType *&storage)