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

Client behavior that attaches a collision object to the robot gripper. More...

#include <cb_attach_object.hpp>

Inheritance diagram for cl_moveit2z::CbAttachObject:
Inheritance graph
Collaboration diagram for cl_moveit2z::CbAttachObject:
Collaboration graph

Public Member Functions

 CbAttachObject (std::string targetObjectName)
 Constructor with object name.
 
 CbAttachObject ()
 Default constructor.
 
void onEntry () override
 Called when the behavior is entered.
 
void onExit () override
 Called when the behavior is exited.
 
 CbAttachObject (std::string targetObjectName)
 
 CbAttachObject ()
 
virtual void onEntry () override
 
virtual void onExit () 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 Attributes

std::string targetObjectName_
 Name of the target object to attach.
 

Additional Inherited Members

- 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
 

Detailed Description

Client behavior that attaches a collision object to the robot gripper.

This behavior attaches a previously created grasping object to the robot's end effector. The object must exist in the CpGraspingComponent's graspingObjects map. Upon successful attachment, the object is added to the planning scene and attached to the gripper using the finger tip links.

Definition at line 28 of file cb_attach_object.hpp.

Constructor & Destructor Documentation

◆ CbAttachObject() [1/4]

cl_moveit2z::CbAttachObject::CbAttachObject ( std::string targetObjectName)
inline

Constructor with object name.

Parameters
targetObjectNameName of the object to attach (must exist in CpGraspingComponent)

Definition at line 45 of file cb_attach_object.hpp.

45: targetObjectName_(targetObjectName) {}
std::string targetObjectName_
Name of the target object to attach.

◆ CbAttachObject() [2/4]

cl_moveit2z::CbAttachObject::CbAttachObject ( )
inline

Default constructor.

Definition at line 50 of file cb_attach_object.hpp.

50{}

◆ CbAttachObject() [3/4]

cl_moveit2z::CbAttachObject::CbAttachObject ( std::string targetObjectName)

◆ CbAttachObject() [4/4]

cl_moveit2z::CbAttachObject::CbAttachObject ( )

Member Function Documentation

◆ onEntry() [1/2]

void cl_moveit2z::CbAttachObject::onEntry ( )
inlineoverridevirtual

Called when the behavior is entered.

Retrieves the target object from CpGraspingComponent, adds it to the planning scene, and attaches it to the gripper. Posts success or failure event based on whether the object was found.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 59 of file cb_attach_object.hpp.

60 {
61 cl_moveit2z::ClMoveit2z * moveGroup;
62 this->requiresClient(moveGroup);
63
64 cl_moveit2z::CpGraspingComponent * graspingComponent;
65 this->requiresComponent(graspingComponent);
66
67 moveit_msgs::msg::CollisionObject targetCollisionObject;
68 bool found = graspingComponent->getGraspingObject(targetObjectName_, targetCollisionObject);
69
70 if (found)
71 {
72 RCLCPP_INFO_STREAM(getLogger(), "[CbAttachObject] Attaching object: " << targetObjectName_);
73
74 targetCollisionObject.operation = moveit_msgs::msg::CollisionObject::ADD;
75 targetCollisionObject.header.stamp = getNode()->now();
76
77 moveGroup->planningSceneInterface->applyCollisionObject(targetCollisionObject);
79
80 moveGroup->moveGroupClientInterface->attachObject(
81 targetObjectName_, graspingComponent->gripperLink_, graspingComponent->fingerTipNames);
82
83 this->postSuccessEvent();
84 }
85 else
86 {
87 RCLCPP_ERROR_STREAM(
88 getLogger(),
89 "[CbAttachObject] Object not found in grasping component: " << targetObjectName_);
90 this->postFailureEvent();
91 }
92 }
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
std::shared_ptr< moveit::planning_interface::PlanningSceneInterface > planningSceneInterface
std::optional< std::string > currentAttachedObjectName
std::vector< std::string > fingerTipNames
bool getGraspingObject(std::string name, moveit_msgs::msg::CollisionObject &object)
void requiresComponent(SmaccComponentType *&storage, bool throwExceptionIfNotExist)
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
void requiresClient(SmaccClientType *&storage)

References cl_moveit2z::CpGraspingComponent::currentAttachedObjectName, cl_moveit2z::CpGraspingComponent::fingerTipNames, cl_moveit2z::CpGraspingComponent::getGraspingObject(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getNode(), cl_moveit2z::CpGraspingComponent::gripperLink_, cl_moveit2z::ClMoveit2z::moveGroupClientInterface, cl_moveit2z::ClMoveit2z::planningSceneInterface, smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), smacc2::ISmaccClientBehavior::requiresClient(), smacc2::ISmaccClientBehavior::requiresComponent(), and targetObjectName_.

Here is the call graph for this function:

◆ onEntry() [2/2]

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

Reimplemented from smacc2::ISmaccClientBehavior.

◆ onExit() [1/2]

void cl_moveit2z::CbAttachObject::onExit ( )
inlineoverridevirtual

Called when the behavior is exited.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 97 of file cb_attach_object.hpp.

97{}

◆ onExit() [2/2]

virtual void cl_moveit2z::CbAttachObject::onExit ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Member Data Documentation

◆ targetObjectName_

std::string cl_moveit2z::CbAttachObject::targetObjectName_

Name of the target object to attach.

Definition at line 100 of file cb_attach_object.hpp.

Referenced by onEntry().


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