SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | List of all members
cl_move_group_interface::CbCircularPouringMotion Class Reference

#include <cb_pouring_motion.h>

Inheritance diagram for cl_move_group_interface::CbCircularPouringMotion:
Inheritance graph
Collaboration diagram for cl_move_group_interface::CbCircularPouringMotion:
Collaboration graph

Public Member Functions

 CbCircularPouringMotion (const geometry_msgs::Point &pivotPoint, double deltaHeight, std::string tipLink, std::string globalFrame)
 
virtual void generateTrajectory () override
 
virtual void createMarkers () override
 
- Public Member Functions inherited from cl_move_group_interface::CbMoveEndEffectorTrajectory
 CbMoveEndEffectorTrajectory (std::string tipLink="")
 
 CbMoveEndEffectorTrajectory (const std::vector< geometry_msgs::PoseStamped > &endEffectorTrajectory, std::string tipLink="")
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual void onEntry () override
 
virtual void onExit () override
 
virtual void update () override
 
- Public Member Functions inherited from smacc::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)
 
- Public Member Functions inherited from smacc::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
ros::NodeHandle getNode ()
 
- Public Member Functions inherited from smacc::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (ros::Duration duration)
 
void executeUpdate ()
 
void setUpdatePeriod (ros::Duration duration)
 

Public Attributes

boost::optional< double > angularSpeed_rad_s_
 
boost::optional< double > linearSpeed_m_s_
 
geometry_msgs::Vector3 directionVector_
 
geometry_msgs::Pose pointerRelativePose_
 
- Public Attributes inherited from cl_move_group_interface::CbMoveEndEffectorTrajectory
boost::optional< std::string > group_
 
boost::optional< std::string > tipLink_
 
boost::optional< boolallowInitialTrajectoryStateJointDiscontinuity_
 

Protected Attributes

geometry_msgs::Point relativePivotPoint_
 
double deltaHeight_
 
std::vector< geometry_msgs::PoseStamped > pointerTrajectory_
 
- Protected Attributes inherited from cl_move_group_interface::CbMoveEndEffectorTrajectory
std::vector< geometry_msgs::PoseStamped > endEffectorTrajectory_
 
ClMoveGroupmovegroupClient_ = nullptr
 
visualization_msgs::MarkerArray beahiorMarkers_
 

Private Member Functions

void computeCurrentEndEffectorPoseRelativeToPivot ()
 

Private Attributes

std::string globalFrame_
 

Additional Inherited Members

- Protected Member Functions inherited from cl_move_group_interface::CbMoveEndEffectorTrajectory
ComputeJointTrajectoryErrorCode computeJointSpaceTrajectory (moveit_msgs::RobotTrajectory &computedJointTrajectory)
 
void executeJointSpaceTrajectory (const moveit_msgs::RobotTrajectory &computedJointTrajectory)
 
virtual void generateTrajectory ()
 
virtual void createMarkers ()
 
void getCurrentEndEffectorPose (std::string globalFrame, tf::StampedTransform &currentEndEffectorTransform)
 
- Protected Member Functions inherited from smacc::SmaccAsyncClientBehavior
virtual void executeOnEntry () override
 
virtual void executeOnExit () override
 
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
- Protected Member Functions inherited from smacc::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 
virtual void dispose ()
 
virtual void update ()=0
 

Detailed Description

Definition at line 14 of file cb_pouring_motion.h.

Constructor & Destructor Documentation

◆ CbCircularPouringMotion()

cl_move_group_interface::CbCircularPouringMotion::CbCircularPouringMotion ( const geometry_msgs::Point &  pivotPoint,
double  deltaHeight,
std::string  tipLink,
std::string  globalFrame 
)

Member Function Documentation

◆ computeCurrentEndEffectorPoseRelativeToPivot()

void cl_move_group_interface::CbCircularPouringMotion::computeCurrentEndEffectorPoseRelativeToPivot ( )
private

◆ createMarkers()

void cl_move_group_interface::CbCircularPouringMotion::createMarkers ( )
overridevirtual

Reimplemented from cl_move_group_interface::CbMoveEndEffectorTrajectory.

Definition at line 118 of file cb_pouring_motion.cpp.

