SMACC2
Loading...
Searching...
No Matches
cl_moveit2z::CbEndEffectorRotate Class Reference

#include <cb_end_effector_rotate.hpp>

Inheritance diagram for cl_moveit2z::CbEndEffectorRotate:
Inheritance graph
Collaboration diagram for cl_moveit2z::CbEndEffectorRotate:
Collaboration graph

Public Member Functions

 CbEndEffectorRotate (double deltaRadians, std::optional< std::string > tipLink=std::nullopt)
 
virtual ~CbEndEffectorRotate ()
 
virtual void onEntry () override
 
- Public Member Functions inherited from cl_moveit2z::CbCircularPivotMotion
 CbCircularPivotMotion (std::optional< std::string > tipLink=std::nullopt)
 
 CbCircularPivotMotion (const geometry_msgs::msg::PoseStamped &planePivotPose, double deltaRadians, std::optional< std::string > tipLink=std::nullopt)
 
 CbCircularPivotMotion (const geometry_msgs::msg::PoseStamped &planePivotPose, const geometry_msgs::msg::Pose &relativeInitialPose, double deltaRadians, std::optional< std::string > tipLink=std::nullopt)
 
virtual void generateTrajectory () override
 
virtual void createMarkers () override
 
- Public Member Functions inherited from cl_moveit2z::CbMoveEndEffectorTrajectory
 CbMoveEndEffectorTrajectory (std::optional< std::string > tipLink=std::nullopt)
 
 CbMoveEndEffectorTrajectory (const std::vector< geometry_msgs::msg::PoseStamped > &endEffectorTrajectory, std::optional< std::string > tipLink=std::nullopt)
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual void onExit () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 

Public Attributes

std::optional< std::string > tipLink
 
- Public Attributes inherited from cl_moveit2z::CbCircularPivotMotion
std::optional< double > angularSpeed_rad_s_
 
std::optional< double > linearSpeed_m_s_
 
std::optional< geometry_msgs::msg::Pose > relativeInitialPose_
 
- Public Attributes inherited from cl_moveit2z::CbMoveEndEffectorTrajectory
std::optional< std::string > group_
 
std::optional< std::string > tipLink_
 
std::optional< boolallowInitialTrajectoryStateJointDiscontinuity_
 

Additional Inherited Members

- Protected Member Functions inherited from cl_moveit2z::CbMoveEndEffectorTrajectory
ComputeJointTrajectoryErrorCode computeJointSpaceTrajectory (moveit_msgs::msg::RobotTrajectory &computedJointTrajectory)
 
void executeJointSpaceTrajectory (const moveit_msgs::msg::RobotTrajectory &computedJointTrajectory)
 
void getCurrentEndEffectorPose (std::string globalFrame, tf2::Stamped< tf2::Transform > &currentEndEffectorTransform)
 
- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 onEntry is executed in a new thread. However the current state cannot be left until the onEntry thread finishes. This flag can be checked from the onEntry thread to force finishing the thread.
 
- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
- Protected Attributes inherited from cl_moveit2z::CbCircularPivotMotion
geometry_msgs::msg::PoseStamped planePivotPose_
 
double deltaRadians_
 
- Protected Attributes inherited from cl_moveit2z::CbMoveEndEffectorTrajectory
std::vector< geometry_msgs::msg::PoseStamped > endEffectorTrajectory_
 
CpMoveGroupInterfacecpMoveGroup_ = nullptr
 
visualization_msgs::msg::MarkerArray beahiorMarkers_
 

Detailed Description

Definition at line 34 of file cb_end_effector_rotate.hpp.

Constructor & Destructor Documentation

◆ CbEndEffectorRotate()

cl_moveit2z::CbEndEffectorRotate::CbEndEffectorRotate ( double deltaRadians,
std::optional< std::string > tipLink = std::nullopt )
inline

Definition at line 37 of file cb_end_effector_rotate.hpp.

39 {
40 deltaRadians_ = deltaRadians;
41 }
CbCircularPivotMotion(std::optional< std::string > tipLink=std::nullopt)

References cl_moveit2z::CbCircularPivotMotion::deltaRadians_.

◆ ~CbEndEffectorRotate()

virtual cl_moveit2z::CbEndEffectorRotate::~CbEndEffectorRotate ( )
inlinevirtual

Definition at line 43 of file cb_end_effector_rotate.hpp.

43{}

Member Function Documentation

◆ onEntry()

virtual void cl_moveit2z::CbEndEffectorRotate::onEntry ( )
inlineoverridevirtual

