22 : planePivotPose_(planePivotPose), relativeInitialPose_(relativeInitialPose), deltaRadians_(deltaRadians),
CbMoveEndEffectorTrajectory(tipLink)
44 const double RADS_PER_SAMPLE = 0.02;
45 const double METERS_PER_SAMPLE = 0.01;
47 int totalSamplesCount = std::max(totallineardist / METERS_PER_SAMPLE, totalangulardist / RADS_PER_SAMPLE);
49 double linearSecondsPerSample;
50 double angularSecondsPerSamples;
51 double secondsPerSample;
55 linearSecondsPerSample = METERS_PER_SAMPLE / (*linearSpeed_m_s_);
59 linearSecondsPerSample = std::numeric_limits<double>::max();
64 angularSecondsPerSamples = RADS_PER_SAMPLE / (*angularSpeed_rad_s_);
68 angularSecondsPerSamples = std::numeric_limits<double>::max();
73 secondsPerSample = 0.5;
77 secondsPerSample = std::min(linearSecondsPerSample, angularSecondsPerSamples);
80 double currentAngle = initialAngle;
84 tf::Transform tfBasePose;
87 for (
int i = 0; i < totalSamplesCount; i++)
90 currentAngle += angleStep;
91 double y = radius * cos(currentAngle);
92 double z = radius * sin(currentAngle);
94 geometry_msgs::Pose relativeCurrentPose;
97 relativeCurrentPose.position.y = y;
98 relativeCurrentPose.position.z = z;
100 auto localquat = tf::createQuaternionFromRPY(currentAngle, 0, 0);
103 relativeCurrentPose.orientation.w = 1;
105 tf::Transform tfRelativeCurrentPose;
106 tf::poseMsgToTF(relativeCurrentPose, tfRelativeCurrentPose);
108 tf::Transform tfGlobalPose = tfRelativeCurrentPose * tfBasePose;
110 tfGlobalPose.setRotation(tfGlobalPose.getRotation() * localquat);
112 geometry_msgs::PoseStamped globalPose;
113 tf::poseTFToMsg(tfGlobalPose, globalPose.pose);
115 globalPose.header.stamp =
planePivotPose_.header.stamp + ros::Duration(i * secondsPerSample);
125 tf::TransformListener tfListener;
127 tf::StampedTransform endEffectorInPivotFrame;
143 catch (
const std::exception &e)
145 std::cerr << e.what() <<
'\n';
155 tf::Transform pivotTransform;
157 tf::Transform invertedNewReferenceFrame = pivotTransform.inverse();
159 tf::Transform currentPoseRelativeToPivot = invertedNewReferenceFrame * endEffectorInPivotFrame;
161 geometry_msgs::Pose finalEndEffectorRelativePose;
162 tf::poseTFToMsg(currentPoseRelativeToPivot, finalEndEffectorRelativePose);
170 tf::Transform localdirection;
171 localdirection.setIdentity();
172 localdirection.setOrigin(tf::Vector3(0.12, 0, 0));
175 visualization_msgs::Marker marker;
176 marker.header.frame_id = frameid;
177 marker.header.stamp = ros::Time::now();
178 marker.ns =
"trajectory";
180 marker.type = visualization_msgs::Marker::ARROW;
181 marker.action = visualization_msgs::Marker::ADD;
182 marker.scale.x = 0.01;
183 marker.scale.y = 0.02;
184 marker.scale.z = 0.02;
185 marker.color.a = 1.0;
186 marker.color.r = 0.0;
188 marker.color.b = 1.0;
190 geometry_msgs::Point start, end;
195 tf::Transform basetransform;
197 tf::Transform endarrow = localdirection * basetransform;
199 end.x = endarrow.getOrigin().x();
200 end.y = endarrow.getOrigin().y();
201 end.z = endarrow.getOrigin().z();
203 marker.pose.orientation.w = 1;
204 marker.points.push_back(start);
205 marker.points.push_back(end);
geometry_msgs::PoseStamped planePivotPose_
void computeCurrentEndEffectorPoseRelativeToPivot()
boost::optional< geometry_msgs::Pose > relativeInitialPose_
boost::optional< double > angularSpeed_rad_s_
virtual void createMarkers() override
virtual void generateTrajectory() override
CbCircularPivotMotion(std::string tipLink="")
boost::optional< double > linearSpeed_m_s_
boost::optional< std::string > tipLink_
virtual void createMarkers()
visualization_msgs::MarkerArray beahiorMarkers_
std::vector< geometry_msgs::PoseStamped > endEffectorTrajectory_
ClMoveGroup * movegroupClient_
moveit::planning_interface::MoveGroupInterface moveGroupClientInterface