6 const std::string description,
7 const std::string service_name) :
9 description_(description),
10 service_name_(service_name)
15 "ram/information/get_trajectory_infos");
20 programs_.front().second.append(
"\n" + comment);
30 std::stringstream buffer;
32 std::string pose_str(buffer.str());
33 programs_.front().second.append(
"\n Pose: \n" + buffer.str());
52 programs_.front().second.append(
"\nStart polygon");
65 programs_.front().second.append(
"\nFinish polygon");
99 programs_.front().second.append(
"\nStop feed rate");
104 programs_.front().second.append(
"\nStop feed rate");
128 programs_.front().second.append(
"\nStop laser power");
136 std::vector<std::pair<std::string, std::string>> &programs)
138 ram_msgs::AdditiveManufacturingPose last_pose;
146 if (trajectory.poses.empty())
147 throw std::runtime_error(
"Trajectory is empty");
154 throw std::runtime_error(
"Cannot get start pose, service does not exist");
157 ram_utils::GetStartPose srv_1;
159 throw std::runtime_error(
"Cannot get start pose, call to service failed");
166 throw std::runtime_error(
"Cannot get tool, service does not exist");
169 ram_utils::GetTool srv_2;
171 throw std::runtime_error(
"Cannot get tool, call to service failed");
178 unsigned highest_layer(0);
180 if (ram_pose.layer_level > highest_layer)
181 highest_layer = ram_pose.layer_level;
183 addComment(
"Number of layers = " + std::to_string(highest_layer + 1));
188 throw std::runtime_error(
"Cannot get trajectory infos, service does not exist");
191 ram_utils::GetTrajectoryInfos srv_3;
193 throw std::runtime_error(
"Cannot get trajectory infos, call to service failed");
196 uint16_t seconds(srv_3.response.informations.execution_time);
197 unsigned hours(seconds / 3600);
198 seconds -= hours * 3600;
200 unsigned minutes(seconds / 60);
201 seconds -= minutes * 60;
203 addComment(
"Execution duration = " + std::to_string(hours) +
":" + std::to_string(minutes) +
":" 204 + std::to_string(seconds));
214 Eigen::Isometry3d pose;
223 bool first_pose(
true);
226 bool laser_power_start(
false),
227 laser_power_stop(
false),
228 laser_power_change(
false),
229 feed_rate_start(
false),
230 feed_rate_stop(
false),
231 feed_rate_change(
false);
236 if ((
current_pose_->layer_index != last_pose.layer_index || first_pose))
249 feed_rate_start =
true;
253 if (last_pose.params.laser_power != 0)
255 laser_power_start =
true;
262 if (
current_pose_->params.feed_rate != last_pose.params.feed_rate)
264 if (last_pose.params.feed_rate != 0 &&
current_pose_->params.feed_rate == 0)
266 feed_rate_stop =
true;
269 else if (last_pose.params.feed_rate == 0)
271 feed_rate_start =
true;
276 feed_rate_change =
true;
282 if (
current_pose_->params.laser_power != last_pose.params.laser_power)
284 if (last_pose.params.laser_power != 0 &&
current_pose_->params.laser_power == 0)
286 laser_power_stop =
true;
289 else if (last_pose.params.laser_power == 0)
291 laser_power_start =
true;
296 laser_power_change =
true;
322 if (last_pose.params.laser_power != 0)
328 if (
current_pose_->params.feed_rate != last_pose.params.feed_rate)
330 if (last_pose.params.feed_rate != 0 &&
current_pose_->params.feed_rate == 0)
332 else if (last_pose.params.feed_rate == 0)
339 if (
current_pose_->params.laser_power != last_pose.params.laser_power)
341 if (last_pose.params.laser_power != 0 &&
current_pose_->params.laser_power == 0)
343 else if (last_pose.params.laser_power == 0)
359 const std::string file_extension)
361 std::ofstream program_file;
364 const std::string file_name(directory +
"/" + program.first + file_extension);
365 program_file.open(file_name, std::ofstream::out);
366 if (!program_file.is_open())
367 throw std::runtime_error(
"Could not open file " + file_name +
" for writing");
369 program_file << program.second;
370 program_file.close();
virtual void changeLaserPowerBefore()
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
virtual void startFeedRateAfter()
std::string program_name_
void generatePrograms(const ram_msgs::AdditiveManufacturingTrajectory &trajectory, std::vector< std::pair< std::string, std::string >> &programs)
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
ram_msgs::AdditiveManufacturingParams params
void poseMsgToEigen(const geometry_msgs::Pose &m, Eigen::Affine3d &e)
const ram_pose_const_iterator & currentPose()
bool call(MReq &req, MRes &res)
virtual void clearProgram()
Eigen::Isometry3d start_pose_
virtual void startPolygonBefore()
Polygons.
std::string program_comment_
virtual void startFeedRateBefore()
Feed rate.
ros::ServiceClient get_start_pose_client_
virtual void stopFeedRateBefore()
virtual void changeFeedRateBefore()
virtual void addComment(const std::string comment)
virtual void beforeGenerating()
ros::ServiceClient get_trajectory_infos_client_
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
ros::ServiceClient get_tool_client_
virtual void startPolygonAfter()
virtual void stopLaserPowerAfter()
virtual void finishPolygonAfter()
virtual void saveToFiles(const std::string directory, const std::string file_extension="")
virtual void addPose(const bool laser_power_start, const bool laser_power_stop, const bool laser_power_change, const bool feed_rate_start, const bool feed_rate_stop, const bool feed_rate_change)
virtual void stopLaserPowerBefore()
std::vector< std::pair< std::string, std::string > > programs_
virtual void layerIndexChanged()
Layer change.
virtual void finishPolygonBefore()
PostProcessor(const std::string name="Generic", const std::string description="A human readable textual output.\n""Not meant to be used by any kind of hardware.", const std::string service_name="ram/post_processors/generic")
ram_msgs::AdditiveManufacturingTrajectory trajectory_
ram_pose_const_iterator current_pose_
virtual void changeFeedRateAfter()
virtual void changeLaserPowerAfter()
virtual void startLaserPowerBefore()
Laser power.
virtual void afterGenerating()
virtual void startLaserPowerAfter()
virtual void stopFeedRateAfter()