15 #include <moveit_msgs/ExecuteKnownTrajectory.h> 16 #include <visualization_msgs/Marker.h> 17 #include <visualization_msgs/MarkerArray.h> 18 #include <std_msgs/String.h> 20 #include "bezier_library/bezier_grinding_surfacing.hpp" 22 #include <fanuc_grinding_path_planning/PathPlanningService.h> 34 const std::string
tcp_name(
"/grinding_disk_tcp");
48 bool pathPlanning(fanuc_grinding_path_planning::PathPlanningService::Request &req,
49 fanuc_grinding_path_planning::PathPlanningService::Response &res)
51 if (!req.SurfacingMode)
53 res.ReturnStatus =
false;
54 res.ReturnMessage =
"Grinding mode is not implemented yet!";
58 std_msgs::String status;
59 std::vector<bool> is_grinding_pose;
63 std::string
package = "fanuc_grinding_path_planning";
65 std::string mesh_ressource =
"package://" +
package + "/meshes/";
66 std::string mesh_ressource_file =
"file://";
69 std::string lean_angle_axis;
70 BezierGrindingSurfacing::AXIS_OF_ROTATION lean_axis;
71 if (req.AngleX ==
true)
72 lean_axis = BezierGrindingSurfacing::X;
73 else if (req.AngleY ==
true)
74 lean_axis = BezierGrindingSurfacing::Y;
75 else if (req.AngleZ ==
true)
76 lean_axis = BezierGrindingSurfacing::Z;
79 res.ReturnStatus =
false;
80 res.ReturnMessage =
"Please select a lean angle axis for the effector";
87 new BezierGrindingSurfacing(req.CADFileName, req.GrinderWidth, req.CoveringPercentage, req.ExtricationRadius,
88 req.LeanAngle, lean_axis));
93 status.data =
"Generate Bezier trajectory";
94 status_pub->publish(status);
95 std::string error_string;
96 error_string = bezier->generateTrajectory(
way_points_vector, is_grinding_pose, req.GrinderWidth,
97 req.CoveringPercentage, req.ExtricationRadius, req.LeanAngle, lean_axis);
99 if (!error_string.empty())
101 res.ReturnStatus =
false;
102 res.ReturnMessage = error_string;
108 std::vector<geometry_msgs::Pose> way_points_msg;
111 geometry_msgs::Pose tmp;
112 pose.translation() += Eigen::Vector3d(0, 0, req.TrajectoryZOffset);
114 way_points_msg.push_back(tmp);
117 res.RobotPosesOutput = way_points_msg;
118 for (std::vector<bool>::const_iterator iter(is_grinding_pose.begin()); iter != is_grinding_pose.end(); ++iter)
119 res.IsGrindingPose.push_back(*iter);
123 res.ReturnStatus =
true;
124 res.ReturnMessage = boost::lexical_cast<std::string>(way_points_msg.size()) +
" poses generated";
132 moveit_msgs::ExecuteKnownTrajectory srv;
133 srv.request.wait_for_execution =
true;
134 ros::ServiceClient executeKnownTrajectoryServiceClient = node->serviceClient < moveit_msgs::ExecuteKnownTrajectory
135 > (
"/execute_kinematic_path");
136 double percentage = group->computeCartesianPath(way_points_msg, 0.05, 0.0, srv.request.trajectory);
138 status.data = boost::lexical_cast<std::string>(percentage*100) +
"% of the trajectory will be executed";
139 status_pub->publish(status);
140 executeKnownTrajectoryServiceClient.
call(srv);
142 if (percentage < 0.9)
144 res.ReturnStatus =
false;
145 res.ReturnMessage =
"Could not compute the whole trajectory!";
148 res.ReturnStatus =
true;
160 *status_pub = node->advertise <std_msgs::String> (
"scanning_status", 1);
164 group->setPoseReferenceFrame(
"/base_link");
165 group->setPlannerId(
"RRTConnectkConfigDefault");
166 group->setPlanningTime(2);
const std::string tcp_name("/grinding_disk_tcp")
std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > vector_Affine3d
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
std::string input_mesh_filename
EigenSTL::vector_Affine3d way_points_vector
boost::shared_ptr< BezierGrindingSurfacing > bezier
bool pathPlanning(fanuc_grinding_path_planning::PathPlanningService::Request &req, fanuc_grinding_path_planning::PathPlanningService::Response &res)
boost::shared_ptr< ros::NodeHandle > node
boost::shared_ptr< moveit::planning_interface::MoveGroupInterface > group
boost::shared_ptr< ros::Publisher > status_pub
int main(int argc, char **argv)
const std::string move_group_name("grinding_disk")