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 cl_moveit2z::CbMoveit2zClientBehaviorBase
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~CbMoveit2zClientBehaviorBase ()
 
- 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)
 
template<typename SmaccComponentType >
void requiresComponent (std::string name, 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 cl_moveit2z::CbMoveit2zClientBehaviorBase
void postMotionSuccess ()
 
void postMotionFailure ()
 
- 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_
 
CpTrajectoryVisualizercpTrajectoryVisualizer_ = nullptr
 
CpJointSpaceTrajectoryPlannercpJointSpaceTrajectoryPlanner_ = nullptr
 
CpTfListenercpTfListener_ = nullptr
 
visualization_msgs::msg::MarkerArray beahiorMarkers_
 
- Protected Attributes inherited from cl_moveit2z::CbMoveit2zClientBehaviorBase
CpMoveGroupInterfacecpMoveGroup_ = nullptr
 
CpMotionPlannercpMotionPlanner_ = nullptr
 
CpTrajectoryExecutorcpTrajectoryExecutor_ = nullptr
 
CpTrajectoryHistorycpTrajectoryHistory_ = nullptr
 

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

References cl_moveit2z::CbMoveit2zClientBehaviorBase::cpMoveGroup_, cl_moveit2z::CbMoveEndEffectorTrajectory::cpTfListener_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccClientBehavior::getNode(), cl_moveit2z::CpTfListener::lookupTransform(), cl_moveit2z::CpMoveGroupInterface::moveGroupClientInterface, smacc2::ISmaccClientBehavior::onEntry(), cl_moveit2z::CbCircularPivotMotion::planePivotPose_, 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 130 of file cb_end_effector_rotate.hpp.


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