1 #ifndef RAM_PATH_PLANNING_FOLLOW_POSES_IMP_HPP 2 #define RAM_PATH_PLANNING_FOLLOW_POSES_IMP_HPP 6 template<
class ActionSpec>
9 "ram/path_planning/generate_trajectory/follow_poses")
13 template<
class ActionSpec>
15 ram_msgs::AdditiveManufacturingTrajectory &msg)
20 vtkIdType n_contours = poly_data->GetNumberOfCells();
23 return "YAML is empty";
25 for (vtkIdType contour_id(0); contour_id < n_contours; ++contour_id)
28 vtkIdType n_points = poly_data->GetCell(contour_id)->GetNumberOfPoints();
30 return "Polygon in YAML file is empty";
32 for (vtkIdType point_id(0); point_id < n_points; ++point_id)
36 poly_data->GetCell(contour_id)->GetPoints()->GetPoint(point_id, p);
38 ram_msgs::AdditiveManufacturingPose ram_pose;
41 ram_pose.pose.orientation.w = 1;
43 ram_pose.pose.position.x = p[0];
44 ram_pose.pose.position.y = p[1];
45 ram_pose.pose.position.z = p[2];
49 ram_pose.polygon_start =
true;
50 if ((point_id + 1) == n_points)
51 ram_pose.polygon_end =
true;
53 msg.poses.push_back(ram_pose);
60 template<
class ActionSpec>
62 const unsigned number_of_layers,
63 const double height_between_layers,
64 bool invert_one_of_two_layers)
66 if (number_of_layers < 2)
67 return "Number of layers < 2";
69 if (!msg.poses.empty())
71 msg.poses.front().polygon_start =
true;
72 msg.poses.back().polygon_end =
true;
75 const std::vector<ram_msgs::AdditiveManufacturingPose> first_layer(msg.poses);
78 for (
unsigned i(1); i < number_of_layers; ++i)
80 std::vector < ram_msgs::AdditiveManufacturingPose > new_layer(first_layer);
81 if (invert_one_of_two_layers && i % 2 == 1)
84 std::reverse(new_layer.begin(), new_layer.end());
85 new_layer.front().polygon_start =
true;
86 new_layer.front().polygon_end =
false;
88 new_layer.back().polygon_end =
true;
89 new_layer.back().polygon_start =
false;
92 for (
auto &pose : new_layer)
96 pose.layer_index = pose.layer_level;
97 pose.pose.position.z += i * height_between_layers;
101 msg.poses.insert(msg.poses.end(), new_layer.begin(), new_layer.end());
104 if (invert_one_of_two_layers)
105 msg.similar_layers =
false;
107 msg.similar_layers =
true;
111 template<
class ActionSpec>
113 ram_msgs::AdditiveManufacturingTrajectory &msg)
119 const Polygon poly_data = Polygon::New();
120 std::vector<unsigned> layer_count;
127 msg.file = yaml_file;
129 msg.modified = msg.generated;
130 msg.similar_layers =
false;
131 msg.generation_info =
"From YAML (points) file";
135 return "Failed to read YAML file";
static boost::uuids::uuid fromRandom(void)
vtkSmartPointer< vtkPolyData > Polygon
std::string duplicateLayers(ram_msgs::AdditiveManufacturingTrajectory &msg, const unsigned number_of_layers, const double height_between_layers, bool invert_one_of_two_layers)
std::string generateTrajectory(const Polygon poly_data, ram_msgs::AdditiveManufacturingTrajectory &msg)
bool yamlFileToPolydata2(const std::string yaml_file, Polygon poly_data, std::vector< unsigned > &layer_count)
static uuid_msgs::UniqueID toMsg(boost::uuids::uuid const &uu)
bool yamlFileToTrajectory(const std::string yaml_file, ram_msgs::AdditiveManufacturingTrajectory &traj)