task_sequence_processor_node.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <ros/console.h>
3 
4 #include <boost/tuple/tuple.hpp>
5 
6 #include <choreo_msgs/TaskSequenceProcessing.h>
9 
10 bool processTaskSequenceCallback(choreo_msgs::TaskSequenceProcessingRequest& req,
11  choreo_msgs::TaskSequenceProcessingResponse& res)
12 {
14 
15  switch (req.action)
16  {
17  case choreo_msgs::TaskSequenceProcessing::Request::SPATIAL_EXTRUSION:
18  {
19  ROS_WARN_STREAM("[ts processor] using spatial extrusion parsing mode now.");
20 
21  // TODO: ARCHIVED for now
22  ts_processor.setParams(req.model_params, req.task_sequence_params, req.world_frame);
23 
24  if(!(ts_processor.createCandidatePoses() && ts_processor.createEnvCollisionObjs()))
25  {
26  ROS_ERROR("[Task Seq Process] Could not process input task sequence!");
27  res.succeeded = false;
28  return false;
29  }
30 
31  std::vector<choreo_task_sequence_processing_utils::UnitProcess> process_array =
32  ts_processor.getCandidatePoses();
33 
34  std::vector<moveit_msgs::CollisionObject> env_objs =
35  ts_processor.getEnvCollisionObjs();
36 
37  for(auto& unit_process : process_array)
38  {
39  res.process.push_back(unit_process.asElementCandidatePoses());
40  }
41 
42  for(auto& env_obj : env_objs)
43  {
44  res.env_collision_objs.push_back(env_obj);
45  }
46 
47  break;
48  }
49  case choreo_msgs::TaskSequenceProcessing::Request::PICKNPLACE:
50  {
51  if(!ts_processor.parseAssemblySequencePickNPlace(
52  req.model_params, req.task_sequence_params, req.world_frame, res.assembly_sequence_pnp))
53  {
54  ROS_ERROR("[Task Seq Process] Could not process input task sequence!");
55  res.succeeded = false;
56  return false;
57  }
58 
59  return true;
60 
61  break;
62  }
63  default:
64  {
65  ROS_ERROR("[Task Seq Process] Unrecognized task sequence processing request");
66  res.succeeded = false;
67  return false;
68  }
69  }
70 
71  res.succeeded = true;
72  return true;
73 }
74 
75 int main(int argc, char** argv)
76 {
77 
78  ros::init(argc, argv, "task_sequence_processor");
79  ros::NodeHandle nh;
80 
81  ros::ServiceServer task_sequence_processing_server =
82  nh.advertiseService<choreo_msgs::TaskSequenceProcessingRequest, choreo_msgs::TaskSequenceProcessingResponse>(
83  "task_sequence_processing", boost::bind(processTaskSequenceCallback, _1, _2));
84 
85  ROS_INFO("[task seq processor] %s server ready to service requests.", task_sequence_processing_server.getService().c_str());
86  ros::spin();
87 
88  return 0;
89 }
void setParams(choreo_msgs::ModelInputParameters model_params, choreo_msgs::TaskSequenceInputParameters task_sequence_params, std::string world_frame)
const std::vector< choreo_task_sequence_processing_utils::UnitProcess > & getCandidatePoses() const
const std::vector< moveit_msgs::CollisionObject > & getEnvCollisionObjs() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ROSCPP_DECL void spin(Spinner &spinner)
#define ROS_INFO(...)
std::string getService() const
bool parseAssemblySequencePickNPlace(const choreo_msgs::ModelInputParameters &model_params, const choreo_msgs::TaskSequenceInputParameters &task_sequence_params, const std::string &world_frame_, choreo_msgs::AssemblySequencePickNPlace &as_pnp)
#define ROS_WARN_STREAM(args)
bool processTaskSequenceCallback(choreo_msgs::TaskSequenceProcessingRequest &req, choreo_msgs::TaskSequenceProcessingResponse &res)
#define ROS_ERROR(...)


choreo_task_sequence_processor
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:29