print_process_planning.cpp
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 7/5/17.
3 //
4 
6 #include <ros/console.h>
7 
8 // msg
9 #include <choreo_msgs/ElementCandidatePoses.h>
10 
11 // service
12 #include <choreo_msgs/ProcessPlanning.h>
13 
14 // descartes
15 #include "path_transitions.h"
16 #include "common_utils.h"
17 #include "generate_motion_plan.h"
18 
20 {
21 // Planning Constants
23  M_PI / 12.0; // The discretization of the tool's pose about the z axis
24 
25 const static std::string JOINT_TOPIC_NAME =
26  "joint_states"; // ROS topic to subscribe to for current robot state info
27 
28 bool ProcessPlanningManager::handlePrintPlanning(choreo_msgs::ProcessPlanning::Request &req,
29  choreo_msgs::ProcessPlanning::Response &res)
30 {
31  // Enable Collision Checks
32  hotend_model_->setCheckCollisions(true);
33 
34  if (req.task_sequence.empty())
35  {
36  ROS_WARN("[Process Planning] Planning request contained no process path. Nothing to be done.");
37  return true;
38  }
39 
40  const static double LINEAR_VEL = 0.1; // (m/s)
41  const static double RETRACT_DISTANCE = 0.010; // meters
42 
43  const static double LINEAR_DISCRETIZATION = 0.005; // meters
44  // the distance between angular steps about z for each orientationcreateCollisionObject
45  const static double ANGULAR_DISCRETIZATION = PRINT_ANGLE_DISCRETIZATION; // radians
46 
47  ConstrainedSegParameters constrained_seg_params;
48  constrained_seg_params.linear_vel = LINEAR_VEL;
49  constrained_seg_params.linear_disc = LINEAR_DISCRETIZATION;
50  constrained_seg_params.angular_disc = ANGULAR_DISCRETIZATION;
51  constrained_seg_params.retract_dist = RETRACT_DISTANCE;
52 
53  // Eigen::Affine3d start_home_pose;
54  // hotend_model_->getFK(current_joints, start_home_pose);
55  std::vector<double> current_joints = getCurrentJointState(JOINT_TOPIC_NAME);
56 
57  // construct segs for descartes & copy chosen task sequence
58  const std::vector<choreo_msgs::ElementCandidatePoses>
59  chosen_task_seq(req.task_sequence.begin(), req.task_sequence.begin() + req.index + 1);
60 
61  std::vector<descartes_planner::ConstrainedSegment> constrained_segs =
62  toDescartesConstrainedPath(chosen_task_seq, constrained_seg_params);
63 
64  // clear existing objs from previous planning
66 
67  // add fixed extra collision objects in the work environment, e.g. heating bed (adjustable)
68  for(const auto& obj : req.env_collision_objs)
69  {
71  }
72 
75  req.use_saved_graph, req.file_name, req.clt_rrt_unit_process_timeout, req.clt_rrt_timeout,
77  current_joints,
78  chosen_task_seq,
79  req.wf_collision_objs,
80  constrained_segs,
84  res.plan))
85  {
86  return true;
87  }
88  else
89  {
90  return false;
91  }
92 }
93 
94 }// end namespace
bool addCollisionObject(ros::ServiceClient &planning_scene, const moveit_msgs::CollisionObject &c_obj)
bool clearAllCollisionObjects(ros::ServiceClient &planning_scene)
static const std::string JOINT_TOPIC_NAME
#define M_PI
#define ROS_WARN(...)
std::vector< double > getCurrentJointState(const std::string &topic)
std::vector< descartes_planner::ConstrainedSegmentPickNPlace > toDescartesConstrainedPath(const choreo_msgs::AssemblySequencePickNPlace &as_pnp, const std::vector< std::vector< planning_scene::PlanningScenePtr >> &planning_scene_subprocess, const double &linear_vel, const double &linear_disc)
bool generateMotionPlan(const std::string world_frame, const bool use_saved_graph, const std::string &saved_graph_file_name, const double clt_rrt_unit_process_timeout, const double clt_rrt_timeout, const std::string &move_group_name, const std::vector< double > &start_state, const std::vector< choreo_msgs::ElementCandidatePoses > &task_seq, const std::vector< choreo_msgs::WireFrameCollisionObject > &wf_collision_objs, std::vector< descartes_planner::ConstrainedSegment > &segs, descartes_core::RobotModelPtr model, moveit::core::RobotModelConstPtr moveit_model, ros::ServiceClient &planning_scene_diff_client, std::vector< choreo_msgs::UnitProcessPlan > &plans)
bool handlePrintPlanning(choreo_msgs::ProcessPlanning::Request &req, choreo_msgs::ProcessPlanning::Response &res)


choreo_process_planning
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:02