Skip to content

Commit ef36b7e

Browse files
committed
Add PG6 to IK problem builder
1 parent 3c55a18 commit ef36b7e

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

libraries/ScrewTheoryLib/ScrewTheoryIkProblemBuilder.cpp

+22-21
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,14 @@ ScrewTheoryIkProblem::JointIdsToSubproblem ScrewTheoryIkProblemBuilder::trySolve
394394
// Find rightmost unknown and not simplified PoE term.
395395
auto lastUnknown = std::find_if(poeTerms.rbegin(), poeTerms.rend(), unknownNotSimplifiedTerm);
396396
int lastExpId = std::distance(poeTerms.begin(), lastUnknown.base()) - 1;
397-
const MatrixExponential & lastExp = poe.exponentialAtJoint(lastExpId);
397+
const auto & lastExp = poe.exponentialAtJoint(lastExpId);
398398

399399
// Select the most adequate subproblem, if available.
400400
if (unknownsCount == 1)
401401
{
402402
if (depth == 0)
403403
{
404-
if (lastExp.getMotionType() == MatrixExponential::ROTATION
405-
&& !liesOnAxis(lastExp, testPoints[0]))
404+
if (lastExp.getMotionType() == MatrixExponential::ROTATION && !liesOnAxis(lastExp, testPoints[0]))
406405
{
407406
poeTerms[lastExpId].known = true;
408407
return {{lastExpId}, new PadenKahanOne(lastExp, testPoints[0])};
@@ -450,19 +449,30 @@ ScrewTheoryIkProblem::JointIdsToSubproblem ScrewTheoryIkProblemBuilder::trySolve
450449
}
451450

452451
int nextToLastExpId = lastExpId - 1;
453-
const MatrixExponential & nextToLastExp = poe.exponentialAtJoint(nextToLastExpId);
452+
const auto & nextToLastExp = poe.exponentialAtJoint(nextToLastExpId);
454453

455454
if (depth == 0)
456455
{
457-
KDL::Vector r;
458-
459-
if (lastExp.getMotionType() == MatrixExponential::ROTATION
460-
&& nextToLastExp.getMotionType() == MatrixExponential::ROTATION
461-
&& !parallelAxes(lastExp, nextToLastExp)
462-
&& intersectingAxes(lastExp, nextToLastExp, r))
456+
if (lastExp.getMotionType() == MatrixExponential::ROTATION && nextToLastExp.getMotionType() == MatrixExponential::ROTATION)
463457
{
464-
poeTerms[lastExpId].known = poeTerms[nextToLastExpId].known = true;
465-
return {{nextToLastExpId, lastExpId}, new PadenKahanTwo(nextToLastExp, lastExp, testPoints[0], r)};
458+
if (!parallelAxes(lastExp, nextToLastExp))
459+
{
460+
poeTerms[lastExpId].known = poeTerms[nextToLastExpId].known = true;
461+
462+
if (KDL::Vector r; intersectingAxes(lastExp, nextToLastExp, r))
463+
{
464+
return {{nextToLastExpId, lastExpId}, new PadenKahanTwo(nextToLastExp, lastExp, testPoints[0], r)};
465+
}
466+
else
467+
{
468+
return {{nextToLastExpId, lastExpId}, new PardosGotorSix(nextToLastExp, lastExp, testPoints[0])};
469+
}
470+
}
471+
else if (!colinearAxes(lastExp, nextToLastExp))
472+
{
473+
poeTerms[lastExpId].known = poeTerms[nextToLastExpId].known = true;
474+
return {{nextToLastExpId, lastExpId}, new PardosGotorFour(nextToLastExp, lastExp, testPoints[0])};
475+
}
466476
}
467477

468478
if (lastExp.getMotionType() == MatrixExponential::TRANSLATION
@@ -472,15 +482,6 @@ ScrewTheoryIkProblem::JointIdsToSubproblem ScrewTheoryIkProblemBuilder::trySolve
472482
poeTerms[lastExpId].known = poeTerms[nextToLastExpId].known = true;
473483
return {{nextToLastExpId, lastExpId}, new PardosGotorTwo(nextToLastExp, lastExp, testPoints[0])};
474484
}
475-
476-
if (lastExp.getMotionType() == MatrixExponential::ROTATION
477-
&& nextToLastExp.getMotionType() == MatrixExponential::ROTATION
478-
&& parallelAxes(lastExp, nextToLastExp)
479-
&& !colinearAxes(lastExp, nextToLastExp))
480-
{
481-
poeTerms[lastExpId].known = poeTerms[nextToLastExpId].known = true;
482-
return {{nextToLastExpId, lastExpId}, new PardosGotorFour(nextToLastExp, lastExp, testPoints[0])};
483-
}
484485
}
485486
}
486487

0 commit comments

Comments
 (0)