choreo_core_service_process_planning.cpp
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 7/5/17.
3 //
5 
7 
8 // services
9 #include <choreo_msgs/ProcessPlanning.h>
10 #include <choreo_msgs/MoveToTargetPose.h>
11 #include <choreo_msgs/TaskSequencePlanning.h>
12 
14  const int selected_path_index, choreo_core_service::TrajectoryLibrary& traj_lib)
15 {
16  ProcessPlanResult plan = generateProcessPlan(selected_path_index);
17 
18  traj_lib.get().clear();
19  for (std::size_t k = 0; k < plan.plans.size(); ++k)
20  {
21  traj_lib.get()[std::to_string(k)] = plan.plans[k];
22  }
23 
24  return plan.plans.size() > 0;
25 }
26 
28 {
29  ProcessPlanResult result;
30 
31  bool fetch_co_success = false;
32  std::vector<choreo_msgs::UnitProcessPlan> process_plan;
33 
34  // get task sequence file name as ladder graph file name
35  std::string saved_graph_file_name = task_sequence_input_params_.file_path;
36  std::replace(saved_graph_file_name.begin(), saved_graph_file_name.end(), '/', '_');
37 
38  // construct sequenced collision objects
39  choreo_msgs::TaskSequencePlanning ts_srv;
40  ts_srv.request.action = ts_srv.request.READ_WIREFRAME;
41  ts_srv.request.model_params = model_input_params_;
42  ts_srv.request.task_sequence_params = task_sequence_input_params_;
43 
44  // call process_processing srv
45  choreo_msgs::ProcessPlanning srv;
46  srv.request.index = selected_path_index;
47  srv.request.use_saved_graph = use_saved_graph_;
48  srv.request.file_name = saved_graph_file_name;
49  srv.request.clt_rrt_unit_process_timeout = model_input_params_.clt_rrt_unit_process_timeout;
50  srv.request.clt_rrt_timeout = model_input_params_.clt_rrt_timeout;
51 
53  {
54  assert(as_pnp_.sequenced_elements.size() > 0);
55 
56  srv.request.assembly_type = choreo::ASSEMBLY_TYPE_PICKNPLACE;
57  srv.request.as_pnp = as_pnp_;
58 
59  // no need to call seq planner for collision objs
60  fetch_co_success = true;
61  }
62 
64  {
65  srv.request.assembly_type = choreo::ASSEMBLY_TYPE_SPATIAL_EXTRUSION;
66 
67  // first call sequence planner to request collision object (because it has model configuration ability...)
69  {
70  ROS_ERROR_STREAM("[Core] task sequence planning service read wireframe failed.");
71  fetch_co_success = false;
72  }
73  else
74  {
75  ts_srv.request.action = ts_srv.request.REQUEST_COLLISION_OBJS;
76  ts_srv.request.element_array = std::vector<choreo_msgs::ElementCandidatePoses>(
77  task_sequence_.begin(), task_sequence_.begin() + selected_path_index + 1);
78 
80  {
81  ROS_WARN_STREAM("[Core] task sequence planning service construct collision objects failed.");
82  fetch_co_success = false;
83  }
84  else
85  {
86  srv.request.wf_collision_objs = ts_srv.response.wf_collision_objs;
87  fetch_co_success = true;
88  }
89  }
90 
91  srv.request.task_sequence = task_sequence_;
92  srv.request.env_collision_objs = env_objs_;
93  }
94 
95  assert(fetch_co_success);
96 
97  if(fetch_co_success)
98  {
100  {
101  process_plan = srv.response.plan;
102 
103  for (auto v : process_plan)
104  {
105  result.plans.push_back(v);
106  }
107  }
108  else
109  {
110  ROS_ERROR_STREAM("[Core] Failed to plan until path #" << selected_path_index << ", planning failed.");
111  }
112  }
113 
114  return result;
115 }
116 
117 bool ChoreoCoreService::moveToTargetJointPose(std::vector<double> joint_pose)
118 {
119  choreo_msgs::MoveToTargetPose srv;
120 
121  srv.request.type = srv.request.JOINT_POSE;
122  srv.request.pose = joint_pose;
123 
124  for(auto j : joint_pose)
125  {
126  ROS_INFO_STREAM("reset joint: " << j);
127  }
128 
129  return move_to_pose_client_.call(srv);
130 }
bool moveToTargetJointPose(std::vector< double > joint_pose)
std::vector< choreo_msgs::UnitProcessPlan > plans
bool generateMotionLibrary(const int selected_path_index, choreo_core_service::TrajectoryLibrary &traj_lib)
ros::ServiceClient move_to_pose_client_
bool call(MReq &req, MRes &res)
v
ros::ServiceClient process_planning_client_
std::vector< moveit_msgs::CollisionObject > env_objs_
ros::ServiceClient task_sequence_planning_srv_client_
static const std::string ASSEMBLY_TYPE_PICKNPLACE
choreo_msgs::ModelInputParameters model_input_params_
choreo_msgs::TaskSequenceInputParameters task_sequence_input_params_
#define ROS_WARN_STREAM(args)
#define ROS_INFO_STREAM(args)
static const std::string ASSEMBLY_TYPE_SPATIAL_EXTRUSION
ProcessPlanResult generateProcessPlan(const int &index)
#define ROS_ERROR_STREAM(args)
std::vector< choreo_msgs::ElementCandidatePoses > task_sequence_
choreo_msgs::AssemblySequencePickNPlace as_pnp_


choreo_core
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:38