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
 
 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
 
 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 onOrthogonalAllocation ()
 
virtual void onExit () override
 
 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 onOrthogonalAllocation ()
 
virtual void onExit () override
 
virtual void update () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
boost::signals2::connection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection 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, bool throwExceptionIfNotExist)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

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< bool > allowInitialTrajectoryStateJointDiscontinuity_
 

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)
 
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 Member Functions inherited from smacc2::ISmaccUpdatable
- 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_
 
ClMoveit2zmovegroupClient_ = nullptr
 
visualization_msgs::msg::MarkerArray beahiorMarkers_
 

Detailed Description

Definition at line 26 of file cb_end_effector_rotate.hpp.

Constructor & Destructor Documentation

◆ CbEndEffectorRotate() [1/2]

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() [1/2]

cl_moveit2z::CbEndEffectorRotate::~CbEndEffectorRotate ( )
inlinevirtual

Definition at line 43 of file cb_end_effector_rotate.hpp.

43{}

◆ CbEndEffectorRotate() [2/2]

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

◆ ~CbEndEffectorRotate() [2/2]

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

Member Function Documentation

◆ onEntry() [1/2]

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

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccClientBehavior::getNode(), cl_moveit2z::CpTfListener::lookupTransform(), cl_moveit2z::CbMoveEndEffectorTrajectory::movegroupClient_, cl_moveit2z::ClMoveit2z::moveGroupClientInterface, smacc2::ISmaccClientBehavior::onEntry(), cl_moveit2z::CbCircularPivotMotion::planePivotPose_, smacc2::ISmaccClientBehavior::requiresClient(), smacc2::ISmaccClientBehavior::requiresComponent(), and cl_moveit2z::CbMoveEndEffectorTrajectory::tipLink_.

Here is the call graph for this function:

◆ onEntry() [2/2]

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

Member Data Documentation

◆ tipLink

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

Definition at line 133 of file cb_end_effector_rotate.hpp.


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