14 : relativePivotPoint_(relativePivotPoint)
15 , deltaHeight_(deltaHeight)
17 , globalFrame_(globalFrame)
24 const double METERS_PER_SAMPLE = 0.001;
29 int totalSamplesCount = totallineardist / METERS_PER_SAMPLE;
30 int steps = totallineardist/ METERS_PER_SAMPLE;
32 float interpolation_factor_step = 1.0/totalSamplesCount;
34 double secondsPerSample;
38 secondsPerSample = METERS_PER_SAMPLE / (*linearSpeed_m_s_);
42 secondsPerSample = std::numeric_limits<double>::max();
45 tf::StampedTransform currentEndEffectorTransform;
49 tf::Transform lidEndEffectorTransform;
53 v0 = (currentEndEffectorTransform * lidEndEffectorTransform).getOrigin();
58 tf::Vector3 pivot = (currentEndEffectorTransform * pivotPoint);
66 tf::Quaternion rotation = tf::shortestArcQuatNormalize2(vp0, vp1);
68 tf::Quaternion initialEndEffectorOrientation = currentEndEffectorTransform.getRotation();
69 auto finalEndEffectorOrientation = initialEndEffectorOrientation* rotation;
71 tf::Quaternion initialPointerOrientation = initialEndEffectorOrientation * lidEndEffectorTransform.getRotation();
72 tf::Quaternion finalPointerOrientation = finalEndEffectorOrientation * lidEndEffectorTransform.getRotation();
74 auto shortestAngle = tf::angleShortestPath(initialEndEffectorOrientation, finalEndEffectorOrientation);
80 float interpolation_factor = 0;
83 tf::Transform invertedLidTransform = lidEndEffectorTransform.inverse();
84 ros::Time startTime = ros::Time::now();
86 for (
float i =0; i < steps; i++)
88 auto currentEndEffectorOrientation = tf::slerp(initialEndEffectorOrientation, finalEndEffectorOrientation, interpolation_factor);
89 auto currentPointerOrientation = tf::slerp(initialPointerOrientation, finalPointerOrientation, interpolation_factor);
91 interpolation_factor += interpolation_factor_step;
95 vi.setZ(vi.getZ() + dist_meters);
99 pose.setRotation(currentPointerOrientation);
101 geometry_msgs::PoseStamped pointerPose;
102 tf::poseTFToMsg(pose, pointerPose.pose);
104 pointerPose.header.stamp = startTime + ros::Duration(i * secondsPerSample);
107 tf::Transform poseEndEffector = pose * invertedLidTransform;
109 geometry_msgs::PoseStamped globalEndEffectorPose;
110 tf::poseTFToMsg(poseEndEffector, globalEndEffectorPose.pose);
112 globalEndEffectorPose.header.stamp = startTime + ros::Duration(i * secondsPerSample);
122 tf::StampedTransform currentEndEffectorTransform;
124 tf::Point pivotPoint;
126 tf::Vector3 pivot = (currentEndEffectorTransform * pivotPoint);
129 visualization_msgs::Marker marker;
131 marker.ns =
"trajectory";
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;
139 marker.color.a = 1.0;
140 marker.color.r = 0.0;
142 marker.color.b = 1.0;
144 tf::pointTFToMsg(pivot, marker.pose.position);
146 marker.header.stamp = ros::Time::now();
150 tf::Transform localdirection;
151 localdirection.setIdentity();
152 localdirection.setOrigin(tf::Vector3(0.05, 0, 0));
157 visualization_msgs::Marker marker;
158 marker.header.frame_id = frameid;
159 marker.header.stamp = ros::Time::now();
160 marker.ns =
"trajectory";
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;
170 marker.color.b = 0.0;
172 geometry_msgs::Point start, end;
177 tf::Transform basetransform;
178 tf::poseMsgToTF(pose.pose, basetransform);
179 tf::Transform endarrow = localdirection * basetransform;
181 end.x = localdirection.getOrigin().x();
182 end.y = localdirection.getOrigin().y();
183 end.z = localdirection.getOrigin().z();
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);
virtual void createMarkers() override
geometry_msgs::Pose pointerRelativePose_
geometry_msgs::Point relativePivotPoint_
std::vector< geometry_msgs::PoseStamped > pointerTrajectory_
virtual void generateTrajectory() override
boost::optional< double > linearSpeed_m_s_
CbCircularPouringMotion(const geometry_msgs::Point &pivotPoint, double deltaHeight, std::string tipLink, std::string globalFrame)
virtual void createMarkers()
void getCurrentEndEffectorPose(std::string globalFrame, tf::StampedTransform ¤tEndEffectorTransform)
visualization_msgs::MarkerArray beahiorMarkers_
std::vector< geometry_msgs::PoseStamped > endEffectorTrajectory_