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 "AbstractInterpolation.h"
26 #include "InterpolationType.h"
27 #include <VirtualRobot/IK/AdvancedIKSolver.h>
28 
29 namespace armarx
30 {
31  /**
32  * @brief The InterpolationSegmentFactory class
33  * Utility Class used to easily create InterpolationSegments, so that every Interpolation can be threated the same
34  * An Interpolation produced by this factory always has exactly two Waypoints and is defined between 0 and 1
35  * With 0 being the starting pose and 1 being the end pose
36  */
38  {
39  public:
40  /**
41  * @brief produceInterpolationSegments constructs a vector of AbstractInterpolation the concrete Interpolationtype of which is defined by interpolations
42  * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
43  * @param interpolations the InterpolationTypes of the Interpolation segments (warning: at least 2 segments in a row have to have spline intepolation)
44  * @return a vector of |controlPoints| - 1 AbstractInterpolations between the control points
45  */
46  static std::vector<AbstractInterpolationPtr> produceInterpolationSegments(std::vector<PoseBasePtr> controlPoints, std::vector<InterpolationType> interpolations);
47 
48  /**
49  * @brief produceInterpolationSegments constructs a vector of LinearInterpolations
50  * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
51  * @return a vector of |controlPoints| - 1 LinearInterpolations between the control points
52  */
53  static std::vector<AbstractInterpolationPtr> produceLinearInterpolationSegments(std::vector<PoseBasePtr> controlPoints);
54 
55  /**
56  * @brief produceInterpolationSegments constructs a vector of SplineInterpolations
57  * @param controlPoints the Poses the interpolation curves go through; segment i starts at controlPoint i and ends at control point i + 1
58  * @return a vector of |controlPoints| - 1 SplineInterpolations between the control points
59  */
60  static std::vector<AbstractInterpolationPtr> produceSplineInterpolationSegments(std::vector<PoseBasePtr> controlPoints);
61 
62  /**
63  * @brief produceSplineInterpolationSegment constructs the splineInterpolationSegment of a splineInterpolation between given controlPoints
64  * @param controlPoints the controlPoints of the parent SplineInterpolatiom
65  * @param segmentStart the first Point in the Interval
66  * @return a SplineInterpolationSegment between segmentStart and the following control point
67  */
68  static AbstractInterpolationPtr produceSplineInterpolationSegment(std::vector<PoseBasePtr> controlPoints, PoseBasePtr segmentStart);
69 
70  /**
71  * @brief optimizeControlPoints changes the cartian selections and control points so that the IKSolving produces a smooth Trajectory
72  * @param controlPoints the controlPoints to change to make the Trajectory smooth
73  * @param selections the cartesian selections to optimize
74  */
75  static void optimizeControlPoints(std::vector<PoseBasePtr>& controlPoints, std::vector<VirtualRobot::IKSolver::CartesianSelection>& selections);
76  /**
77  * @brief needsOptimizing returns true if there is a CartesianSelection at i that dominates a CartesianSelection at i - 1
78  * @param selections the cartesian selection that should be reached
79  * @return true if the cartesian Selection need optimizing for a smooth trajectory
80  */
81  static bool needsOptimizing(std::vector<VirtualRobot::IKSolver::CartesianSelection>& selections);
82  /**
83  * @brief isDominantOver returns true when current selection dominates other selection
84  * Definition: A CartesianSelection dominates another CartesianSelection when additional Information is needed to solve curren after solving other
85  * 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
86  * @param current the later cartesian selection
87  * @param other the prior cartesian selection
88  * @return true if current dominates other
89  */
91  /**
92  * @brief getSmallestDominating returns the cartesian selection that dominates all other cartesian selections in selections
93  * Examples: (X,Y,Y,Y,Z) -> Pos ; (X,Y, Ori) -> All; (Ori,Ori) -> Ori ; (X,Z,Pos) -> Pos
94  * @param selections the selections to get the smallest dominating selection from
95  * @return the smmallestDominating Selection
96  */
97  static VirtualRobot::IKSolver::CartesianSelection getSmallestDominating(std::vector<VirtualRobot::IKSolver::CartesianSelection> selections);
98  /**
99  * @brief optimizePose changes the original pose so that the interpolation is smove when it changes from selectionOriginal to selectionCorrected
100  * @param original the original Pose
101  * @param corrected the absolute corrected Pose
102  * @param selectionOriginal the cartesian selection associated with the original Pose
103  * @param selectionCorrected the cartesian selection associated with the corrected Pose
104  * @return
105  */
106  static PoseBasePtr optimizePose(armarx::PoseBasePtr original, armarx::PoseBasePtr corrected, VirtualRobot::IKSolver::CartesianSelection selectionOriginal, VirtualRobot::IKSolver::CartesianSelection selectionCorrected);
107  };
108 }
109 
110 #endif
armarx::InterpolationSegmentFactory::optimizePose
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...
Definition: InterpolationSegmentFactory.cpp:347
armarx::InterpolationSegmentFactory::needsOptimizing
static bool needsOptimizing(std::vector< VirtualRobot::IKSolver::CartesianSelection > &selections)
needsOptimizing returns true if there is a CartesianSelection at i that dominates a CartesianSelectio...
Definition: InterpolationSegmentFactory.cpp:278
AbstractInterpolation.h
armarx::AbstractInterpolationPtr
std::shared_ptr< AbstractInterpolation > AbstractInterpolationPtr
Definition: AbstractInterpolation.h:77
armarx::InterpolationSegmentFactory::isDominantOver
static bool isDominantOver(VirtualRobot::IKSolver::CartesianSelection current, VirtualRobot::IKSolver::CartesianSelection other)
isDominantOver returns true when current selection dominates other selection Definition: A CartesianS...
Definition: InterpolationSegmentFactory.cpp:291
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
armarx::InterpolationSegmentFactory::produceLinearInterpolationSegments
static std::vector< AbstractInterpolationPtr > produceLinearInterpolationSegments(std::vector< PoseBasePtr > controlPoints)
produceInterpolationSegments constructs a vector of LinearInterpolations
Definition: InterpolationSegmentFactory.cpp:151
armarx::InterpolationSegmentFactory::produceSplineInterpolationSegment
static AbstractInterpolationPtr produceSplineInterpolationSegment(std::vector< PoseBasePtr > controlPoints, PoseBasePtr segmentStart)
produceSplineInterpolationSegment constructs the splineInterpolationSegment of a splineInterpolation ...
Definition: InterpolationSegmentFactory.cpp:178
armarx::InterpolationSegmentFactory::optimizeControlPoints
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...
Definition: InterpolationSegmentFactory.cpp:191
armarx::InterpolationSegmentFactory::produceInterpolationSegments
static std::vector< AbstractInterpolationPtr > produceInterpolationSegments(std::vector< PoseBasePtr > controlPoints, std::vector< InterpolationType > interpolations)
produceInterpolationSegments constructs a vector of AbstractInterpolation the concrete Interpolationt...
Definition: InterpolationSegmentFactory.cpp:36
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::InterpolationSegmentFactory::getSmallestDominating
static VirtualRobot::IKSolver::CartesianSelection getSmallestDominating(std::vector< VirtualRobot::IKSolver::CartesianSelection > selections)
getSmallestDominating returns the cartesian selection that dominates all other cartesian selections i...
Definition: InterpolationSegmentFactory.cpp:304
armarx::InterpolationSegmentFactory::produceSplineInterpolationSegments
static std::vector< AbstractInterpolationPtr > produceSplineInterpolationSegments(std::vector< PoseBasePtr > controlPoints)
produceInterpolationSegments constructs a vector of SplineInterpolations
Definition: InterpolationSegmentFactory.cpp:165
armarx::InterpolationSegmentFactory
The InterpolationSegmentFactory class Utility Class used to easily create InterpolationSegments,...
Definition: InterpolationSegmentFactory.h:37
InterpolationType.h