63 double LengthOfDirectionVector = 0.0
64 , LengthOfCurrentVelocityVector = 0.0
65 , LengthOfTargetVelocityVector = 0.0
66 , LengthOfReferenceVector = 0.0;
69 for (i = 0; i < this->NumberOfDOFs; i++)
71 if ((this->ModifiedSelectionVector->VecData)[i])
73 (this->PhaseSynchronizationPositionDifferenceVector->VecData)[i]
74 = (this->CurrentInputParameters->TargetPositionVector->VecData)[i]
75 - (this->CurrentInputParameters->CurrentPositionVector->VecData)[i];
76 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]
77 = (this->CurrentInputParameters->CurrentVelocityVector->VecData)[i];
78 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i]
79 = (this->CurrentInputParameters->TargetVelocityVector->VecData)[i];
81 LengthOfDirectionVector +=
pow2((this->PhaseSynchronizationPositionDifferenceVector->VecData)[i]);
82 LengthOfCurrentVelocityVector +=
pow2((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]);
83 LengthOfTargetVelocityVector +=
pow2((this->PhaseSynchronizationTargetVelocityVector->VecData)[i]);
87 (this->PhaseSynchronizationPositionDifferenceVector->VecData) [i] = 0.0;
88 (this->PhaseSynchronizationCurrentVelocityVector->VecData) [i] = 0.0;
89 (this->PhaseSynchronizationTargetVelocityVector->VecData) [i] = 0.0;
93 LengthOfDirectionVector =
RMLSqrt(LengthOfDirectionVector);
94 LengthOfCurrentVelocityVector =
RMLSqrt(LengthOfCurrentVelocityVector);
95 LengthOfTargetVelocityVector =
RMLSqrt(LengthOfTargetVelocityVector);
98 if ( (LengthOfDirectionVector !=
POSITIVE_ZERO) && (LengthOfDirectionVector != 0.0) )
100 for (i = 0; i < this->NumberOfDOFs; i++)
102 if ((this->ModifiedSelectionVector->VecData)[i])
104 (this->PhaseSynchronizationPositionDifferenceVector->VecData)[i] /= LengthOfDirectionVector;
110 for (i = 0; i < this->NumberOfDOFs; i++)
112 if ((this->ModifiedSelectionVector->VecData)[i])
114 (this->PhaseSynchronizationPositionDifferenceVector->VecData)[i] = 0.0;
119 if ( (LengthOfCurrentVelocityVector !=
POSITIVE_ZERO) && (LengthOfCurrentVelocityVector != 0.0) )
121 for (i = 0; i < this->NumberOfDOFs; i++)
123 if ((this->ModifiedSelectionVector->VecData)[i])
125 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i] /= LengthOfCurrentVelocityVector;
131 for (i = 0; i < this->NumberOfDOFs; i++)
133 if ((this->ModifiedSelectionVector->VecData)[i])
135 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i] = 0.0;
140 if ( (LengthOfTargetVelocityVector !=
POSITIVE_ZERO) && (LengthOfTargetVelocityVector != 0.0) )
142 for (i = 0; i < this->NumberOfDOFs; i++)
144 if ((this->ModifiedSelectionVector->VecData)[i])
146 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i] /= LengthOfTargetVelocityVector;
152 for (i = 0; i < this->NumberOfDOFs; i++)
154 if ((this->ModifiedSelectionVector->VecData)[i])
156 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i] = 0.0;
165 if ( ( LengthOfDirectionVector >= LengthOfCurrentVelocityVector )
166 && ( LengthOfDirectionVector >= LengthOfTargetVelocityVector )
169 *(this->PhaseSynchronizationCheckVector) = *(this->PhaseSynchronizationPositionDifferenceVector);
170 LengthOfReferenceVector = LengthOfDirectionVector;
174 if ( ( LengthOfCurrentVelocityVector >= LengthOfDirectionVector )
175 && ( LengthOfCurrentVelocityVector >= LengthOfTargetVelocityVector )
178 *(this->PhaseSynchronizationCheckVector) = *(this->PhaseSynchronizationCurrentVelocityVector);
179 LengthOfReferenceVector = LengthOfCurrentVelocityVector;
183 if ( ( LengthOfTargetVelocityVector >= LengthOfDirectionVector )
184 && ( LengthOfTargetVelocityVector >= LengthOfCurrentVelocityVector )
187 *(this->PhaseSynchronizationCheckVector) = *(this->PhaseSynchronizationTargetVelocityVector);
188 LengthOfReferenceVector = LengthOfTargetVelocityVector;
198 for (i = 0; i < this->NumberOfDOFs; i++)
200 if ((this->ModifiedSelectionVector->VecData)[i])
202 if ((
Sign((this->PhaseSynchronizationPositionDifferenceVector->VecData)[i])
203 ==
Sign((this->PhaseSynchronizationCheckVector->VecData)[i]))
204 && (fabs((this->PhaseSynchronizationPositionDifferenceVector->VecData)[i])
215 for (i = 0; i < this->NumberOfDOFs; i++)
217 if ((this->ModifiedSelectionVector->VecData)[i])
219 (this->PhaseSynchronizationPositionDifferenceVector->VecData)[i]
220 = -(this->PhaseSynchronizationPositionDifferenceVector->VecData)[i];
227 for (i = 0; i < this->NumberOfDOFs; i++)
229 if ((this->ModifiedSelectionVector->VecData)[i])
231 if ((
Sign((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
232 ==
Sign((this->PhaseSynchronizationCheckVector->VecData)[i]))
233 && (fabs((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
244 for (i = 0; i < this->NumberOfDOFs; i++)
246 if ((this->ModifiedSelectionVector->VecData)[i])
248 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]
249 = -(this->PhaseSynchronizationCurrentVelocityVector->VecData)[i];
256 for (i = 0; i < this->NumberOfDOFs; i++)
258 if ((this->ModifiedSelectionVector->VecData)[i])
260 if ((
Sign((this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
261 ==
Sign((this->PhaseSynchronizationCheckVector->VecData)[i]))
262 && (fabs((this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
273 for (i = 0; i < this->NumberOfDOFs; i++)
275 if ((this->ModifiedSelectionVector->VecData)[i])
277 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i]
278 = -(this->PhaseSynchronizationTargetVelocityVector->VecData)[i];
285 for (i = 0; i < this->NumberOfDOFs; i++)
287 if ( (this->ModifiedSelectionVector->VecData)[i] )
289 if ( ((fabs((this->PhaseSynchronizationCheckVector->VecData)[i] - (this->PhaseSynchronizationPositionDifferenceVector->VecData)[i])
292 || ((fabs((this->PhaseSynchronizationCheckVector->VecData)[i] - (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
295 || ((fabs((this->PhaseSynchronizationCheckVector->VecData)[i] - (this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
312 *ReferenceVector = *(this->PhaseSynchronizationCheckVector);
316 ReferenceVector->
Set(0.0);
#define ABSOLUTE_PHASE_SYNC_EPSILON
Absolute epsilon to check whether all required vectors are collinear.
The current acceleration vector was to the dominant value to determine the reference vector for a p...
void Set(const T Value)
Sets all elements of a vector of double elements to one specific value.
Header file for functions and definitions of constant values and macros.
double RMLSqrt(const double &Value)
Calculates the real square root of a given value. If the value is negative a value of almost zero wil...
Header file for the class TypeIIRMLPosition, which constitutes the actual interface of the Type II Re...
#define pow2(A)
A to the power of 2.
The target velocity vector was to the dominant value to determine the reference vector for a phase-...
The position difference vector was to the dominant value to determine the reference vector for a ph...
Header file for the Step 1 motion profiles.
bool IsPhaseSynchronizationPossible(RMLDoubleVector *ReferenceVector)
Checks, whether the motion trajectory can be phase-synchronized.
#define PHASE_SYNC_COLLINEARITY_REL_EPSILON
Relative value to check for collinearity during the check for phase synchronization.
#define Sign(A)
Sign macro (integer)
This is a minimalistic dynamic vector class implementation used for the Reflexxes Motion Libraries...
#define POSITIVE_ZERO
To prevent from numerical errors, a value for a "positive" value of zero is required for deterministi...