21#include <tf2_ros/buffer.h>
22#include <tf2_ros/transform_listener.h>
26#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
28#include <ament_index_cpp/get_package_share_directory.hpp>
30using namespace std::chrono_literals;
35: CbCircularPivotMotion(tipLink)
37 deltaRadians_ = deltaRadians;
40CbEndEffectorRotate::~CbEndEffectorRotate() {}
42void CbEndEffectorRotate::onEntry()
45 tf2_ros::Buffer tfBuffer(getNode()->get_clock());
46 tf2_ros::TransformListener tfListener(tfBuffer);
48 tf2::Stamped<tf2::Transform> endEffectorInPivotFrame;
52 this->requiresClient(movegroupClient_);
55 tipLink_ = this->movegroupClient_->moveGroupClientInterface->getEndEffectorLink();
58 "[" << getName() <<
"] tip unspecified, using default end effector: " << *tipLink_);
66 auto pivotFrameName = this->movegroupClient_->moveGroupClientInterface->getEndEffectorLink();
68 tf2::Stamped<tf2::Transform> endEffectorInPivotFrame;
71 tfBuffer.lookupTransform(pivotFrameName, *tipLink_, rclcpp::Time(), rclcpp::Duration(10s)),
72 endEffectorInPivotFrame);
74 tf2::toMsg(endEffectorInPivotFrame, this->planePivotPose_.pose);
75 this->planePivotPose_.header.frame_id = endEffectorInPivotFrame.frame_id_;
76 this->planePivotPose_.header.stamp =
77 rclcpp::Time(endEffectorInPivotFrame.stamp_.time_since_epoch().count());
80 catch (
const std::exception & e)
82 RCLCPP_ERROR_STREAM(getLogger(), e.what() <<
". Attempt countdown: " << attempts);
83 rclcpp::Duration(500ms);
88 RCLCPP_INFO_STREAM(getLogger(),
"[" << getName() <<
"] pivotPose: " << planePivotPose_);
91 getLogger(),
"[" << getName() <<
"] calling base CbCircularPivotMotion::onEntry");
92 CbCircularPivotMotion::onEntry();
CbEndEffectorRotate(double deltaRadians, std::optional< std::string > tipLink=std::nullopt)