SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
cl_moveit2z::CbMoveJoints Class Reference

#include <cb_move_joints.hpp>

Inheritance diagram for cl_moveit2z::CbMoveJoints:
Inheritance graph
Collaboration diagram for cl_moveit2z::CbMoveJoints:
Collaboration graph

Public Member Functions

 CbMoveJoints ()
 
 CbMoveJoints (const std::map< std::string, double > &jointValueTarget)
 
virtual void onEntry () override
 
virtual void onExit () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
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=false)
 

Public Attributes

std::optional< double > scalingFactor_
 
std::map< std::string, double > jointValueTarget_
 
std::optional< std::string > group_
 

Protected Member Functions

void moveJoints (moveit::planning_interface::MoveGroupInterface &moveGroupInterface)
 
- 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

ClMoveit2zmovegroupClient_
 

Detailed Description

Definition at line 31 of file cb_move_joints.hpp.

Constructor & Destructor Documentation

◆ CbMoveJoints() [1/2]

cl_moveit2z::CbMoveJoints::CbMoveJoints ( )

Definition at line 31 of file cb_move_joints.cpp.

31{}

◆ CbMoveJoints() [2/2]

cl_moveit2z::CbMoveJoints::CbMoveJoints ( const std::map< std::string, double > &  jointValueTarget)

Definition at line 26 of file cb_move_joints.cpp.

27: jointValueTarget_(jointValueTarget)
28{
29}
std::map< std::string, double > jointValueTarget_

Member Function Documentation

◆ moveJoints()

void cl_moveit2z::CbMoveJoints::moveJoints ( moveit::planning_interface::MoveGroupInterface &  moveGroupInterface)
protected

Definition at line 72 of file cb_move_joints.cpp.

73{
74 if (scalingFactor_) moveGroupInterface.setMaxVelocityScalingFactor(*scalingFactor_);
75
76 bool success;
77 moveit::planning_interface::MoveGroupInterface::Plan computedMotionPlan;
78
79 if (jointValueTarget_.size() == 0)
80 {
81 RCLCPP_WARN(
82 getLogger(), "[CbMoveJoints] No joint was value specified. Skipping planning call.");
83 success = false;
84 }
85 else
86 {
87 moveGroupInterface.setJointValueTarget(jointValueTarget_);
88 //moveGroupInterface.setGoalJointTolerance(0.01);
89
90 auto result = moveGroupInterface.plan(computedMotionPlan);
91
92 success = (result == moveit::core::MoveItErrorCode::SUCCESS);
93
94 RCLCPP_INFO(
95 getLogger(), "[CbMoveJoints] Execution plan result %s (%d)", success ? "SUCCESS" : "FAILED",
96 result.val);
97 }
98
99 if (success)
100 {
101 auto executionResult = moveGroupInterface.execute(computedMotionPlan);
102
103 //auto statestr = currentJointStatesToString(moveGroupInterface, jointValueTarget_);
104
105 if (executionResult == moveit_msgs::msg::MoveItErrorCodes::SUCCESS)
106 {
107 RCLCPP_INFO_STREAM(
108 getLogger(), "[" << this->getName()
109 << "] motion execution succeeded. Throwing success event. " << std::endl
110 // << statestr
111 );
113 this->postSuccessEvent();
114 }
115 else
116 {
117 RCLCPP_WARN_STREAM(
118 getLogger(),
119 "[" << this->getName() << "] motion execution failed. Throwing fail event." << std::endl
120 // << statestr
121 );
123 this->postFailureEvent();
124 }
125 }
126 else
127 {
128 auto statestr = currentJointStatesToString(moveGroupInterface, jointValueTarget_);
129 RCLCPP_WARN_STREAM(
130 getLogger(),
131 "[" << this->getName() << "] motion execution failed. Throwing fail event." << std::endl
132 // << statestr
133 );
135 this->postFailureEvent();
136 }
137}
std::optional< double > scalingFactor_
void postEventMotionExecutionSucceded()
virtual rclcpp::Logger getLogger() const
std::string currentJointStatesToString(moveit::planning_interface::MoveGroupInterface &moveGroupInterface, std::map< std::string, double > &targetJoints)

References cl_moveit2z::currentJointStatesToString(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), jointValueTarget_, movegroupClient_, cl_moveit2z::ClMoveit2z::postEventMotionExecutionFailed(), cl_moveit2z::ClMoveit2z::postEventMotionExecutionSucceded(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), and scalingFactor_.

Referenced by onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onEntry()

void cl_moveit2z::CbMoveJoints::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Reimplemented in cl_moveit2z::CbMoveKnownState, and cl_moveit2z::CbMoveLastTrajectoryInitialState.

Definition at line 33 of file cb_move_joints.cpp.

34{
36
37 if (this->group_)
38 {
39 moveit::planning_interface::MoveGroupInterface move_group(
40 getNode(), moveit::planning_interface::MoveGroupInterface::Options(*(this->group_)));
41 this->moveJoints(move_group);
42 }
43 else
44 {
46 }
47}
void moveJoints(moveit::planning_interface::MoveGroupInterface &moveGroupInterface)
std::optional< std::string > group_
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
virtual rclcpp::Node::SharedPtr getNode() const
void requiresClient(SmaccClientType *&storage)

References smacc2::ISmaccClientBehavior::getNode(), group_, movegroupClient_, cl_moveit2z::ClMoveit2z::moveGroupClientInterface, moveJoints(), and smacc2::ISmaccClientBehavior::requiresClient().

Referenced by cl_moveit2z::CbMoveKnownState::onEntry(), and cl_moveit2z::CbMoveLastTrajectoryInitialState::onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onExit()

void cl_moveit2z::CbMoveJoints::onExit ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 139 of file cb_move_joints.cpp.

139{}

Member Data Documentation

◆ group_

std::optional<std::string> cl_moveit2z::CbMoveJoints::group_

Definition at line 36 of file cb_move_joints.hpp.

Referenced by onEntry().

◆ jointValueTarget_

std::map<std::string, double> cl_moveit2z::CbMoveJoints::jointValueTarget_

◆ movegroupClient_

ClMoveit2z* cl_moveit2z::CbMoveJoints::movegroupClient_
protected

Definition at line 45 of file cb_move_joints.hpp.

Referenced by moveJoints(), and onEntry().

◆ scalingFactor_

std::optional<double> cl_moveit2z::CbMoveJoints::scalingFactor_

Definition at line 34 of file cb_move_joints.hpp.

Referenced by moveJoints().


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