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

Client behavior that detaches the currently attached collision object. More...

#include <cb_detach_object.hpp>

Inheritance diagram for cl_moveit2z::CbDetachObject:
Inheritance graph
Collaboration diagram for cl_moveit2z::CbDetachObject:
Collaboration graph

Public Member Functions

void onEntry () override
 Called when the behavior is entered.
 
void onExit () override
 Called when the behavior is exited.
 
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)
 

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 detaches the currently attached collision object.

This behavior detaches whatever object is currently attached to the robot's gripper (tracked in CpGraspingComponent::currentAttachedObjectName) and removes it from the planning scene. Posts success or failure event based on the detach operation result.

Definition at line 30 of file cb_detach_object.hpp.

Member Function Documentation

◆ onEntry() [1/2]

void cl_moveit2z::CbDetachObject::onEntry ( )
inlineoverridevirtual

Called when the behavior is entered.

Retrieves the currently attached object name from CpGraspingComponent, detaches it from the gripper, and removes it from the planning scene.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 46 of file cb_detach_object.hpp.

47 {
48 cl_moveit2z::CpGraspingComponent * graspingComponent;
49 this->requiresComponent(graspingComponent);
50
51 cl_moveit2z::ClMoveit2z * moveGroupClient;
52 this->requiresClient(moveGroupClient);
53
54 if (graspingComponent->currentAttachedObjectName)
55 {
56 RCLCPP_INFO_STREAM(
57 getLogger(),
58 "[CbDetachObject] Detaching object: " << *(graspingComponent->currentAttachedObjectName));
59
60 auto & planningSceneInterface = moveGroupClient->planningSceneInterface;
61 auto res = moveGroupClient->moveGroupClientInterface->detachObject(
62 *(graspingComponent->currentAttachedObjectName));
63
64 planningSceneInterface->removeCollisionObjects(
65 {*(graspingComponent->currentAttachedObjectName)});
66
67 if (res)
68 {
69 RCLCPP_INFO(getLogger(), "[CbDetachObject] Detach succeeded");
70 this->postSuccessEvent();
71 }
72 else
73 {
74 RCLCPP_ERROR(getLogger(), "[CbDetachObject] Detach failed");
75 this->postFailureEvent();
76 }
77 }
78 else
79 {
80 RCLCPP_ERROR(getLogger(), "[CbDetachObject] No object currently attached");
81 this->postFailureEvent();
82 }
83 }
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
std::shared_ptr< moveit::planning_interface::PlanningSceneInterface > planningSceneInterface
std::optional< std::string > currentAttachedObjectName
void requiresComponent(SmaccComponentType *&storage, bool throwExceptionIfNotExist)
virtual rclcpp::Logger getLogger() const
void requiresClient(SmaccClientType *&storage)

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

Here is the call graph for this function:

◆ onEntry() [2/2]

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

Reimplemented from smacc2::ISmaccClientBehavior.

◆ onExit() [1/2]

void cl_moveit2z::CbDetachObject::onExit ( )
inlineoverridevirtual

Called when the behavior is exited.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 88 of file cb_detach_object.hpp.

88{}

◆ onExit() [2/2]

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

Reimplemented from smacc2::ISmaccClientBehavior.


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