39std::vector<AbstractInterpolationPtr>
41 std::vector<PoseBasePtr> controlPoints,
42 std::vector<InterpolationType> interpolations)
44 if (controlPoints.size() != interpolations.size() + 1)
47 controlPoints.size(), interpolations.size());
50 std::vector<AbstractInterpolationPtr> producedInterpolations =
51 std::vector<AbstractInterpolationPtr>();
53 std::vector<int> interPolationChangePoints = std::vector<int>();
54 interPolationChangePoints.push_back(0);
62 int splineCounter = 0;
68 for (
unsigned int i = 1; i < interpolations.size(); i++)
74 if (current != interpolations.at(i))
78 if (splineCounter < 2)
84 interPolationChangePoints.push_back(i);
90 interPolationChangePoints.push_back(i);
92 current = interpolations[i];
95 if (interpolations.size() >= 2 &&
99 interpolations.pop_back();
119 for (
unsigned int j = 1; j < interPolationChangePoints.size(); j++)
121 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
122 for (
int i = interPolationChangePoints.at(j - 1); i <= interPolationChangePoints.at(j); i++)
124 currentCP.push_back(controlPoints.at(i));
126 std::vector<AbstractInterpolationPtr> temp;
127 switch (interpolations.at(interPolationChangePoints.at(j - 1)))
136 producedInterpolations.insert(producedInterpolations.end(), temp.begin(), temp.end());
139 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
140 for (
unsigned int i = interPolationChangePoints.at(interPolationChangePoints.size() - 1);
141 i < controlPoints.size();
144 currentCP.push_back(controlPoints.at(i));
146 std::vector<AbstractInterpolationPtr> temp;
147 switch (interpolations.at(interpolations.size() - 1))
156 producedInterpolations.insert(producedInterpolations.end(), temp.begin(), temp.end());
157 return producedInterpolations;
160std::vector<AbstractInterpolationPtr>
162 std::vector<PoseBasePtr> controlPoints)
164 std::vector<AbstractInterpolationPtr> producedInterpolations =
165 std::vector<AbstractInterpolationPtr>();
166 for (
unsigned int i = 0; i < controlPoints.size() - 1; i++)
168 std::vector<PoseBasePtr> currentCP = std::vector<PoseBasePtr>();
169 currentCP.push_back(controlPoints.at(i));
170 currentCP.push_back(controlPoints.at(i + 1));
173 producedInterpolations.push_back(interpolation);
175 return producedInterpolations;
178std::vector<AbstractInterpolationPtr>
180 std::vector<PoseBasePtr> controlPoints)
182 std::vector<AbstractInterpolationPtr> producedInterpolations =
183 std::vector<AbstractInterpolationPtr>();
187 for (
unsigned int i = 0; i < controlPoints.size() - 1; i++)
190 std::shared_ptr<AbstractInterpolation>(parent->getInterPolationSegment(i));
191 producedInterpolations.push_back(interpolation);
193 return producedInterpolations;
198 std::vector<PoseBasePtr> controlPoints,
199 PoseBasePtr segmentStart)
205 std::shared_ptr<AbstractInterpolation>(parent->getInterPolationSegment(segmentStart));
207 return interpolation;
217 std::vector<PoseBasePtr>& controlPoints,
218 std::vector<IKSolver::CartesianSelection>& selections)
227 for (
unsigned int i = 0; i < selections.size() - 1; i++)
232 std::vector<IKSolver::CartesianSelection> followingDominations =
233 std::vector<IKSolver::CartesianSelection>();
234 followingDominations.push_back(selections[i + 1]);
235 int followingDominationsStart = i;
240 for (
int j = i; j >= 0; j--)
243 selections[i + 1]) &&
246 selections[i + 1] == selections[j])
250 followingDominationsStart = j + 1;
252 int dominanceIntervalSize = i + 1 - j;
253 PoseBasePtr dominanceIntervalStart = controlPoints[j];
254 PoseBasePtr dominanceIntervalEnd = controlPoints[i + 1];
255 std::vector<AbstractInterpolationPtr> li =
257 {dominanceIntervalStart, dominanceIntervalEnd});
259 for (
unsigned int k = j + 1; k < i + 1; k++)
263 li[0]->getPoseAt(
double(1.0 / dominanceIntervalSize) * counter),
271 followingDominations.push_back(selections[j]);
274 if (i + 2 < selections.size() &&
279 followingDominations.push_back(selections[i + 1]);
286 }
while (!isBreaking);
292 IKSolver::CartesianSelection dominatingSelection =
294 for (
unsigned int m = followingDominationsStart; m <= i + 1; m++)
297 selections[m] = dominatingSelection;
317 for (
unsigned int i = 0; i < selections.size() - 1; i++)
330 VirtualRobot::IKSolver::CartesianSelection other)
332 if (other == IKSolver::CartesianSelection::X || other == IKSolver::CartesianSelection::Y ||
333 other == IKSolver::CartesianSelection::Z ||
334 other == IKSolver::CartesianSelection::Orientation)
336 return current != other;
338 else if (other == IKSolver::CartesianSelection::Position)
340 return (current == IKSolver::CartesianSelection::Orientation ||
341 current == IKSolver::CartesianSelection::All);
346IKSolver::CartesianSelection
348 std::vector<VirtualRobot::IKSolver::CartesianSelection> selections)
350 bool isInhomogenous =
false;
353 for (IKSolver::CartesianSelection current : selections)
357 ARMARX_INFO <<
"In Vector" + std::to_string(current);
360 if (
max != 0 && current !=
max)
362 isInhomogenous =
true;
365 if (
max <= 4 && isInhomogenous)
368 std::to_string(IKSolver::CartesianSelection::Position);
369 return IKSolver::CartesianSelection::Position;
371 else if (
max == IKSolver::CartesianSelection::Orientation)
373 for (IKSolver::CartesianSelection currentSelection : selections)
375 if (currentSelection != IKSolver::CartesianSelection::Orientation)
378 std::to_string(IKSolver::CartesianSelection::All);
379 return IKSolver::CartesianSelection::All;
383 std::to_string(IKSolver::CartesianSelection::Orientation);
384 return IKSolver::CartesianSelection::Orientation;
389 return static_cast<IKSolver::CartesianSelection
>(
max);
395 PoseBasePtr corrected,
396 IKSolver::CartesianSelection selectionOriginal,
397 IKSolver::CartesianSelection selectionCorrecting)
401 PoseBasePtr firstStep;
402 switch (selectionCorrecting)
404 case (IKSolver::CartesianSelection::X):
405 firstStep = PoseBasePtr(
407 corrected->position->x, original->position->y, original->position->z)),
408 original->orientation));
409 case (IKSolver::CartesianSelection::Y):
410 firstStep = PoseBasePtr(
412 original->position->x, corrected->position->y, original->position->z)),
413 original->orientation));
414 case (IKSolver::CartesianSelection::Z):
415 firstStep = PoseBasePtr(
417 original->position->x, original->position->y, corrected->position->z)),
418 original->orientation));
419 case (IKSolver::CartesianSelection::Position):
420 firstStep = PoseBasePtr(
new Pose(corrected->position, original->orientation));
421 case (IKSolver::CartesianSelection::Orientation):
422 firstStep = PoseBasePtr(
new Pose(original->position, corrected->orientation));
423 case (IKSolver::CartesianSelection::All):
425 firstStep = corrected;
427 switch (selectionOriginal)
429 case (IKSolver::CartesianSelection::X):
430 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(original->position->x,
431 firstStep->position->y,
432 firstStep->position->z)),
433 firstStep->orientation));
434 case (IKSolver::CartesianSelection::Y):
435 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(firstStep->position->x,
436 original->position->y,
437 firstStep->position->z)),
438 firstStep->orientation));
439 case (IKSolver::CartesianSelection::Z):
440 return PoseBasePtr(
new Pose(Vector3BasePtr(
new Vector3(firstStep->position->x,
441 firstStep->position->y,
442 original->position->z)),
443 firstStep->orientation));
444 case (IKSolver::CartesianSelection::Position):
445 return PoseBasePtr(
new Pose(original->position, firstStep->orientation));
446 case (IKSolver::CartesianSelection::Orientation):
447 return PoseBasePtr(
new Pose(firstStep->position, original->orientation));
448 case (IKSolver::CartesianSelection::All):
static std::vector< AbstractInterpolationPtr > produceInterpolationSegments(std::vector< PoseBasePtr > controlPoints, std::vector< InterpolationType > interpolations)
produceInterpolationSegments constructs a vector of AbstractInterpolation the concrete Interpolationt...
static bool needsOptimizing(std::vector< VirtualRobot::IKSolver::CartesianSelection > &selections)
needsOptimizing returns true if there is a CartesianSelection at i that dominates a CartesianSelectio...
static bool isDominantOver(VirtualRobot::IKSolver::CartesianSelection current, VirtualRobot::IKSolver::CartesianSelection other)
isDominantOver returns true when current selection dominates other selection Definition: A CartesianS...
static AbstractInterpolationPtr produceSplineInterpolationSegment(std::vector< PoseBasePtr > controlPoints, PoseBasePtr segmentStart)
produceSplineInterpolationSegment constructs the splineInterpolationSegment of a splineInterpolation ...
static PoseBasePtr optimizePose(armarx::PoseBasePtr original, armarx::PoseBasePtr corrected, VirtualRobot::IKSolver::CartesianSelection selectionOriginal, VirtualRobot::IKSolver::CartesianSelection selectionCorrected)
optimizePose changes the original pose so that the interpolation is smove when it changes from select...
static void optimizeControlPoints(std::vector< PoseBasePtr > &controlPoints, std::vector< VirtualRobot::IKSolver::CartesianSelection > &selections)
optimizeControlPoints changes the cartian selections and control points so that the IKSolving produce...
static std::vector< AbstractInterpolationPtr > produceSplineInterpolationSegments(std::vector< PoseBasePtr > controlPoints)
produceInterpolationSegments constructs a vector of SplineInterpolations
static VirtualRobot::IKSolver::CartesianSelection getSmallestDominating(std::vector< VirtualRobot::IKSolver::CartesianSelection > selections)
getSmallestDominating returns the cartesian selection that dominates all other cartesian selections i...
static std::vector< AbstractInterpolationPtr > produceLinearInterpolationSegments(std::vector< PoseBasePtr > controlPoints)
produceInterpolationSegments constructs a vector of LinearInterpolations
The LinearInterpolation class represents a linear Interpolation between a series of control points Li...
The SplineInterpolation class represents a linear Interpolation between a series of control points Sp...
#define ARMARX_INFO
The normal logging level.
This file offers overloads of toIce() and fromIce() functions for STL container types.
InterpolationType
The InterpolationType enum lists all available interpolation types eLinearInterpolation: represents l...
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::shared_ptr< SplineInterpolation > SplineInterpolationPtr
std::shared_ptr< AbstractInterpolation > AbstractInterpolationPtr