119 {
121
122 tf::StampedTransform currentEndEffectorTransform;
123 this->getCurrentEndEffectorPose(globalFrame_, currentEndEffectorTransform);
124 tf::Point pivotPoint;
125 tf::pointMsgToTF(this->relativePivotPoint_, pivotPoint);
126 tf::Vector3 pivot = (currentEndEffectorTransform * pivotPoint);
127
128
129 visualization_msgs::Marker marker;
130
131 marker.ns = "trajectory";
132 marker.id = beahiorMarkers_.markers.size();
133 marker.type = visualization_msgs::Marker::SPHERE;
134 marker.action = visualization_msgs::Marker::ADD;
135 marker.scale.x = 0.01;
136 marker.scale.y = 0.01;
137 marker.scale.z = 0.01;
138
139 marker.color.a = 1.0;
140 marker.color.r = 0.0;
141 marker.color.g = 0;
142 marker.color.b = 1.0;
143
144 tf::pointTFToMsg(pivot, marker.pose.position);
145 marker.header.frame_id = globalFrame_;
146 marker.header.stamp = ros::Time::now();
147
148 beahiorMarkers_.markers.push_back(marker);
149
150 tf::Transform localdirection;
151 localdirection.setIdentity();
152 localdirection.setOrigin(tf::Vector3(0.05, 0, 0));
153 auto frameid = this->pointerTrajectory_.front().header.frame_id;
154
155 for (auto &pose : this->pointerTrajectory_)
156 {
157 visualization_msgs::Marker marker;
158 marker.header.frame_id = frameid;
159 marker.header.stamp = ros::Time::now();
160 marker.ns = "trajectory";
161 marker.id = this->beahiorMarkers_.markers.size();
162 marker.type = visualization_msgs::Marker::ARROW;
163 marker.action = visualization_msgs::Marker::ADD;
164 marker.scale.x = 0.005;
165 marker.scale.y = 0.01;
166 marker.scale.z = 0.01;
167 marker.color.a = 0.8;
168 marker.color.r = 0.0;
169 marker.color.g = 1;
170 marker.color.b = 0.0;
171
172 geometry_msgs::Point start, end;
173 start.x = 0;
174 start.y = 0;
175 start.z = 0;
176
177 tf::Transform basetransform;
178 tf::poseMsgToTF(pose.pose, basetransform);
179 tf::Transform endarrow = localdirection * basetransform;
180
181 end.x = localdirection.getOrigin().x();
182 end.y = localdirection.getOrigin().y();
183 end.z = localdirection.getOrigin().z();
184
185 marker.pose.position = pose.pose.position;
186 marker.pose.orientation = pose.pose.orientation;
187 marker.points.push_back(start);
188 marker.points.push_back(end);
189
190 beahiorMarkers_.markers.push_back(marker);
191 }
192 }
std::vector< geometry_msgs::PoseStamped > pointerTrajectory_
void getCurrentEndEffectorPose(std::string globalFrame, tf::StampedTransform &currentEndEffectorTransform)

References cl_move_group_interface::CbMoveEndEffectorTrajectory::beahiorMarkers_, cl_move_group_interface::CbMoveEndEffectorTrajectory::createMarkers(), cl_move_group_interface::CbMoveEndEffectorTrajectory::getCurrentEndEffectorPose(), globalFrame_, pointerTrajectory_, and relativePivotPoint_.

Here is the call graph for this function:

◆ generateTrajectory()

void cl_move_group_interface::CbCircularPouringMotion::generateTrajectory ( )
overridevirtual

Reimplemented from cl_move_group_interface::CbMoveEndEffectorTrajectory.

Definition at line 21 of file cb_pouring_motion.cpp.

