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

#include <cb_move_to_pose.hpp>

Inheritance diagram for cl_moveit2z::CbMoveToPose:
Inheritance graph
Collaboration diagram for cl_moveit2z::CbMoveToPose:
Collaboration graph

Public Member Functions

 CbMoveToPose ()=default
 
 CbMoveToPose (const MoveToPoseParams &params)
 
void setParams (const MoveToPoseParams &params)
 
void onEntry () 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 ()
 
 SmaccAsyncClientBehavior ()=default
 
 ~SmaccAsyncClientBehavior () override
 
 SmaccAsyncClientBehavior (const SmaccAsyncClientBehavior &)=delete
 
SmaccAsyncClientBehavior & operator= (const SmaccAsyncClientBehavior &)=delete
 
 SmaccAsyncClientBehavior (SmaccAsyncClientBehavior &&)=delete
 
SmaccAsyncClientBehavior & operator= (SmaccAsyncClientBehavior &&)=delete
 
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 ()
 
 ISmaccClientBehavior (const ISmaccClientBehavior &)=delete
 
ISmaccClientBehavior & operator= (const ISmaccClientBehavior &)=delete
 
 ISmaccClientBehavior (ISmaccClientBehavior &&)=delete
 
ISmaccClientBehavior & operator= (ISmaccClientBehavior &&)=delete
 
ISmaccStateMachine * getStateMachine ()
 
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 (const std::string &name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void onExit ()
 

Private Attributes

std::optional< MoveToPoseParams > params_
 

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 ()
 
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 ()
 
ISmaccState * getCurrentState ()
 
void postInitializationFailureEvent (const std::string &what)
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
std::string getTraceStateName () const
 
std::string getTraceOrthogonalName () const
 
- Protected Attributes inherited from cl_moveit2z::CbMoveit2zClientBehaviorBase
CpMoveGroupInterface * cpMoveGroup_ = nullptr
 
CpMotionPlanner * cpMotionPlanner_ = nullptr
 
CpTrajectoryExecutor * cpTrajectoryExecutor_ = nullptr
 
CpTrajectoryHistory * cpTrajectoryHistory_ = nullptr
 

Detailed Description

Definition at line 43 of file cb_move_to_pose.hpp.

Constructor & Destructor Documentation

◆ CbMoveToPose() [1/2]

cl_moveit2z::CbMoveToPose::CbMoveToPose ( )
default

◆ CbMoveToPose() [2/2]

cl_moveit2z::CbMoveToPose::CbMoveToPose ( const MoveToPoseParams & params)
inlineexplicit

Definition at line 48 of file cb_move_to_pose.hpp.

48: params_(params) {}
std::optional< MoveToPoseParams > params_

Member Function Documentation

◆ onEntry()

void cl_moveit2z::CbMoveToPose::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 52 of file cb_move_to_pose.hpp.

53 {
54 if (!params_)
55 {
56 RCLCPP_INFO(getLogger(), "[CbMoveToPose] no pose given: idle");
57 return;
58 }
59 if (cpMotionPlanner_ == nullptr)
60 {
61 RCLCPP_ERROR(getLogger(), "[CbMoveToPose] the client has no CpMotionPlanner");
62 this->postMotionFailure();
63 return;
64 }
65
66 PlanningOptions options;
67 options.planningTime = params_->planningTime;
68 options.maxVelocityScaling = params_->velocityScaling;
69 options.maxAccelerationScaling = params_->accelerationScaling;
70 const std::optional<std::string> tipLink =
71 params_->tipLink.empty() ? std::nullopt : std::optional<std::string>(params_->tipLink);
72
73 const auto planned = cpMotionPlanner_->planToPose(params_->pose, tipLink, options);
74 if (!planned.success)
75 {
76 RCLCPP_WARN(getLogger(), "[CbMoveToPose] no plan: %s", planned.errorMessage.c_str());
77 this->postMotionFailure();
78 return;
79 }
80
81 bool executed = false;
82 if (cpTrajectoryExecutor_ != nullptr)
83 {
84 ExecutionOptions executionOptions;
85 executionOptions.trajectoryName = this->getName();
86 executed = cpTrajectoryExecutor_->executePlan(planned.plan, executionOptions).success;
87 }
88 else
89 {
90 executed = cpMoveGroup_->moveGroupClientInterface->execute(planned.plan) ==
91 moveit::core::MoveItErrorCode::SUCCESS;
92 }
93
94 if (executed)
95 {
96 this->postMotionSuccess();
97 }
98 else
99 {
100 RCLCPP_WARN(getLogger(), "[CbMoveToPose] the execution failed");
101 this->postMotionFailure();
102 }
103 }
PlanningResult planToPose(const geometry_msgs::msg::PoseStamped &target, const std::optional< std::string > &tipLink=std::nullopt, const PlanningOptions &options={})
Plan to a Cartesian pose.
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
ExecutionResult executePlan(const moveit::planning_interface::MoveGroupInterface::Plan &plan, const ExecutionOptions &options={})
Execute a motion plan synchronously.
virtual rclcpp::Logger getLogger() const

References cl_moveit2z::CbMoveit2zClientBehaviorBase::cpMotionPlanner_, cl_moveit2z::CbMoveit2zClientBehaviorBase::cpMoveGroup_, cl_moveit2z::CbMoveit2zClientBehaviorBase::cpTrajectoryExecutor_, cl_moveit2z::CpTrajectoryExecutor::executePlan(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), cl_moveit2z::PlanningOptions::maxAccelerationScaling, cl_moveit2z::PlanningOptions::maxVelocityScaling, cl_moveit2z::CpMoveGroupInterface::moveGroupClientInterface, params_, cl_moveit2z::PlanningOptions::planningTime, cl_moveit2z::CpMotionPlanner::planToPose(), cl_moveit2z::CbMoveit2zClientBehaviorBase::postMotionFailure(), cl_moveit2z::CbMoveit2zClientBehaviorBase::postMotionSuccess(), cl_moveit2z::ExecutionResult::success, and cl_moveit2z::ExecutionOptions::trajectoryName.

Here is the call graph for this function:

◆ setParams()

void cl_moveit2z::CbMoveToPose::setParams ( const MoveToPoseParams & params)
inline

Definition at line 50 of file cb_move_to_pose.hpp.

50{ params_ = params; }

References params_.

Member Data Documentation

◆ params_

std::optional<MoveToPoseParams> cl_moveit2z::CbMoveToPose::params_
private

Definition at line 106 of file cb_move_to_pose.hpp.

Referenced by onEntry(), and setParams().


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