InterpolationSegmentFactory.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXGuiPlugins::RobotTrajectoryDesigner::Interpolation
17 * @author Timo Birr
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#ifndef INTERPOLATIONSEGMENTFACTORY_H
23#define INTERPOLATIONSEGMENTFACTORY_H
24
25#include <VirtualRobot/IK/AdvancedIKSolver.h>
26
28#include "InterpolationType.h"
29
30namespace armarx
31{
32 /**
33 * @brief The InterpolationSegmentFactory class
34 * Utility Class used to easily create InterpolationSegments, so that every Interpolation can be threated the same
35 * An Interpolation produced by this factory always has exactly two Waypoints and is defined between 0 and 1
36 * With 0 being the starting pose and 1 being the end pose
37 */
39 {
40 public:
41 /**
42 * @brief produceInterpolationSegments constructs a vector of AbstractInterpolation the concrete Interpolationtype of which is defined by interpolations
43 * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
44 * @param interpolations the InterpolationTypes of the Interpolation segments (warning: at least 2 segments in a row have to have spline intepolation)
45 * @return a vector of |controlPoints| - 1 AbstractInterpolations between the control points
46 */
47 static std::vector<AbstractInterpolationPtr>
48 produceInterpolationSegments(std::vector<PoseBasePtr> controlPoints,
49 std::vector<InterpolationType> interpolations);
50
51 /**
52 * @brief produceInterpolationSegments constructs a vector of LinearInterpolations
53 * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
54 * @return a vector of |controlPoints| - 1 LinearInterpolations between the control points
55 */
56 static std::vector<AbstractInterpolationPtr>
57 produceLinearInterpolationSegments(std::vector<PoseBasePtr> controlPoints);
58
59 /**
60 * @brief produceInterpolationSegments constructs a vector of SplineInterpolations
61 * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
62 * @return a vector of |controlPoints| - 1 SplineInterpolations between the control points
63 */
64 static std::vector<AbstractInterpolationPtr>
65 produceSplineInterpolationSegments(std::vector<PoseBasePtr> controlPoints);
66
67 /**
68 * @brief produceSplineInterpolationSegment constructs the splineInterpolationSegment of a splineInterpolation between given controlPoints
69 * @param controlPoints the controlPoints of the parent SplineInterpolatiom
70 * @param segmentStart the first Point in the Interval
71 * @return a SplineInterpolationSegment between segmentStart and the following control point
72 */
74 produceSplineInterpolationSegment(std::vector<PoseBasePtr> controlPoints,
75 PoseBasePtr segmentStart);
76
77 /**
78 * @brief optimizeControlPoints changes the cartian selections and control points so that the IKSolving produces a smooth Trajectory
79 * @param controlPoints the controlPoints to change to make the Trajectory smooth
80 * @param selections the cartesian selections to optimize
81 */
82 static void
83 optimizeControlPoints(std::vector<PoseBasePtr>& controlPoints,
84 std::vector<VirtualRobot::IKSolver::CartesianSelection>& selections);
85 /**
86 * @brief needsOptimizing returns true if there is a CartesianSelection at i that dominates a CartesianSelection at i - 1
87 * @param selections the cartesian selection that should be reached
88 * @return true if the cartesian Selection need optimizing for a smooth trajectory
89 */
90 static bool
91 needsOptimizing(std::vector<VirtualRobot::IKSolver::CartesianSelection>& selections);
92 /**
93 * @brief isDominantOver returns true when current selection dominates other selection
94 * Definition: A CartesianSelection dominates another CartesianSelection when additional Information is needed to solve curren after solving other
95 * Examples: - X dominates Y ; Y dominates X ; Pos dominates X,Y ans Z but X,Y and Z dont dominate Pos; Pos dominates Ori ; Ori dominates Pos
96 * @param current the later cartesian selection
97 * @param other the prior cartesian selection
98 * @return true if current dominates other
99 */
100 static bool isDominantOver(VirtualRobot::IKSolver::CartesianSelection current,
101 VirtualRobot::IKSolver::CartesianSelection other);
102 /**
103 * @brief getSmallestDominating returns the cartesian selection that dominates all other cartesian selections in selections
104 * Examples: (X,Y,Y,Y,Z) -> Pos ; (X,Y, Ori) -> All; (Ori,Ori) -> Ori ; (X,Z,Pos) -> Pos
105 * @param selections the selections to get the smallest dominating selection from
106 * @return the smmallestDominating Selection
107 */
108 static VirtualRobot::IKSolver::CartesianSelection
109 getSmallestDominating(std::vector<VirtualRobot::IKSolver::CartesianSelection> selections);
110 /**
111 * @brief optimizePose changes the original pose so that the interpolation is smove when it changes from selectionOriginal to selectionCorrected
112 * @param original the original Pose
113 * @param corrected the absolute corrected Pose
114 * @param selectionOriginal the cartesian selection associated with the original Pose
115 * @param selectionCorrected the cartesian selection associated with the corrected Pose
116 * @return
117 */
118 static PoseBasePtr
119 optimizePose(armarx::PoseBasePtr original,
120 armarx::PoseBasePtr corrected,
121 VirtualRobot::IKSolver::CartesianSelection selectionOriginal,
122 VirtualRobot::IKSolver::CartesianSelection selectionCorrected);
123 };
124} // namespace armarx
125
126#endif
The InterpolationSegmentFactory class Utility Class used to easily create InterpolationSegments,...
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
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< AbstractInterpolation > AbstractInterpolationPtr