20 for (
int i = 0; i <
Nd_; i++)
27 int print_until = layer_size;
30 assert(print_until <= layer_size);
32 for (
int l = 0; l < print_until; l++)
34 fprintf(stderr,
"Size of layer %d is %d\n", l, (
int)
layers_[l].
size());
40 for (
int l = 0; l < print_until; l++)
62 for (
int i = 0; i < Nl; i++)
74 double dist = sqrt(pow((st_pt_msg.x + end_pt_msg.x)/2, 2)
75 + pow((st_pt_msg.y + end_pt_msg.y)/2, 2)
76 + pow((st_pt_msg.z + end_pt_msg.z)/2, 2));
94 ROS_ERROR(
"All possible start edge at layer %d has been tried but no feasible sequence is obtained after %d iterations.", l,
search_rerun_);
99 fprintf(stderr,
"\n\nFFAnalyzer seq search finished:\n Number of edges: %d\nNumber of partial assignment visited: %d, Number of backtrack: %d\n\n",
109 > *std::max_element(layer_ids.begin(), layer_ids.end()));
124 for (
int i = 0; i <
Nd_; i++)
131 for(
const int& layer_id : layer_ids)
133 fprintf(stderr,
"Size of target layer %d is %d\n", layer_id, (
int)
layers_[layer_id].
size());
136 int min_tid = *std::min_element(layer_ids.begin(), layer_ids.end());
138 bool bSuccess =
true;
140 for(
int l=0; l < min_tid; l++)
142 std::cout <<
"layer #" << l << std::endl;
153 for(
const int& layer_id : layer_ids)
155 vector <vector<lld>> state_map(3);
158 for (
int j = 0; j <
layers_[layer_id].size(); j++)
168 for (
int k = 0; k < 3; k++)
180 std::cout <<
"Update finished." << std::endl;
184 for(
const int& lb : layer_ids)
197 for (
int i = 0; i < Nl; i++)
209 double dist = sqrt(pow((st_pt_msg.x + end_pt_msg.x)/2, 2)
210 + pow((st_pt_msg.y + end_pt_msg.y)/2, 2)
211 + pow((st_pt_msg.z + end_pt_msg.z)/2, 2));
228 ROS_ERROR(
"All possible start edge at layer %d has been tried but no feasible sequence is obtained after %d iterations.",
234 fprintf(stderr,
"****Reminder: Start of target layers is %d\n", Nd_ - target_size);
249 fprintf(stderr,
"-----------------------------------\n");
250 fprintf(stderr,
"Searching edge #%d in layer %d, head %d, tail %d\n",
251 ei->
ID() / 2, l, h, t);
258 fprintf(stderr,
"-----------------------------------\n");
259 fprintf(stderr,
"Searching starts in layer %d, head %d, tail %d\n", l, h, t);
268 fprintf(stderr,
"++++ Head meets tail! Current layer solution found.\n\n");
275 multimap<double, WF_edge*> choice;
276 multimap<double, WF_edge*>::iterator it;
283 for (
int j = 0; j < Nl; j++)
298 choice.insert(pair<double, WF_edge*>(cost, ej));
306 for (it = choice.begin(); it != choice.end(); it++)
323 std::vector<std::vector<lld>> tmp_angle(3);
330 fprintf(stderr,
"Choose edge #%d in with cost %lf - candidates %d/%d \n\n",
331 ej->
ID() / 2, it->first, cnt, (
int)choice.size());
349 fprintf(stderr,
"---- Backtrack - head %d/tail %d\n", h, t);
361 int orig_j = ej->
ID();
373 fprintf(stderr,
"Look-ahead in layer %d/%d - head %d/tail %d: Attempting edge #%d, queue size %d\n",
396 if (exist_uj && exist_vj)
403 if (exist_uj || exist_vj)
425 fprintf(stderr,
"...floating edge, skip\n\n");
438 fprintf(stderr,
"...collision test failed at edge #%d.\n", ej->
ID() / 2);
441 fprintf(stderr,
"fail edge vert u: (%f, %f, %f), vert v: (%f, %f, %f)\n\n",
457 fprintf(stderr,
"...robot kinematics test failed at edge #%d.\n", ej->
ID() / 2);
458 fprintf(stderr,
"fail edge vert u: (%f, %f, %f), vert v: (%f, %f, %f)\n\n",
483 int remaining_num = 0;
484 double forward_checking_factor = 1.0;
486 for (
int k = 0; k < Nl; k++)
497 for (
int o = 0; o < 3; o++)
504 if(0 == future_angle)
506 fprintf(stderr,
"...FC pruning - collision test failed at edge #%d to future edge #%d.\n\n",
507 ej->
ID() / 2, ek->
ID() / 2);
512 I += exp(- forward_checking_factor * d_ratio * d_ratio);
518 if(0 != remaining_num)
535 double dist = sqrt(pow((st_pt_msg.x + end_pt_msg.x) / 2, 2)
536 + pow((st_pt_msg.y + end_pt_msg.y) / 2, 2)
537 + pow((st_pt_msg.z + end_pt_msg.z) / 2, 2));
544 double cost =
Wp_ * P +
Wa_ * A +
Wi_ * I;
548 fprintf(stderr,
"P: %lf, A: %lf, I: %lf\ncost: %f\n\n", P, A, I, cost);
560 printf(
"***FFAnalyzer timer result:\n");
574 printf(
"***FFAnalyzer detailed timing turned off.\n");
int ColFreeAngle(const std::vector< lld > &colli_map)
void UpdateStructure(WF_edge *e, bool update_collision=false)
void ModifyAngle(std::vector< lld > &angle_state, const std::vector< lld > &colli_map)
void UpdateStateMap(WF_edge *e, vector< vector< lld >> &state_map)
static double angle(Vector3d vec1, Vector3d vec2)
bool GenerateSeq(int l, int h, int t)
WF_edge * RouteEdgeDirection(const WF_edge *prev_e, WF_edge *e)
void RecoverStructure(WF_edge *e, bool update_collision=false)
bool isExistingVert(int u)
bool SeqPrintLayer(std::vector< int > layer_id)
static const T dist(const Vec< D, T > &v1, const Vec< D, T > &v2)
vector< vector< unsigned long long > > angle_state_
bool DetectCollision(WF_edge *target_e, DualGraph *ptr_subgraph, std::vector< lld > &result_map)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
DualGraph * ptr_wholegraph_
DualGraph * ptr_dualgraph_
QuadricCollision * ptr_collision_
double GenerateCost(WF_edge *ej, const int h, const int t, const int layer_id)
std::vector< WF_edge * > print_queue_
GLdouble GLdouble GLdouble z
GLfloat GLfloat GLfloat GLfloat h
bool isExistingEdge(WF_edge *e)
#define ROS_INFO_STREAM(args)
int num_p_assign_visited_
bool TestRobotKinematics(WF_edge *e, const std::vector< lld > &colli_map)
void RecoverStateMap(WF_edge *e, vector< vector< lld >> &state_map)
std::vector< choreo_msgs::ElementCandidatePoses > frame_msgs_
std::vector< std::vector< WF_edge * > > layers_
point GetPosition(int u) const