00001
00002 #include "math/vector4.h"
00003 #include "math/matrixmxn.h"
00004 #include "synchronization/semaphore.h"
00005 #include "robots/R_OpenChain.h"
00006 #include "CollisionDetectors/CD_Swiftpp.h"
00007 #include <assert.h>
00008 #include "planners/inversekin/Redundant.h"
00009 #include "planners/ik_mpep/IK_Jacobian.h"
00010 #include "PL_RRT_ClosedChain.h"
00011 #include <gl/gl.h>
00012 #include <opengl/gl_sphere.h>
00013 #include <opengl/gl_group.h>
00014
00015 #define DEF_NEIGHBOR (2) //For CompareLocalPlanners();
00016 #define DEF_RESOLUTION (15)
00017 #define MIN_DIST_CHANGE (0.5)
00018
00019 #define LEN_STEP_SIZE 30
00020
00021
00022 #define _MULTIPLE_STEP
00023
00024 typedef struct
00025 {
00026 Configuration conf;
00027 PA_Points edge;
00028 } VertexInfoInTree;
00029
00030 #define ERR_FAIL 0xff
00031 #define ERR_SUCCESS 0x00
00032 #define ERR_TIMEOUT 0x10
00033 #define ERR_ILLPARAMETER 0x20
00034
00035
00036 PL_RRT_ClosedChain::PL_RRT_ClosedChain()
00037 {
00038 m_rootVert = NULL;
00039 m_goalVert = NULL;
00040 }
00041
00042 PL_RRT_ClosedChain::~PL_RRT_ClosedChain()
00043 {
00044 if ( m_rootVert != NULL )
00045 ClearTree();
00046 }
00047
00048 void PL_RRT_ClosedChain::SetCollisionDetector(CD_BasicStyle* collisionDetector)
00049 {
00050 PL_PRM_ClosedChain::SetCollisionDetector(collisionDetector);
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 }
00070
00071 bool PL_RRT_ClosedChain::DrawExplicit () const
00072 {
00073 double Xcor, Ycor, Zcor;
00074
00075 Semaphore semaphore( guid );
00076 semaphore.Lock();
00077
00078
00079 glClearColor( 0.0f, 0.0f, 0.2f, 1.0f );
00080 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
00081 BOOL lightingState = glIsEnabled( GL_LIGHTING );
00082 glDisable( GL_LIGHTING );
00083 glShadeModel( GL_SMOOTH );
00084 glPointSize(5.0f);
00085
00086 if (m_vertices.size() )
00087 {
00088 int i;
00089
00090
00091 glBegin(GL_POINTS);
00092 for(i = 0; i<m_vertices.size(); i++)
00093 {
00094 vertex vert;
00095 VertexInfoInTree *info;
00096 vert = m_vertices[i];
00097 info = (VertexInfoInTree *)((dynamic_trees &)m_trajTree).vertex_inf(vert);
00098
00099 Configuration conf = info->conf;
00100 Xcor = conf[0];
00101 Ycor = conf[1];
00102 Zcor = conf[2];
00103
00104 if ((i==0) || (i==(m_vertices.size()-1)))
00105 glColor3f(0.0f,0.0f,1.0f);
00106 else
00107 glColor3f(1.0f,1.0f,0.0f);
00108 glVertex3f( (float)Xcor, (float)Ycor, (float)Zcor );
00109 }
00110 glEnd();
00111
00112 glBegin(GL_LINES);
00113 for(i = 1; i<m_vertices.size(); i++)
00114 {
00115 vertex vert, parentVert;
00116 VertexInfoInTree *info, *parentInfo;
00117
00118 vert = m_vertices[i];
00119 parentVert = ((dynamic_trees &)m_trajTree).parent(vert);
00120 info = (VertexInfoInTree *)((dynamic_trees &)m_trajTree).vertex_inf(vert);
00121 parentInfo = (VertexInfoInTree *)((dynamic_trees &)m_trajTree).vertex_inf(parentVert);
00122
00123 Configuration conf = info->conf;
00124 Configuration parentConf = parentInfo->conf;
00125
00126 Xcor = conf[0];
00127 Ycor = conf[1];
00128 Zcor = conf[2];
00129 glColor3f(1.0f,0.5f,0.0f);
00130 glVertex3f( (float)Xcor, (float)Ycor, (float)Zcor );
00131
00132 Xcor = parentConf[0];
00133 Ycor = parentConf[1];
00134 Zcor = parentConf[2];
00135 glColor3f(1.0f,0.0f,0.0f);
00136 glVertex3f( (float)Xcor, (float)Ycor, (float)Zcor );
00137 }
00138 glEnd();
00139 }
00140
00141
00142 if( lightingState != FALSE )
00143 {
00144 glEnable( GL_LIGHTING );
00145 }
00146
00147 semaphore.Unlock();
00148
00149 Sleep( 50 );
00150
00151 return true;
00152 }
00153
00154 bool PL_RRT_ClosedChain::Plan ()
00155 {
00156 srand( (unsigned)time( NULL ) );
00157
00158 path.Clear();
00159
00160
00161 StartTimer();
00162
00163
00164 CompareLocalPlanners();
00165 return false;
00166
00167
00168 Configuration startConf = GetStartConfig();
00169 CreateTree(startConf);
00170
00171 int result = ERR_FAIL;
00172 bool pathFound = false;
00173 m_goalVert = NULL;
00174
00175
00176
00177
00178
00179
00180
00181
00182 int repeatNum = 0;
00183 while ((!pathFound) && (result != ERR_TIMEOUT))
00184 {
00185 PA_Points localPath;
00186 Configuration randConf = PL_PRM::GenerateRandomConfig();
00187
00188 vertex fromVert = FindClosestInTree(randConf);
00189 Configuration fromConf = GetConfigurationFromTree(fromVert);
00190 Configuration toConf;
00191
00192
00193
00194 if (m_nAlgorithm == ALG_CLOSEDCHAIN_JACOBIAN)
00195 result = ExtendJacobian(fromConf, toConf, randConf, localPath);
00196 else
00197 result = Extend(fromConf, toConf, randConf, localPath);
00198
00199
00200 if (result == ERR_SUCCESS)
00201 {
00202 Log("ExtendDistance.log", "%f", Distance(fromConf, toConf));
00203 fromVert = AddNodeInTree(fromVert, toConf, localPath);
00204
00205
00206
00207 if (ConnectToGoal(fromVert) == ERR_SUCCESS)
00208 {
00209 pathFound = true;
00210 }
00211
00212 }
00213
00214
00215
00216
00217 if ( HasTimeLimitExpired() )
00218 {
00219 break;
00220 }
00221
00222 }
00223
00224
00225 if (pathFound)
00226 {
00227 assert(m_goalVert != NULL);
00228 RetrievePath(m_goalVert);
00229 }
00230
00231 OutputStatistics();
00232 return pathFound;
00233 }
00234
00235 int PL_RRT_ClosedChain::Extend(Configuration &fromConf, Configuration &toConf, Configuration dirConf, PA_Points &localPath)
00236 {
00237 std::vector<Frame> edgeTraj;
00238 localPath.Clear();
00239
00240 double pathLen = 0;
00241 bool trajExtracted = true;
00242
00243
00244 double dist = Distance(fromConf, dirConf);
00245 if (dist > LEN_STEP_SIZE)
00246 toConf = fromConf * (1-LEN_STEP_SIZE/dist) + dirConf * (LEN_STEP_SIZE/dist);
00247 else
00248 toConf = dirConf;
00249
00250
00251
00252
00253
00254
00255
00256
00257 bool result = MakeItClosed( toConf );
00258
00259 if (!result)
00260 {
00261 return ERR_FAIL;
00262 }
00263
00264 if ( IsInterfering(fromConf, toConf) == false)
00265 {
00266 for (int i=0; i<edgeFrag->size(); i++)
00267 {
00268 list_item itt = edgeFrag->get_item(i);
00269 Configuration conf = edgeFrag->contents(itt);
00270 localPath.AppendPoint(conf);
00271 }
00272 edgeFrag->clear();
00273
00274 return ERR_SUCCESS;
00275 }
00276
00277 return ERR_FAIL;
00278 }
00279
00280 int PL_RRT_ClosedChain::ExtendJacobian(Configuration &fromConf, Configuration &toConf, Configuration dirConf, PA_Points &localPath)
00281 {
00282 std::vector<Frame> edgeTraj;
00283 localPath.Clear();
00284
00285 double pathLen = 0;
00286 bool trajExtracted = true;
00287
00288 Configuration dirVel = dirConf;
00289 dirVel -= fromConf;
00290 toConf = fromConf;
00291
00292
00293 jacobian->SetConfiguration(fromConf);
00294
00295 Matrixmxn mJEnd, mJEndInv;
00296 Matrixmxn mTemp(m_nDof, m_nDof);
00297 Matrixmxn matrixIdentity(m_nDof, m_nDof);
00298 double distTravel=0;
00299 localPath.AppendPoint(fromConf);
00300 bool bCollisionFree = true;
00301 Configuration lastConf = fromConf;
00302 #ifdef _MULTIPLE_STEP
00303 while(distTravel<LEN_STEP_SIZE)
00304 {
00305 jacobian->SetInterestPoint(m_nDof-1, m_frEndEffector, true, false);
00306 mJEnd = *(jacobian->GetMatrix());
00307 mJEnd.Inverse(mJEndInv);
00308 mTemp = matrixIdentity;
00309 mTemp -= mJEndInv * mJEnd;
00310 dirVel = mTemp * dirVel;
00311 dirVel *= (DEF_RESOLUTION / dirVel.Magnitude());
00312 toConf = toConf + dirVel;
00313 if (MakeItClosed(toConf))
00314 {
00315 if (IsInterfering(toConf, fromConf))
00316 {
00317 bCollisionFree = false;
00318 localPath.Clear();
00319 break;
00320 }
00321 else
00322 {
00323
00324 for (int i=0; i<edgeFrag->size(); i++)
00325 {
00326 list_item itt = edgeFrag->get_item(i);
00327 Configuration conf = edgeFrag->contents(itt);
00328 localPath.AppendPoint(conf);
00329 }
00330 edgeFrag->clear();
00331 jacobian->SetConfiguration(toConf);
00332 distTravel += dirVel.Magnitude();
00333 dirVel = dirConf - toConf;
00334 lastConf = toConf;
00335 if (distTravel < MIN_DIST_CHANGE)
00336 break;
00337 }
00338 }
00339 else
00340 {
00341 bCollisionFree = false;
00342 localPath.Clear();
00343 break;
00344 }
00345 }
00346 #else
00347 jacobian->SetInterestPoint(m_nDof-1, m_frEndEffector, true, false);
00348 mJEnd = *(jacobian->GetMatrix());
00349 mJEnd.Inverse(mJEndInv);
00350 mTemp = matrixIdentity;
00351 mTemp -= mJEndInv * mJEnd;
00352 dirVel = mTemp * dirVel;
00353 dirVel *= (DEF_RESOLUTION / dirVel.Magnitude());
00354 toConf = toConf + dirVel;
00355 MakeItClosed(toConf);
00356
00357 if (IsInterfering(toConf, fromConf))
00358 {
00359 bCollisionFree = false;
00360 localPath.Clear();
00361 }
00362 else
00363 {
00364 localPath.AppendPoint(toConf);
00365 }
00366 #endif
00367
00368 if (bCollisionFree)
00369 {
00370
00371 return ERR_SUCCESS;
00372 }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 return ERR_FAIL;
00385 }
00386
00387
00388 int PL_RRT_ClosedChain::ConnectToGoal()
00389 {
00390 Configuration goalConf = GetGoalConfig();
00391 Frame goalPose = GetToolFrame(goalConf);
00392
00393 vertex fromVert = fromVert = FindClosestInTree(goalConf);
00394 return ConnectToGoal(fromVert);
00395 }
00396
00397
00398 int PL_RRT_ClosedChain::ConnectToGoal(vertex fromVert)
00399 {
00400 Configuration goalConf = GetGoalConfig();
00401 if (fromVert==NULL)
00402 {
00403 return ERR_FAIL;
00404 }
00405
00406 Configuration fromConf = GetConfigurationFromTree(fromVert);
00407 if (!IsInterfering(fromConf, goalConf))
00408 {
00409 PA_Points localPath;
00410 for (int i=0; i<edgeFrag->size(); i++)
00411 {
00412 list_item itt = edgeFrag->get_item(i);
00413 Configuration conf = edgeFrag->contents(itt);
00414 localPath.AppendPoint( conf );
00415 }
00416 edgeFrag->clear();
00417 m_goalVert = AddNodeInTree(fromVert, goalConf, localPath);
00418 localPath.Clear();
00419 return ERR_SUCCESS;
00420 }
00421 return ERR_FAIL;
00422 }
00423
00424 bool PL_RRT_ClosedChain::CreateTree(Configuration &conf)
00425 {
00426 if (m_rootVert != NULL)
00427 {
00428 ClearTree();
00429 }
00430
00431 VertexInfoInTree *newNode = new VertexInfoInTree;
00432 newNode->conf = conf;
00433
00434 Semaphore semaphore( guid );
00435 semaphore.Lock();
00436 m_rootVert = m_trajTree.make(newNode);
00437 m_vertices.push_back(m_rootVert);
00438 semaphore.Unlock();
00439
00440 return true;
00441 }
00442
00443 void PL_RRT_ClosedChain::ClearTree()
00444 {
00445 Semaphore semaphore( guid );
00446 semaphore.Lock();
00447 for (int i=0; i<m_vertices.size(); i++)
00448 {
00449 VertexInfoInTree *info;
00450 info = (VertexInfoInTree *)m_trajTree.vertex_inf(m_vertices[i]);
00451 delete info;
00452 }
00453
00454 m_trajTree.clear();
00455 m_vertices.clear();
00456 m_rootVert = NULL;
00457 semaphore.Unlock();
00458 }
00459
00460 vertex PL_RRT_ClosedChain::AddNodeInTree(vertex parentVertex, Configuration &childConf, PA_Points &localPath)
00461 {
00462 VertexInfoInTree *newNode = new VertexInfoInTree;
00463 newNode->conf = childConf;
00464 CopyPath(newNode->edge, localPath);
00465
00466 Semaphore semaphore( guid );
00467 semaphore.Lock();
00468 vertex newVert = m_trajTree.make(newNode);
00469 m_vertices.push_back(newVert);
00470 m_trajTree.link(newVert, parentVertex, 1);
00471 semaphore.Unlock();
00472
00473 return newVert;
00474 }
00475
00476 vertex PL_RRT_ClosedChain::FindClosestInTree(Configuration &conf)
00477 {
00478 if (m_vertices.size() == 0)
00479 return NULL;
00480
00481 VertexInfoInTree *info;
00482 double minDist, currDist;
00483 int minIndex=0;
00484
00485 info = (VertexInfoInTree *)m_trajTree.vertex_inf(m_vertices[0]);
00486 minDist = Distance(info->conf, conf);
00487 minIndex = 0;
00488
00489 for (int i=1; i<m_vertices.size(); i++)
00490 {
00491 info = (VertexInfoInTree *)m_trajTree.vertex_inf(m_vertices[i]);
00492 currDist = Distance(info->conf, conf);
00493 if (currDist < minDist)
00494 {
00495 minDist = currDist;
00496 minIndex = i;
00497 }
00498 }
00499
00500 return m_vertices[minIndex];
00501 }
00502
00503 Configuration& PL_RRT_ClosedChain::GetConfigurationFromTree(vertex vert)
00504 {
00505 VertexInfoInTree *info;
00506 info = (VertexInfoInTree *)m_trajTree.vertex_inf(vert);
00507 return info->conf;
00508 }
00509
00510 double PL_RRT_ClosedChain::Distance(const Configuration &conf1, const Configuration &conf2)
00511 {
00512 double dist = 0;
00513 VectorN jointDiff = collisionDetector->JointDisplacement(conf1, conf2);
00514 for(int i = 0; i < jointDiff.Length(); i++)
00515 {
00516 dist += (jointDiff[i])*(jointDiff[i]);
00517 }
00518 return sqrt(dist);
00519 }
00520
00521 PA_Points& PL_RRT_ClosedChain::GetPathFromTree(vertex vert)
00522 {
00523 VertexInfoInTree *info;
00524 info = (VertexInfoInTree *)m_trajTree.vertex_inf(vert);
00525 return info->edge;
00526 }
00527
00528 void PL_RRT_ClosedChain::RetrievePath(vertex &goalVert)
00529 {
00530 vertex currVert = goalVert;
00531 while (currVert != NULL)
00532 {
00533 InsertPath(path, GetPathFromTree(currVert));
00534
00535 currVert = m_trajTree.parent(currVert);
00536 }
00537 }
00538
00539 void PL_RRT_ClosedChain::AppendPath(PA_Points &collect, PA_Points &local)
00540 {
00541 for (int i=0; i<local.Size(); i++)
00542 {
00543 collect.AppendPoint(local[i]);
00544 }
00545 }
00546
00547 void PL_RRT_ClosedChain::AppendPath(PA_Points &collect, PA_Points *local)
00548 {
00549 for (int i=0; i<local->Size(); i++)
00550 {
00551 collect.AppendPoint(local->GetPoint(i));
00552 }
00553 }
00554
00555 void PL_RRT_ClosedChain::InsertPath(PA_Points &target, PA_Points &source)
00556 {
00557 int nLen = source.Size()-1;
00558 if ( target.Size() != 0 )
00559 {
00560 nLen = nLen - 1;
00561 }
00562 for( int i = nLen; i >= 0; i-- )
00563 {
00564 target.AppendPointToBeginning( source[ i ] ) ;
00565 }
00566 }
00567
00568 void PL_RRT_ClosedChain::OutputStatistics()
00569 {
00570 double dTimeElapsed = GetTimeElapsedInSeconds();
00571 int nLinearCD = collisionDetector->GetNumberOfTimesCalledLinear();
00572 int nBoolCD = collisionDetector->GetNumberOfTimesCalledPoint();
00573 int nNodeNum = m_vertices.size();
00574 int nPathLen = path.Size();
00575 bool bSuccess = (nPathLen != 0);
00576
00577 Log("ClosedChainRRT.log", "%d, %f, %d, %d, %d, %d",
00578 bSuccess, dTimeElapsed, nLinearCD, nBoolCD, nNodeNum, nPathLen);
00579 }
00580
00581
00582
00583
00584
00585 bool PL_RRT_ClosedChain::TestJacobianConnection(Configuration &testStartConf, Configuration &testGoalConf, PA_Points &localPath)
00586 {
00587 ClosedChainAlgorithm currentAlg = m_nAlgorithm;
00588 m_nAlgorithm = ALG_CLOSEDCHAIN_JACOBIAN;
00589 localPath.Clear();
00590 bool bValid = !(PL_PRM_ClosedJacobian::IsInterfering(testStartConf, testGoalConf));
00591 if (bValid)
00592 {
00593 for (int i=0; i<edgeFrag->size(); i++)
00594 {
00595 list_item itt = edgeFrag->get_item(i);
00596 Configuration conf = edgeFrag->contents(itt);
00597 localPath.AppendPoint(conf);
00598 }
00599 edgeFrag->clear();
00600 }
00601
00602 m_nAlgorithm = currentAlg;
00603 return bValid;
00604 }
00605
00606 bool PL_RRT_ClosedChain::TestRGDConnection(Configuration &testStartConf, Configuration &testGoalConf, PA_Points &localPath)
00607 {
00608 ClosedChainAlgorithm currentAlg = m_nAlgorithm;
00609 m_nAlgorithm = ALG_CLOSEDCHAIN_RGD;
00610 localPath.Clear();
00611 bool bValid = !(PL_PRM_ClosedRGD::IsInterfering(testStartConf, testGoalConf));
00612 if (bValid)
00613 {
00614 for (int i=0; i<edgeFrag->size(); i++)
00615 {
00616 list_item itt = edgeFrag->get_item(i);
00617 Configuration conf = edgeFrag->contents(itt);
00618 localPath.AppendPoint(conf);
00619 }
00620 edgeFrag->clear();
00621 }
00622
00623 m_nAlgorithm = currentAlg;
00624 return bValid;
00625 }
00626
00627 bool PL_RRT_ClosedChain::TestAPDecompConnection(Configuration &testStartConf, Configuration &testGoalConf, PA_Points &localPath)
00628 {
00629 ClosedChainAlgorithm currentAlg = m_nAlgorithm;
00630 m_nAlgorithm = ALG_CLOSEDCHAIN_APD;
00631 localPath.Clear();
00632 bool bValid = !(PL_PRM_ClosedAPDecomp::IsInterfering(testStartConf, testGoalConf));
00633 if (bValid)
00634 {
00635 for (int i=0; i<edgeFrag->size(); i++)
00636 {
00637 list_item itt = edgeFrag->get_item(i);
00638 Configuration conf = edgeFrag->contents(itt);
00639 localPath.AppendPoint(conf);
00640 }
00641 edgeFrag->clear();
00642 }
00643
00644 m_nAlgorithm = currentAlg;
00645 return bValid;
00646 }
00647
00648 void PL_RRT_ClosedChain::CompareLocalPlanners()
00649 {
00650 int numTest = 100;
00651 Configuration testStart, testGoal;
00652 if (jacobian==NULL)
00653 jacobian = new CJacobian(*m_pRobot);
00654
00655 testStart = GetStartConfig();
00656 testGoal = GetGoalConfig();
00657
00658 Log("CompareLocalPlanners.log", "===============Begin===============");
00659 Log("CompareLocalPlanners.log", "Planner: S/F, Time, Len, Max, Min");
00660 for (int i=0; i<numTest; i++)
00661 {
00662 #if 1
00663 do{
00664 testStart = GenerateRandomConfig(testStart, DEF_NEIGHBOR*0.5);
00665 } while(!IsClosed(testStart));
00666 do
00667 {
00668 testGoal = GenerateRandomConfig(testGoal, DEF_NEIGHBOR*0.5);
00669 } while(!IsClosed(testGoal));
00670 #endif
00671 Log("PathByJacobian.log", "Start Configuration");
00672 LogConfiguration("PathByJacobian.log", testStart);
00673 Log("PathByJacobian.log", "Goal Configuration");
00674 LogConfiguration("PathByJacobian.log", testGoal);
00675
00676
00677
00678
00679
00680
00681 int nDof = testStart.DOF();
00682 PA_Points foundPath;
00683
00684
00685
00686 bool bJacobian = false;
00687 double timeForJacobian = 0;
00688 int nPathLenForJacobian = 0;
00689 int nCDBoolForJacobian, nCDLinearForJacobian;
00690 nCDBoolForJacobian = nCDLinearForJacobian = 0;
00691 double dMaxForJacobian, dMinForJacobian;
00692 dMaxForJacobian = dMinForJacobian = 0;
00693 #if 1
00694 collisionDetector->ResetStats();
00695 timeForJacobian = GetTimeElapsedInSeconds();
00696 bJacobian = TestJacobianConnection(testStart, testGoal, foundPath);
00697 timeForJacobian = GetTimeElapsedInSeconds() - timeForJacobian;
00698 nCDLinearForJacobian = collisionDetector->GetNumberOfTimesCalledLinear();
00699 nCDBoolForJacobian = collisionDetector->GetNumberOfTimesCalledPoint();
00700 nPathLenForJacobian = foundPath.Size();
00701
00702 if ((bJacobian) && (nPathLenForJacobian>1))
00703 {
00704 Configuration diff=foundPath[1]-foundPath[0];
00705 double distance = diff.Magnitude();
00706 dMaxForJacobian = dMinForJacobian = distance;
00707 for(int k=2; k<nPathLenForJacobian; k++)
00708 {
00709 diff=foundPath[k]-foundPath[k-1];
00710 distance = diff.Magnitude();
00711 if (distance > dMaxForJacobian)
00712 dMaxForJacobian = distance;
00713 if (distance < dMinForJacobian)
00714 dMinForJacobian = distance;
00715 }
00716
00717 Log("PathByJacobian.log", "Path: %d [out of %d]", i, numTest);
00718 LogPath("PathByJacobian.log", foundPath);
00719 }
00720
00721 foundPath.Clear();
00722 #endif
00723
00724
00725
00726 bool bRGD=false;
00727 double timeForRGD = 0;
00728 int nPathLenForRGD = 0;
00729 int nCDBoolForRGD, nCDLinearForRGD;
00730 nCDBoolForRGD = nCDLinearForRGD = 0;
00731 double dMaxForRGD, dMinForRGD;
00732 dMaxForRGD = dMinForRGD = 0;
00733 #if 1
00734 collisionDetector->ResetStats();
00735 timeForRGD = GetTimeElapsedInSeconds();
00736 bRGD = TestRGDConnection(testStart, testGoal, foundPath);
00737 timeForRGD = GetTimeElapsedInSeconds() - timeForRGD;
00738 nCDLinearForRGD = collisionDetector->GetNumberOfTimesCalledLinear();
00739 nCDBoolForRGD = collisionDetector->GetNumberOfTimesCalledPoint();
00740 nPathLenForRGD = foundPath.Size();
00741
00742 if ((bRGD) && (nPathLenForRGD>1))
00743 {
00744 Configuration diff=foundPath[1]-foundPath[0];
00745 double distance = diff.Magnitude();
00746 dMaxForRGD = dMinForRGD = distance;
00747 for(int k=2; k<nPathLenForRGD; k++)
00748 {
00749 diff=foundPath[k]-foundPath[k-1];
00750 distance = diff.Magnitude();
00751 if (distance > dMaxForRGD)
00752 dMaxForRGD = distance;
00753 if (distance < dMinForRGD)
00754 dMinForRGD = distance;
00755 }
00756
00757 Log("PathByRGD.log", "Path: %d [out of %d]", i, numTest);
00758 LogPath("PathByRGD.log", foundPath);
00759 }
00760
00761 foundPath.Clear();
00762 #endif
00763
00764
00765
00766 bool bAPDecomp = false;
00767 double timeForAPDecomp = 0;
00768 int nPathLenForAPDecomp = 0;
00769 int nCDBoolForAPDecomp, nCDLinearForAPDecomp;
00770 nCDBoolForAPDecomp = nCDLinearForAPDecomp = 0;
00771 double dMaxForAPDecomp, dMinForAPDecomp;
00772 dMaxForAPDecomp = dMinForAPDecomp = 0;
00773 #if 1
00774 collisionDetector->ResetStats();
00775 timeForAPDecomp = GetTimeElapsedInSeconds();
00776 bAPDecomp = TestAPDecompConnection(testStart, testGoal, foundPath);
00777 timeForAPDecomp = GetTimeElapsedInSeconds() - timeForAPDecomp;
00778 nCDLinearForAPDecomp = collisionDetector->GetNumberOfTimesCalledLinear();
00779 nCDBoolForAPDecomp = collisionDetector->GetNumberOfTimesCalledPoint();
00780 nPathLenForAPDecomp = foundPath.Size();
00781
00782 if ((bAPDecomp) && (nPathLenForAPDecomp>1))
00783 {
00784 Configuration diff=foundPath[1]-foundPath[0];
00785 double distance = diff.Magnitude();
00786 dMaxForAPDecomp = dMinForAPDecomp = distance;
00787 for(int k=2; k<nPathLenForAPDecomp; k++)
00788 {
00789 diff=foundPath[k]-foundPath[k-1];
00790 distance = diff.Magnitude();
00791 if (distance > dMaxForAPDecomp)
00792 dMaxForAPDecomp = distance;
00793 if (distance < dMinForAPDecomp)
00794 dMinForAPDecomp = distance;
00795 }
00796
00797 Log("PathByAPDecomp.log", "Path: %d [out of %d]", i, numTest);
00798 LogPath("PathByAPDecomp.log", foundPath);
00799 }
00800
00801 foundPath.Clear();
00802 #endif
00803
00804 Log("CompareLocalPlanners.log", "Jacobian: %d, %.3f, %d, %.3f, %.3f, %d, %d;\nRGD: %d, %.3f, %d, %.3f, %.3f, %d, %d;\nAPDecomp: %d, %.3f, %d, %.3f, %.3f, %d, %d; ",
00805 bJacobian, timeForJacobian, nPathLenForJacobian, dMaxForJacobian, dMinForJacobian, nCDLinearForJacobian, nCDBoolForJacobian,
00806 bRGD, timeForRGD, nPathLenForRGD, dMaxForRGD, dMinForRGD, nCDLinearForRGD, nCDBoolForRGD,
00807 bAPDecomp, timeForAPDecomp, nPathLenForAPDecomp, dMaxForAPDecomp, dMinForAPDecomp, nCDLinearForAPDecomp, nCDBoolForAPDecomp);
00808 }
00809
00810 }