Reimplemented from cl_moveit2z::CbMoveEndEffectorTrajectory.

Definition at line 45 of file cb_end_effector_rotate.hpp.

46 {
47 // Use CpTfListener component for transform lookups
48 CpTfListener * tfListener = nullptr;
49 this->requiresComponent(tfListener, smacc2::ComponentRequirement::SOFT); // Optional component
50
51 tf2::Stamped<tf2::Transform> endEffectorInPivotFrame;
52
53 int attempts = 3;
54
56 if (!tipLink_)
57 {
58 tipLink_ = this->cpMoveGroup_->moveGroupClientInterface->getEndEffectorLink();
59 RCLCPP_WARN_STREAM(
60 getLogger(),
61 "[" << getName() << "] tip unspecified, using default end effector: " << *tipLink_);
62 }
63
64 while (attempts > 0)
65 {
66 try
67 {
68 auto pivotFrameName = this->cpMoveGroup_->moveGroupClientInterface->getEndEffectorLink();
69
70 if (tfListener != nullptr)
71 {
72 // Use component-based TF listener (preferred)
73 auto transformOpt =
74 tfListener->lookupTransform(pivotFrameName, *tipLink_, rclcpp::Time());
75
76 if (transformOpt)
77 {
78 tf2::fromMsg(transformOpt.value(), endEffectorInPivotFrame);
79 tf2::toMsg(endEffectorInPivotFrame, this->planePivotPose_.pose);
80 this->planePivotPose_.header.frame_id = endEffectorInPivotFrame.frame_id_;
81 this->planePivotPose_.header.stamp =
82 rclcpp::Time(endEffectorInPivotFrame.stamp_.time_since_epoch().count());
83 break;
84 }
85 else
86 {
87 RCLCPP_ERROR_STREAM(
88 getLogger(), "[" << getName() << "] Failed to lookup transform from " << *tipLink_
89 << " to " << pivotFrameName << ". Attempt countdown: " << attempts);
90 rclcpp::sleep_for(500ms);
91 attempts--;
92 }
93 }
94 else
95 {
96 // Fallback to legacy TF2 usage if component not available
97 RCLCPP_WARN_STREAM(
98 getLogger(),
99 "[" << getName()
100 << "] CpTfListener component not available, using legacy TF2 (consider "
101 "adding CpTfListener component)");
102 tf2_ros::Buffer tfBuffer(getNode()->get_clock());
103 tf2_ros::TransformListener tfListenerLegacy(tfBuffer);
104
105 tf2::fromMsg(
106 tfBuffer.lookupTransform(
107 pivotFrameName, *tipLink_, rclcpp::Time(), rclcpp::Duration(10s)),
108 endEffectorInPivotFrame);
109
110 tf2::toMsg(endEffectorInPivotFrame, this->planePivotPose_.pose);
111 this->planePivotPose_.header.frame_id = endEffectorInPivotFrame.frame_id_;
112 this->planePivotPose_.header.stamp =
113 rclcpp::Time(endEffectorInPivotFrame.stamp_.time_since_epoch().count());
114 break;
115 }
116 }
117 catch (const std::exception & e)
118 {
119 RCLCPP_ERROR_STREAM(getLogger(), e.what() << ". Attempt countdown: " << attempts);
120 rclcpp::sleep_for(500ms);
121 attempts--;
122 }
123 }
124
125 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] pivotPose: " << planePivotPose_);
126
127 RCLCPP_INFO_STREAM(
128 getLogger(), "[" << getName() << "] calling base CbCircularPivotMotion::onEntry");
130 }
geometry_msgs::msg::PoseStamped planePivotPose_
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)

References cl_moveit2z::CbMoveEndEffectorTrajectory::cpMoveGroup_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccClientBehavior::getNode(), cl_moveit2z::CpTfListener::lookupTransform(), cl_moveit2z::CpMoveGroupInterface::moveGroupClientInterface, smacc2::ISmaccClientBehavior::onEntry(), cl_moveit2z::CbCircularPivotMotion::planePivotPose_, smacc2::ISmaccClientBehavior::requiresComponent(), smacc2::SOFT, and cl_moveit2z::CbMoveEndEffectorTrajectory::tipLink_.

Here is the call graph for this function:

Member Data Documentation

◆ tipLink

std::optional<std::string> cl_moveit2z::CbEndEffectorRotate::tipLink

Definition at line 132 of file cb_end_effector_rotate.hpp.


The documentation for this class was generated from the following file: