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

template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 Called when the behavior is entered.
 
void onEntry () override
 
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)
 

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

Member Function Documentation

◆ onEntry()

void cl_moveit2z::CbDetachObject::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 55 of file cb_detach_object.hpp.

56 {
57 // components resolved in onStateOrthogonalAllocation
58 auto * graspingComponent = graspingComponent_;
59 auto * cpMoveGroup = cpMoveGroup_;
60
61 if (graspingComponent->currentAttachedObjectName)
62 {
63 RCLCPP_INFO_STREAM(
64 getLogger(),
65 "[CbDetachObject] Detaching object: " << *(graspingComponent->currentAttachedObjectName));
66
67 auto & planningSceneInterface = cpMoveGroup->planningSceneInterface;
68 auto res = cpMoveGroup->moveGroupClientInterface->detachObject(
69 *(graspingComponent->currentAttachedObjectName));
70
71 planningSceneInterface->removeCollisionObjects(
72 {*(graspingComponent->currentAttachedObjectName)});
73
74 if (res)
75 {
76 RCLCPP_INFO(getLogger(), "[CbDetachObject] Detach succeeded");
77 this->postSuccessEvent();
78 }
79 else
80 {
81 RCLCPP_ERROR(getLogger(), "[CbDetachObject] Detach failed");
82 this->postFailureEvent();
83 }
84 }
85 else
86 {
87 RCLCPP_ERROR(getLogger(), "[CbDetachObject] No object currently attached");
88 this->postFailureEvent();
89 }
90 }
cl_moveit2z::CpGraspingComponent * graspingComponent_
virtual rclcpp::Logger getLogger() const

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

Here is the call graph for this function:

◆ onExit()

void cl_moveit2z::CbDetachObject::onExit ( )
inlineoverridevirtual

Called when the behavior is exited.

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 95 of file cb_detach_object.hpp.

95{}

◆ onStateOrthogonalAllocation()

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

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.

Definition at line 49 of file cb_detach_object.hpp.

References graspingComponent_, smacc2::HARD, cl_moveit2z::CbMoveit2zClientBehaviorBase::onStateOrthogonalAllocation(), and smacc2::ISmaccClientBehavior::requiresComponent().

Here is the call graph for this function:

Member Data Documentation

◆ graspingComponent_

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

Definition at line 98 of file cb_detach_object.hpp.

Referenced by onEntry(), and onStateOrthogonalAllocation().


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