22 {
23 // at least 1 sample per centimeter (average)
24 const double METERS_PER_SAMPLE = 0.001;
25
26 float dist_meters =0;
27 float totallineardist = fabs(this->deltaHeight_);
28
29 int totalSamplesCount = totallineardist / METERS_PER_SAMPLE;
30 int steps = totallineardist/ METERS_PER_SAMPLE;
31
32 float interpolation_factor_step = 1.0/totalSamplesCount;
33
34 double secondsPerSample;
35
37 {
38 secondsPerSample = METERS_PER_SAMPLE / (*linearSpeed_m_s_);
39 }
40 else
41 {
42 secondsPerSample = std::numeric_limits<double>::max();
43 }
44
45 tf::StampedTransform currentEndEffectorTransform;
46
47 this->getCurrentEndEffectorPose(globalFrame_, currentEndEffectorTransform);
48
49 tf::Transform lidEndEffectorTransform;
50 tf::poseMsgToTF(this->pointerRelativePose_, lidEndEffectorTransform);
51
52 tf::Vector3 v0, v1;
53 v0 = (currentEndEffectorTransform * lidEndEffectorTransform).getOrigin();
54
55 tf::Point pivotPoint;
56 tf::pointMsgToTF(this->relativePivotPoint_, pivotPoint);
57
58 tf::Vector3 pivot = (currentEndEffectorTransform * pivotPoint);
59
60 v0 = v0 - pivot;
61 v1 = v0;
62 v1.setZ(v1.z() + this->deltaHeight_);
63
64 tf::Vector3 vp1(v1);
65 tf::Vector3 vp0(v0);
66 tf::Quaternion rotation = tf::shortestArcQuatNormalize2(vp0, vp1);
67
68 tf::Quaternion initialEndEffectorOrientation = currentEndEffectorTransform.getRotation();
69 auto finalEndEffectorOrientation = initialEndEffectorOrientation* rotation;
70
71 tf::Quaternion initialPointerOrientation = initialEndEffectorOrientation * lidEndEffectorTransform.getRotation();
72 tf::Quaternion finalPointerOrientation = finalEndEffectorOrientation * lidEndEffectorTransform.getRotation();
73
74 auto shortestAngle = tf::angleShortestPath(initialEndEffectorOrientation, finalEndEffectorOrientation);
75
76 v0+=pivot;
77 v1+=pivot;
78
79 float linc = deltaHeight_/steps;// METERS_PER_SAMPLE with sign
80 float interpolation_factor = 0;
81 tf::Vector3 vi = v0;
82
83 tf::Transform invertedLidTransform = lidEndEffectorTransform.inverse();
84 ros::Time startTime = ros::Time::now();
85
86 for (float i =0; i < steps; i++)
87 {
88 auto currentEndEffectorOrientation = tf::slerp(initialEndEffectorOrientation, finalEndEffectorOrientation, interpolation_factor);
89 auto currentPointerOrientation = tf::slerp(initialPointerOrientation, finalPointerOrientation, interpolation_factor);
90
91 interpolation_factor += interpolation_factor_step;
92 dist_meters += linc;
93
94 vi = v0;
95 vi.setZ(vi.getZ() + dist_meters);
96
97 tf::Transform pose;
98 pose.setOrigin(vi);
99 pose.setRotation(currentPointerOrientation);
100
101 geometry_msgs::PoseStamped pointerPose;
102 tf::poseTFToMsg(pose, pointerPose.pose);
103 pointerPose.header.frame_id = globalFrame_;
104 pointerPose.header.stamp = startTime + ros::Duration(i * secondsPerSample);
105 this->pointerTrajectory_.push_back(pointerPose);
106
107 tf::Transform poseEndEffector = pose * invertedLidTransform;
108
109 geometry_msgs::PoseStamped globalEndEffectorPose;
110 tf::poseTFToMsg(poseEndEffector, globalEndEffectorPose.pose);
111 globalEndEffectorPose.header.frame_id = globalFrame_;
112 globalEndEffectorPose.header.stamp = startTime + ros::Duration(i * secondsPerSample);
113
114 this->endEffectorTrajectory_.push_back(globalEndEffectorPose);
115 }
116 }
std::vector< geometry_msgs::PoseStamped > endEffectorTrajectory_

References deltaHeight_, cl_move_group_interface::CbMoveEndEffectorTrajectory::endEffectorTrajectory_, cl_move_group_interface::CbMoveEndEffectorTrajectory::getCurrentEndEffectorPose(), globalFrame_, linearSpeed_m_s_, pointerRelativePose_, pointerTrajectory_, and relativePivotPoint_.

Here is the call graph for this function:

Member Data Documentation

◆ angularSpeed_rad_s_

boost::optional<double> cl_move_group_interface::CbCircularPouringMotion::angularSpeed_rad_s_

Definition at line 17 of file cb_pouring_motion.h.

◆ deltaHeight_

double cl_move_group_interface::CbCircularPouringMotion::deltaHeight_
protected

Definition at line 36 of file cb_pouring_motion.h.

Referenced by generateTrajectory().

◆ directionVector_

geometry_msgs::Vector3 cl_move_group_interface::CbCircularPouringMotion::directionVector_

Definition at line 27 of file cb_pouring_motion.h.

◆ globalFrame_

std::string cl_move_group_interface::CbCircularPouringMotion::globalFrame_
private

Definition at line 43 of file cb_pouring_motion.h.

Referenced by createMarkers(), and generateTrajectory().

◆ linearSpeed_m_s_

boost::optional<double> cl_move_group_interface::CbCircularPouringMotion::linearSpeed_m_s_

Definition at line 19 of file cb_pouring_motion.h.

Referenced by generateTrajectory().

◆ pointerRelativePose_

geometry_msgs::Pose cl_move_group_interface::CbCircularPouringMotion::pointerRelativePose_

Definition at line 31 of file cb_pouring_motion.h.

Referenced by generateTrajectory().

◆ pointerTrajectory_

std::vector<geometry_msgs::PoseStamped> cl_move_group_interface::CbCircularPouringMotion::pointerTrajectory_
protected

Definition at line 38 of file cb_pouring_motion.h.

Referenced by createMarkers(), and generateTrajectory().

◆ relativePivotPoint_

geometry_msgs::Point cl_move_group_interface::CbCircularPouringMotion::relativePivotPoint_
protected

Definition at line 33 of file cb_pouring_motion.h.

Referenced by createMarkers(), and generateTrajectory().


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