29 #include "../exceptions/InterpolationNotDefinedException.h"
30 #include "../exceptions/NoInterpolationPossibleException.h"
31 #include "../exceptions/ControlPointsInterpolationMatchException.h"
38 if (controlPoints.size() != interpolations.size() + 1)
43 std::vector<AbstractInterpolationPtr> producedInterpolations = std::vector<AbstractInterpolationPtr>();
45 std::vector<int> interPolationChangePoints = std::vector<int>();
46 interPolationChangePoints.push_back(0);
54 int splineCounter = 0;
60 for (
unsigned int i = 1; i < interpolations.size(); i++)
66 if (current != interpolations.at(i))
70 if (splineCounter < 2)
76 interPolationChangePoints.push_back(i);
82 interPolationChangePoints.push_back(i);
84 current = interpolations[i];
91 interpolations.pop_back();
111 for (
unsigned int j = 1; j < interPolationChangePoints.size(); j++)
113 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
114 for (
int i = interPolationChangePoints.at(j - 1); i <= interPolationChangePoints.at(j); i++)
116 currentCP.push_back(controlPoints.at(i));
118 std::vector<AbstractInterpolationPtr> temp;
119 switch (interpolations.at(interPolationChangePoints.at(j - 1)))
122 temp = produceLinearInterpolationSegments(currentCP);
125 temp = produceSplineInterpolationSegments(currentCP);
128 producedInterpolations.insert(producedInterpolations.end(), temp.begin(), temp.end());
131 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
132 for (
unsigned int i = interPolationChangePoints.at(interPolationChangePoints.size() - 1); i < controlPoints.size(); i++)
134 currentCP.push_back(controlPoints.at(i));
136 std::vector<AbstractInterpolationPtr> temp;
137 switch (interpolations.at(interpolations.size() - 1))
140 temp = produceLinearInterpolationSegments(currentCP);
143 temp = produceSplineInterpolationSegments(currentCP);
146 producedInterpolations.insert(producedInterpolations.end(), temp.begin(), temp.end());
147 return producedInterpolations;
153 std::vector<AbstractInterpolationPtr> producedInterpolations = std::vector<AbstractInterpolationPtr>();
154 for (
unsigned int i = 0; i < controlPoints.size() - 1; i++)
156 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
157 currentCP.push_back(controlPoints.at(i));
158 currentCP.push_back(controlPoints.at(i + 1));
160 producedInterpolations.push_back(interpolation);
162 return producedInterpolations;
167 std::vector<AbstractInterpolationPtr> producedInterpolations = std::vector<AbstractInterpolationPtr>();
170 for (
unsigned int i = 0; i < controlPoints.size() - 1; i++)
172 AbstractInterpolationPtr interpolation = std::shared_ptr<AbstractInterpolation>(parent->getInterPolationSegment(i));
173 producedInterpolations.push_back(interpolation);
175 return producedInterpolations;
182 AbstractInterpolationPtr interpolation = std::shared_ptr<AbstractInterpolation>(parent->getInterPolationSegment(segmentStart));
184 return interpolation;
200 for (
unsigned int i = 0; i < selections.size() - 1; i++)
205 std::vector<IKSolver::CartesianSelection> followingDominations = std::vector<IKSolver::CartesianSelection>();
206 followingDominations.push_back(selections[i + 1]);
207 int followingDominationsStart = i;
212 for (
int j = i ; j >= 0; j--)
215 || selections[i + 1] == selections[j])
219 followingDominationsStart = j + 1;
221 int dominanceIntervalSize = i + 1 - j;
222 PoseBasePtr dominanceIntervalStart = controlPoints[j];
223 PoseBasePtr dominanceIntervalEnd = controlPoints[i + 1];
224 std::vector<AbstractInterpolationPtr> li = produceLinearInterpolationSegments({dominanceIntervalStart, dominanceIntervalEnd});
226 for (
unsigned int k = j + 1; k < i + 1; k++)
228 controlPoints[k] = optimizePose(controlPoints[k], li[0]->getPoseAt(
double(1.0 / dominanceIntervalSize) * counter), selections[k], selections[i + 1]);
235 followingDominations.push_back(selections[j]);
238 if (i + 2 < selections.size() && isDominantOver(selections[i + 2], selections[i + 1]))
242 followingDominations.push_back(selections[i + 1]);
257 for (
unsigned int m = followingDominationsStart; m <= i + 1; m++)
260 selections[m] = dominatingSelection;
280 for (
unsigned int i = 0; i < selections.size() - 1; i++)
295 return current != other;
306 bool isInhomogenous =
false;
316 if (
max != 0 && current !=
max)
318 isInhomogenous =
true;
321 if (
max <= 4 && isInhomogenous)
333 return IKSolver::CartesianSelection::All;
351 PoseBasePtr firstStep;
352 switch (selectionCorrecting)
354 case (IKSolver::CartesianSelection::X):
355 firstStep = PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(corrected->position->x, original->position->y, original->position->z)), original->orientation));
356 case (IKSolver::CartesianSelection::Y):
357 firstStep = PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(original->position->x, corrected->position->y, original->position->z)), original->orientation));
358 case (IKSolver::CartesianSelection::Z):
359 firstStep = PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(original->position->x, original->position->y, corrected->position->z)), original->orientation));
361 firstStep = PoseBasePtr(
new Pose(corrected->position, original->orientation));
363 firstStep = PoseBasePtr(
new Pose(original->position, corrected->orientation));
364 case (IKSolver::CartesianSelection::All):
366 firstStep = corrected;
368 switch (selectionOriginal)
370 case (IKSolver::CartesianSelection::X):
371 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(original->position->x, firstStep->position->y, firstStep->position->z)), firstStep->orientation));
372 case (IKSolver::CartesianSelection::Y):
373 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(firstStep->position->x, original->position->y, firstStep->position->z)), firstStep->orientation));
374 case (IKSolver::CartesianSelection::Z):
375 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(firstStep->position->x, firstStep->position->y, original->position->z)), firstStep->orientation));
377 return PoseBasePtr(
new Pose(original->position, firstStep->orientation));
379 return PoseBasePtr(
new Pose(firstStep->position, original->orientation));
380 case (IKSolver::CartesianSelection::All):