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.
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
void onEntry () override
 Called when the behavior is entered.
 
void onExit () override
 Called when the behavior is exited.
 
- 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::string targetObjectName_
 Name of the target object to attach.
 

Private Attributes

cl_moveit2z::CpGraspingComponentgraspingComponent_ = nullptr
 

Additional Inherited Members

- 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::CbMoveit2zClientBehaviorBase
CpMoveGroupInterfacecpMoveGroup_ = nullptr
 
CpMotionPlannercpMotionPlanner_ = nullptr
 
CpTrajectoryExecutorcpTrajectoryExecutor_ = nullptr
 
CpTrajectoryHistorycpTrajectoryHistory_ = nullptr
 

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 39 of file cb_attach_object.hpp.

Constructor & Destructor Documentation

◆ CbAttachObject() [1/2]

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 46 of file cb_attach_object.hpp.

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

◆ CbAttachObject() [2/2]

cl_moveit2z::CbAttachObject::CbAttachObject ( )
inline

Default constructor.

Definition at line 51 of file cb_attach_object.hpp.

51{}

Member Function Documentation

◆ onEntry()

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 67 of file cb_attach_object.hpp.

68 {
69 // components resolved in onStateOrthogonalAllocation
70 auto * cpMoveGroup = cpMoveGroup_;
71 auto * graspingComponent = graspingComponent_;
72
73 moveit_msgs::msg::CollisionObject targetCollisionObject;
74 bool found = graspingComponent->getGraspingObject(targetObjectName_, targetCollisionObject);
75
76 if (found)
77 {
78 RCLCPP_INFO_STREAM(getLogger(), "[CbAttachObject] Attaching object: " << targetObjectName_);
79
80 targetCollisionObject.operation = moveit_msgs::msg::CollisionObject::ADD;
81 targetCollisionObject.header.stamp = getNode()->now();
82
83 cpMoveGroup->planningSceneInterface->applyCollisionObject(targetCollisionObject);
84 graspingComponent->currentAttachedObjectName = targetObjectName_;
85
86 cpMoveGroup->moveGroupClientInterface->attachObject(
87 targetObjectName_, graspingComponent->gripperLink_, graspingComponent->fingerTipNames);
88
89 this->postSuccessEvent();
90 }
91 else
92 {
93 RCLCPP_ERROR_STREAM(
94 getLogger(),
95 "[CbAttachObject] Object not found in grasping component: " << targetObjectName_);
96 this->postFailureEvent();
97 }
98 }
cl_moveit2z::CpGraspingComponent * graspingComponent_
bool getGraspingObject(std::string name, moveit_msgs::msg::CollisionObject &object)
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const

References cl_moveit2z::CbMoveit2zClientBehaviorBase::cpMoveGroup_, cl_moveit2z::CpGraspingComponent::getGraspingObject(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getNode(), graspingComponent_, smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), and targetObjectName_.

Here is the call graph for this function:

◆ onExit()

void cl_moveit2z::CbAttachObject::onExit ( )
inlineoverridevirtual

Called when the behavior is exited.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 103 of file cb_attach_object.hpp.

103{}

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_moveit2z::CbAttachObject::onStateOrthogonalAllocation ( )
inline

Member Data Documentation

◆ graspingComponent_

cl_moveit2z::CpGraspingComponent* cl_moveit2z::CbAttachObject::graspingComponent_ = nullptr
private

Definition at line 109 of file cb_attach_object.hpp.

Referenced by onEntry(), and onStateOrthogonalAllocation().

◆ targetObjectName_

std::string cl_moveit2z::CbAttachObject::targetObjectName_

Name of the target object to attach.

Definition at line 106 of file cb_attach_object.hpp.

Referenced by onEntry().


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