SeqAnalyzer.h
Go to the documentation of this file.
1 /*
2 * ==========================================================================
3 * This file is part of the implementation of
4 *
5 * <FrameFab: Robotic Fabrication of Frame Shapes>
6 * Yijiang Huang, Juyong Zhang, Xin Hu, Guoxian Song, Zhongyuan Liu, Lei Yu, Ligang Liu
7 * In ACM Transactions on Graphics (Proc. SIGGRAPH Asia 2016)
8 ----------------------------------------------------------------------------
9 * class: SequenceAnalyzer
10 *
11 * Description: perform tool path searching algorithm to generate
12 * a collision-free, structurally stable path.
13 *
14 * Version: 2.0
15 * Created: Oct/10/2015
16 * Updated: Aug/24/2016
17 *
18 * Author: Xin Hu, Yijiang Huang, Guoxian Song
19 * Company: GCL@USTC
20 * Successor: FFAnalyzer - FrameFab sequence analyzer
21 * BFAnalyzer - Brute Force sequence analyzer
22 
23 ----------------------------------------------------------------------------
24 * Copyright (C) 2016 Yijiang Huang, Xin Hu, Guoxian Song, Juyong Zhang
25 * and Ligang Liu.
26 *
27 * FrameFab is free software: you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published by
29 * the Free Software Foundation, either version 3 of the License, or
30 * (at your option) any later version.
31 *
32 * FrameFab is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License
38 * along with FrameFab. If not, see <http://www.gnu.org/licenses/>.
39 * ==========================================================================
40 */
41 
42 #pragma once
43 #include <cmath>
44 
50 
52 
55 
56 // msgs
57 #include <moveit_msgs/CollisionObject.h>
58 #include <choreo_msgs/ElementCandidatePoses.h>
59 #include <choreo_msgs/WireFrameCollisionObject.h>
60 
61 // robot model
62 #include <descartes_core/robot_model.h>
63 #include <pluginlib/class_loader.h>
64 
67  std::vector<Eigen::Vector3d> eef_directions_;
68 };
69 
71 {
72  public:
73  typedef Eigen::MatrixXd MX;
74  typedef Eigen::Matrix3d M3;
75  typedef Eigen::VectorXd VX;
76  typedef Eigen::Vector3d V3;
77 
78  public:
79  explicit SeqAnalyzer(
80  DualGraph *ptr_dualgraph,
81  QuadricCollision *ptr_collision,
82  Stiffness *ptr_stiffness,
83  FiberPrintPARM *ptr_parm,
84  char *ptr_path,
85  bool terminal_output,
86  bool file_output,
87  descartes_core::RobotModelPtr hotend_model,
88  moveit::core::RobotModelConstPtr moveit_model,
89  std::string hotend_group_name
90  ) noexcept;
91 
92  virtual ~SeqAnalyzer();
93 
94  void setFrameMsgs(const std::vector<choreo_msgs::ElementCandidatePoses>& frame_msg){ frame_msgs_ = frame_msg; };
95 
96  public:
97  virtual bool SeqPrint();
98  virtual bool SeqPrintLayer(std::vector<int> layer_id);
99 
100  virtual void PrintOutTimer();
101 
102  public:
103  bool InputPrintOrder(const std::vector<int>& print_queue);
104  bool ConstructCollisionObjsInQueue(const std::vector<int>& print_queue_edge_ids,
105  std::vector<choreo_msgs::WireFrameCollisionObject>& collision_objs);
106 
107  void OutputPrintOrder(std::vector<WF_edge*>& print_queue);
108  void OutputTaskSequencePlanningResult(std::vector<SingleTaskPlanningResult>& planning_result);
109 
110  protected:
111  void Init();
112 
113  void PrintPillars();
114  void UpdateStructure(WF_edge *e, bool update_collision = false);
115  void RecoverStructure(WF_edge *e, bool update_collision = false);
116  void UpdateStateMap(WF_edge *e, vector<vector<lld>> &state_map);
117  void RecoverStateMap(WF_edge *e, vector<vector<lld>> &state_map);
118  bool TestifyStiffness(WF_edge *e);
119 
120  bool TestRobotKinematics(WF_edge* e, const std::vector<lld>& colli_map);
121 
122  WF_edge* RouteEdgeDirection(const WF_edge* prev_e, WF_edge* e);
123 
124  private:
125  // robot kinematics related
126  // the collision obj's update and recover are called
127  // inside UpdateStructure and RecoverStructure.
128  std::vector<moveit_msgs::CollisionObject> UpdateCollisionObjects(WF_edge* e, bool shrink = false);
129  std::vector<moveit_msgs::CollisionObject> RecoverCollisionObjects(WF_edge* e, bool shrink = false);
130 
131  public:
136  char* ptr_path_;
137 
138  std::vector<choreo_msgs::ElementCandidatePoses> frame_msgs_;
139 
140  protected:
141  /* maintaining for sequence */
142  // number of unique edges in wireframe = number of vertices in dual graph
143  int Nd_;
144 
145  // entire dual graph copy
147 
148  std::vector<WF_edge*> print_queue_;
149 
150  // feasible end effector direction record, bit-wise map
151  vector<vector<unsigned long long>> angle_state_;
152 
153  VX D0_;
154 
155  /* parameters */
156  double gamma_; // gamma_ : amplifier factor for adjacency cost
157  double D_tol_; // Dt_tol : tolerance of offset in stiffness
158  double Wp_; // Wp_ : stablity weight for printing cost
159  double Wa_; // Wa_ : adjacent weight for printing cost
160  double Wi_; // Wl_ : influence weight for printing cost
161 
162  /* for debuging */
165 
167 
174 
175  descartes_core::RobotModelPtr hotend_model_;
176  moveit::core::RobotModelConstPtr moveit_model_;
177  std::string hotend_group_name_;
178 
179  planning_scene::PlanningScenePtr planning_scene_;
180 
183 
185 };
Timer test_stiff_
Definition: SeqAnalyzer.h:173
descartes_core::RobotModelPtr hotend_model_
Definition: SeqAnalyzer.h:175
void setFrameMsgs(const std::vector< choreo_msgs::ElementCandidatePoses > &frame_msg)
Definition: SeqAnalyzer.h:94
Stiffness * ptr_stiffness_
Definition: SeqAnalyzer.h:134
Eigen::Matrix3d M3
Definition: SeqAnalyzer.h:74
int num_backtrack_
Definition: SeqAnalyzer.h:182
double Wp_
Definition: SeqAnalyzer.h:158
bool update_collision_
Definition: SeqAnalyzer.h:166
Eigen::Vector3d V3
Definition: SeqAnalyzer.h:76
moveit::core::RobotModelConstPtr moveit_model_
Definition: SeqAnalyzer.h:176
Eigen::VectorXd VX
Definition: SeqAnalyzer.h:75
double gamma_
Definition: SeqAnalyzer.h:156
Timer upd_struct_
Definition: SeqAnalyzer.h:168
bool file_output_
Definition: SeqAnalyzer.h:164
Timer rec_struct_
Definition: SeqAnalyzer.h:169
std::string hotend_group_name_
Definition: SeqAnalyzer.h:177
WireFrame * ptr_frame_
Definition: SeqAnalyzer.h:132
vector< vector< unsigned long long > > angle_state_
Definition: SeqAnalyzer.h:151
planning_scene::PlanningScenePtr planning_scene_
Definition: SeqAnalyzer.h:179
DualGraph * ptr_wholegraph_
Definition: SeqAnalyzer.h:146
double Wi_
Definition: SeqAnalyzer.h:160
double Wa_
Definition: SeqAnalyzer.h:159
DualGraph * ptr_dualgraph_
Definition: SeqAnalyzer.h:133
QuadricCollision * ptr_collision_
Definition: SeqAnalyzer.h:135
Eigen::MatrixXd MX
Definition: SeqAnalyzer.h:73
char * ptr_path_
Definition: SeqAnalyzer.h:136
std::vector< WF_edge * > print_queue_
Definition: SeqAnalyzer.h:148
Timer rec_map_
Definition: SeqAnalyzer.h:172
bool terminal_output_
Definition: SeqAnalyzer.h:163
int num_p_assign_visited_
Definition: SeqAnalyzer.h:181
double D_tol_
Definition: SeqAnalyzer.h:157
int search_rerun_
Definition: SeqAnalyzer.h:184
Definition: Timer.h:48
std::vector< choreo_msgs::ElementCandidatePoses > frame_msgs_
Definition: SeqAnalyzer.h:138
Timer upd_map_
Definition: SeqAnalyzer.h:170
Timer upd_map_collision_
Definition: SeqAnalyzer.h:171
std::vector< Eigen::Vector3d > eef_directions_
Definition: SeqAnalyzer.h:67


choreo_task_sequence_planner
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:03:14