69 double LengthOfCurrentVelocityVector = 0.0
70 , LengthOfTargetVelocityVector = 0.0
71 , LengthOfReferenceVector = 0.0;
73 for (i = 0; i < this->NumberOfDOFs; i++)
75 if ((this->PhaseSyncSelectionVector->VecData)[i])
77 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]
78 = (this->CurrentInputParameters->CurrentVelocityVector->VecData)[i];
79 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i]
80 = (this->CurrentInputParameters->TargetVelocityVector->VecData)[i];
82 LengthOfCurrentVelocityVector +=
pow2((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]);
83 LengthOfTargetVelocityVector +=
pow2((this->PhaseSynchronizationTargetVelocityVector->VecData)[i]);
87 (this->PhaseSynchronizationCurrentVelocityVector->VecData) [i] = 0.0;
88 (this->PhaseSynchronizationTargetVelocityVector->VecData) [i] = 0.0;
92 LengthOfCurrentVelocityVector =
RMLSqrt(LengthOfCurrentVelocityVector);
93 LengthOfTargetVelocityVector =
RMLSqrt(LengthOfTargetVelocityVector);
95 if ( (LengthOfCurrentVelocityVector !=
POSITIVE_ZERO) && (LengthOfCurrentVelocityVector != 0.0) )
97 for (i = 0; i < this->NumberOfDOFs; i++)
99 if ((this->PhaseSyncSelectionVector->VecData)[i])
101 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i] /= LengthOfCurrentVelocityVector;
107 for (i = 0; i < this->NumberOfDOFs; i++)
109 if ((this->PhaseSyncSelectionVector->VecData)[i])
111 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i] = 0.0;
116 if ( (LengthOfTargetVelocityVector !=
POSITIVE_ZERO) && (LengthOfTargetVelocityVector != 0.0) )
118 for (i = 0; i < this->NumberOfDOFs; i++)
120 if ((this->PhaseSyncSelectionVector->VecData)[i])
122 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i] /= LengthOfTargetVelocityVector;
128 for (i = 0; i < this->NumberOfDOFs; i++)
130 if ((this->PhaseSyncSelectionVector->VecData)[i])
132 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i] = 0.0;
141 if ( ( LengthOfCurrentVelocityVector >= LengthOfTargetVelocityVector )
144 *(this->PhaseSynchronizationReferenceVector) = *(this->PhaseSynchronizationCurrentVelocityVector);
145 LengthOfReferenceVector = LengthOfCurrentVelocityVector;
148 if ( ( LengthOfTargetVelocityVector >= LengthOfCurrentVelocityVector )
151 *(this->PhaseSynchronizationReferenceVector) = *(this->PhaseSynchronizationTargetVelocityVector);
152 LengthOfReferenceVector = LengthOfTargetVelocityVector;
161 for (i = 0; i < this->NumberOfDOFs; i++)
163 if ((this->PhaseSyncSelectionVector->VecData)[i])
165 if ((
Sign((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
166 ==
Sign((this->PhaseSynchronizationReferenceVector->VecData)[i]))
167 && (fabs((this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
178 for (i = 0; i < this->NumberOfDOFs; i++)
180 if ((this->PhaseSyncSelectionVector->VecData)[i])
182 (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i]
183 = -(this->PhaseSynchronizationCurrentVelocityVector->VecData)[i];
190 for (i = 0; i < this->NumberOfDOFs; i++)
192 if ((this->PhaseSyncSelectionVector->VecData)[i])
194 if ((
Sign((this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
195 ==
Sign((this->PhaseSynchronizationReferenceVector->VecData)[i]))
196 && (fabs((this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
207 for (i = 0; i < this->NumberOfDOFs; i++)
209 if ((this->PhaseSyncSelectionVector->VecData)[i])
211 (this->PhaseSynchronizationTargetVelocityVector->VecData)[i]
212 = -(this->PhaseSynchronizationTargetVelocityVector->VecData)[i];
220 for (i = 0; i < this->NumberOfDOFs; i++)
222 if ( (this->PhaseSyncSelectionVector->VecData)[i] )
224 if ( ((fabs((this->PhaseSynchronizationReferenceVector->VecData)[i] - (this->PhaseSynchronizationCurrentVelocityVector->VecData)[i])
227 || ((fabs((this->PhaseSynchronizationReferenceVector->VecData)[i] - (this->PhaseSynchronizationTargetVelocityVector->VecData)[i])
244 this->PhaseSynchronizationReferenceVector->Set(0.0);
Header file for the dynamic vector class used for the Reflexxes Motion Libraries. ...
#define ABSOLUTE_PHASE_SYNC_EPSILON
Absolute epsilon to check whether all required vectors are collinear.
Header file for the class ReflexxesAPI (API of the Reflexxes Motion Libraries)
Header file for the class TypeIIRMLVelocity.
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 RMLVelocityFlags.
bool IsPhaseSynchronizationPossible(void)
Checks, whether the motion trajectory can be phase-synchronized.
Header file for the class RMLVelocityOutputParameters.
#define pow2(A)
A to the power of 2.
#define Sign(A)
Sign macro (integer)
#define POSITIVE_ZERO
To prevent from numerical errors, a value for a "positive" value of zero is required for deterministi...