64 double MaximalMinimalExecutionTime = 0.0
65 , VectorStretchFactorMaxAcceleration = 0.0
66 , VectorStretchFactorMaxVelocity = 0.0
67 , PhaseSyncTimeAverage = 0.0;
71 , PhaseSyncDOFCounter = 0;
74 for(i = 0; i < this->NumberOfDOFs; i++)
76 if(this->CurrentInputParameters->SelectionVector->VecData[i])
79 , this->CurrentInputParameters->CurrentVelocityVector->VecData [i]
80 , this->CurrentInputParameters->TargetPositionVector->VecData [i]
81 , this->CurrentInputParameters->TargetVelocityVector->VecData [i]
82 , this->CurrentInputParameters->MaxVelocityVector->VecData [i]
83 , this->CurrentInputParameters->MaxAccelerationVector->VecData [i]
84 , &(this->UsedStep1AProfiles->VecData [i])
85 , &(this->MinimumExecutionTimes->VecData [i]));
87 if((this->MinimumExecutionTimes->VecData)[i] > MaximalMinimalExecutionTime)
89 MaximalMinimalExecutionTime = (this->MinimumExecutionTimes->VecData)[i];
90 this->GreatestDOFForPhaseSynchronization = i;
95 this->SetupModifiedSelectionVector();
98 if (this->CurrentTrajectoryIsNotSynchronized)
100 this->SynchronizationTime = MaximalMinimalExecutionTime;
107 if (this->CurrentTrajectoryIsPhaseSynchronized)
110 this->CurrentTrajectoryIsPhaseSynchronized = IsPhaseSynchronizationPossible(this->PhaseSynchronizationReferenceVector);
113 if ( (this->CurrentTrajectoryIsPhaseSynchronized)
114 && (fabs((this->PhaseSynchronizationReferenceVector->VecData)[this->GreatestDOFForPhaseSynchronization]) >
ABSOLUTE_PHASE_SYNC_EPSILON) )
116 VectorStretchFactorMaxAcceleration = (this->CurrentInputParameters->MaxAccelerationVector->VecData)[this->GreatestDOFForPhaseSynchronization]
117 / fabs((this->PhaseSynchronizationReferenceVector->VecData)[this->GreatestDOFForPhaseSynchronization]);
118 VectorStretchFactorMaxVelocity = (this->CurrentInputParameters->MaxVelocityVector->VecData)[this->GreatestDOFForPhaseSynchronization]
119 / fabs((this->PhaseSynchronizationReferenceVector->VecData)[this->GreatestDOFForPhaseSynchronization]);
121 for(i = 0; i < this->NumberOfDOFs; i++)
123 if((this->ModifiedSelectionVector->VecData)[i])
125 (this->PhaseSynchronizationTimeVector->VecData)[i] = 0.0;
127 (this->PhaseSynchronizationMaxAccelerationVector->VecData)[i] = fabs(VectorStretchFactorMaxAcceleration
128 * (this->PhaseSynchronizationReferenceVector->VecData)[i]);
129 (this->PhaseSynchronizationMaxVelocityVector->VecData)[i] = fabs(VectorStretchFactorMaxVelocity
130 * (this->PhaseSynchronizationReferenceVector->VecData)[i]);
132 if ( ( (this->PhaseSynchronizationMaxAccelerationVector->VecData)[i]
134 || ( (this->PhaseSynchronizationMaxVelocityVector->VecData)[i]
137 this->CurrentTrajectoryIsPhaseSynchronized =
false;
145 this->CurrentTrajectoryIsPhaseSynchronized =
false;
148 if (this->CurrentTrajectoryIsPhaseSynchronized)
150 *(this->PhaseSynchronizationCurrentPositionVector) = *(this->CurrentInputParameters->CurrentPositionVector);
151 *(this->PhaseSynchronizationCurrentVelocityVector) = *(this->CurrentInputParameters->CurrentVelocityVector);
152 *(this->PhaseSynchronizationTargetPositionVector) = *(this->CurrentInputParameters->TargetPositionVector);
153 *(this->PhaseSynchronizationTargetVelocityVector) = *(this->CurrentInputParameters->TargetVelocityVector);
157 for(i = 0; i < this->NumberOfDOFs; i++)
159 if (!
Decision_1A__001(this->PhaseSynchronizationCurrentVelocityVector->VecData[i]))
161 NegateStep1( &(this->PhaseSynchronizationCurrentPositionVector->VecData [i] )
162 , &(this->PhaseSynchronizationCurrentVelocityVector->VecData [i] )
163 , &(this->PhaseSynchronizationTargetPositionVector->VecData [i] )
164 , &(this->PhaseSynchronizationTargetVelocityVector->VecData [i] ) );
166 if (!
Decision_1A__002( this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
167 , this->PhaseSynchronizationMaxVelocityVector->VecData [i] ))
169 VToVMaxStep1( &(this->PhaseSynchronizationTimeVector->VecData [i] )
170 , &(this->PhaseSynchronizationCurrentPositionVector->VecData [i] )
171 , &(this->PhaseSynchronizationCurrentVelocityVector->VecData [i] )
172 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
173 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
181 VToZeroStep1( &(this->PhaseSynchronizationTimeVector->VecData [i] )
182 , &(this->PhaseSynchronizationCurrentPositionVector->VecData [i] )
183 , &(this->PhaseSynchronizationCurrentVelocityVector->VecData [i] )
184 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
186 NegateStep1( &(this->PhaseSynchronizationCurrentPositionVector->VecData [i] )
187 , &(this->PhaseSynchronizationCurrentVelocityVector->VecData [i] )
188 , &(this->PhaseSynchronizationTargetPositionVector->VecData [i] )
189 , &(this->PhaseSynchronizationTargetVelocityVector->VecData [i] ) );
193 switch((this->UsedStep1AProfiles->VecData)[this->GreatestDOFForPhaseSynchronization])
197 for(i = 0; i < this->NumberOfDOFs; i++)
199 if((this->ModifiedSelectionVector->VecData)[i])
202 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
203 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
204 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
205 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
206 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] ))
208 this->CurrentTrajectoryIsPhaseSynchronized =
false;
216 for(i = 0; i < this->NumberOfDOFs; i++)
218 if((this->ModifiedSelectionVector->VecData)[i])
221 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
222 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
223 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
224 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
225 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] ))
227 this->CurrentTrajectoryIsPhaseSynchronized =
false;
235 for(i = 0; i < this->NumberOfDOFs; i++)
237 if((this->ModifiedSelectionVector->VecData)[i])
240 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
241 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
242 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
243 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
244 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] ))
246 this->CurrentTrajectoryIsPhaseSynchronized =
false;
254 for(i = 0; i < this->NumberOfDOFs; i++)
256 if((this->ModifiedSelectionVector->VecData)[i])
259 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
260 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
261 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
262 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
263 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] ))
265 this->CurrentTrajectoryIsPhaseSynchronized =
false;
272 this->CurrentTrajectoryIsPhaseSynchronized =
false;
277 if (this->CurrentTrajectoryIsPhaseSynchronized)
279 this->MotionProfileForPhaseSynchronization = (
unsigned int)(this->UsedStep1AProfiles->VecData)[this->GreatestDOFForPhaseSynchronization];
287 switch(this->MotionProfileForPhaseSynchronization)
291 for(i = 0; i < this->NumberOfDOFs; i++)
293 if((this->ModifiedSelectionVector->VecData)[i])
295 this->PhaseSynchronizationTimeVector->VecData[i]
297 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
298 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
299 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
300 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
301 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
307 for(i = 0; i < this->NumberOfDOFs; i++)
309 if((this->ModifiedSelectionVector->VecData)[i])
311 this->PhaseSynchronizationTimeVector->VecData[i]
313 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
314 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
315 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
316 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
322 for(i = 0; i < this->NumberOfDOFs; i++)
324 if((this->ModifiedSelectionVector->VecData)[i])
326 this->PhaseSynchronizationTimeVector->VecData[i]
328 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
329 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
330 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
331 , this->PhaseSynchronizationMaxVelocityVector->VecData [i]
332 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
338 for(i = 0; i < this->NumberOfDOFs; i++)
340 if((this->ModifiedSelectionVector->VecData)[i])
342 this->PhaseSynchronizationTimeVector->VecData[i]
344 , this->PhaseSynchronizationCurrentVelocityVector->VecData [i]
345 , this->PhaseSynchronizationTargetPositionVector->VecData [i]
346 , this->PhaseSynchronizationTargetVelocityVector->VecData [i]
347 , this->PhaseSynchronizationMaxAccelerationVector->VecData [i] );
352 this->CurrentTrajectoryIsPhaseSynchronized =
false;
356 PhaseSyncTimeAverage = 0.0;
357 PhaseSyncDOFCounter = 0;
359 for(i = 0; i < this->NumberOfDOFs; i++)
361 if((this->ModifiedSelectionVector->VecData)[i])
363 PhaseSyncTimeAverage += (this->PhaseSynchronizationTimeVector->VecData)[i];
364 PhaseSyncDOFCounter++;
368 if (PhaseSyncDOFCounter == 0)
373 PhaseSyncTimeAverage /= ((double)PhaseSyncDOFCounter);
375 for(i = 0; i < this->NumberOfDOFs; i++)
377 if ((this->ModifiedSelectionVector->VecData)[i])
379 if ( fabs((this->PhaseSynchronizationTimeVector->VecData)[i] - PhaseSyncTimeAverage)
382 this->CurrentTrajectoryIsPhaseSynchronized =
false;
389 if (this->CurrentTrajectoryIsPhaseSynchronized)
391 this->SynchronizationTime = this->MinimumExecutionTimes->VecData[this->GreatestDOFForPhaseSynchronization];
398 for(i = 0; i < this->NumberOfDOFs; i++)
400 if ((this->ModifiedSelectionVector->VecData)[i])
403 , this->CurrentInputParameters->CurrentVelocityVector->VecData [i]
404 , this->CurrentInputParameters->TargetPositionVector->VecData [i]
405 , this->CurrentInputParameters->TargetVelocityVector->VecData [i]
406 , this->CurrentInputParameters->MaxVelocityVector->VecData [i]
407 , this->CurrentInputParameters->MaxAccelerationVector->VecData [i]
408 , &(this->BeginningsOfInoperativeTimeIntervals->VecData [i]));
410 if (this->BeginningsOfInoperativeTimeIntervals->VecData[i] !=
RML_INFINITY)
413 , this->CurrentInputParameters->CurrentVelocityVector->VecData [i]
414 , this->CurrentInputParameters->TargetPositionVector->VecData [i]
415 , this->CurrentInputParameters->TargetVelocityVector->VecData [i]
416 , this->CurrentInputParameters->MaxVelocityVector->VecData [i]
417 , this->CurrentInputParameters->MaxAccelerationVector->VecData [i]
418 , &(this->EndingsOfInoperativeTimeIntervals->VecData [i]));
422 this->EndingsOfInoperativeTimeIntervals->VecData[i] =
RML_INFINITY;
427 this->BeginningsOfInoperativeTimeIntervals->VecData [i] =
RML_INFINITY;
428 this->EndingsOfInoperativeTimeIntervals->VecData [i] =
RML_INFINITY;
432 for(i = 0; i < this->NumberOfDOFs; i++)
434 if((this->ModifiedSelectionVector->VecData)[i])
436 if ( (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] < (this->MinimumExecutionTimes->VecData)[i] )
438 (this->BeginningsOfInoperativeTimeIntervals->VecData)[i]
439 = (this->MinimumExecutionTimes->VecData)[i];
442 if ( (this->EndingsOfInoperativeTimeIntervals->VecData)[i] < (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] )
444 (this->EndingsOfInoperativeTimeIntervals->VecData)[i]
445 = (this->BeginningsOfInoperativeTimeIntervals->VecData)[i]
446 = ((this->BeginningsOfInoperativeTimeIntervals->VecData)[i]
447 + (this->EndingsOfInoperativeTimeIntervals->VecData)[i]) * 0.5;
449 if ( (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] < (this->MinimumExecutionTimes->VecData)[i] )
451 (this->MinimumExecutionTimes->VecData)[i]
452 = (this->EndingsOfInoperativeTimeIntervals->VecData)[i];
453 (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
454 (this->EndingsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
458 if ( (this->EndingsOfInoperativeTimeIntervals->VecData)[i] < (this->MinimumExecutionTimes->VecData)[i] )
460 (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
461 (this->EndingsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
471 for(i = 0; i < this->NumberOfDOFs; i++)
473 if(!(this->ModifiedSelectionVector->VecData)[i])
475 (this->BeginningsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
476 (this->EndingsOfInoperativeTimeIntervals->VecData)[i] =
RML_INFINITY;
479 (this->ArrayOfSortedTimes->VecData)[i]
480 = (this->BeginningsOfInoperativeTimeIntervals->VecData)[i];
482 (this->ArrayOfSortedTimes->VecData)[i + this->NumberOfDOFs]
483 = (this->EndingsOfInoperativeTimeIntervals->VecData)[i];
490 Quicksort(0, (2 * this->NumberOfDOFs - 1), &((this->ArrayOfSortedTimes->VecData)[0]));
493 for (Counter = 0; Counter < 2 * this->NumberOfDOFs; Counter++)
495 if ((this->ArrayOfSortedTimes->VecData)[Counter] > MaximalMinimalExecutionTime)
501 this->SynchronizationTime = MaximalMinimalExecutionTime;
504 while((IsWithinAnInoperativeTimeInterval( this->SynchronizationTime
505 , *(this->BeginningsOfInoperativeTimeIntervals)
506 , *(this->EndingsOfInoperativeTimeIntervals) ) )
507 && (Counter < 2 * this->NumberOfDOFs) )
509 this->SynchronizationTime = (this->ArrayOfSortedTimes->VecData)[Counter];
526 for (i = 0; i < this->NumberOfDOFs; i++)
528 if ((this->ModifiedSelectionVector->VecData)[i])
530 if ( ((MaximalExecutionTime.
VecData)[i] < SynchronizationTimeCandidate)
531 && (SynchronizationTimeCandidate < (AlternativeExecutionTime.
VecData)[i]) )
#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)
void VToVMaxStep1(double *TotalTime, double *ThisCurrentPosition, double *ThisCurrentVelocity, const double &MaxVelocity, const double &MaxAcceleration)
One intermediate Step 1 trajectory segment: v -> +vmax (NegLin)
The profile is NegLinHldPosLin.
double ProfileStep1PosTriNegLin(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxAcceleration)
Calculates the execution time of the PosTriNegLin velocity profile.
void TypeIIRMLDecisionTree1A(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration, Step1_Profile *AppliedProfile, double *MinimalExecutionTime)
This function contains the decision tree 1A of the Step 1 of the Type II On-Line Trajectory Generatio...
T * VecData
Pointer to the actual vector data, that is, an array of type T objects.
The profile is NegLinPosLin.
Header file for decisions of the two decision trees of the Type II On-Line Trajectory Generation algo...
Header file for the Quicksort algorithm.
bool IsSolutionForProfile_PosLinNegLin_Possible(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Checks whether a valid solution for the PosLinNegLin velocity profile would be possible.
void NegateStep1(double *ThisCurrentPosition, double *ThisCurrentVelocity, double *ThisTargetPosition, double *ThisTargetVelocity)
Negate input values during Step 1.
Header file for functions and definitions of constant values and macros.
void TypeIIRMLDecisionTree1B(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration, double *MaximalExecutionTime)
This function contains the decision tree 1B of the Step 1 of the Type II On-Line Trajectory Generatio...
#define RML_INFINITY
A value for infinity .
double ProfileStep1PosLinHldNegLin(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Calculates the execution time of the PosLinHldNegLin velocity profile.
bool IsSolutionForProfile_PosTriNegLin_Possible(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Checks whether a valid solution for the PosTriNegLin velocity profile would be possible.
Header file for the class TypeIIRMLPosition, which constitutes the actual interface of the Type II Re...
Header file for the Step 1 decision tree 1C of the Type II On-Line Trajectory Generation algorithm...
The profile is PosLinNegLin.
The profile is PosTrapNegLin.
void VToZeroStep1(double *TotalTime, double *ThisCurrentPosition, double *ThisCurrentVelocity, const double &MaxAcceleration)
One intermediate Step 1 trajectory segment: v -> 0 (NegLin)
double ProfileStep1PosTrapNegLin(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Calculates the execution time of the PosTrapNegLin velocity profile.
Header file for the Step 1 decision tree 1B of the Type II On-Line Trajectory Generation algorithm...
bool Decision_1A__002(const double &CurrentVelocity, const double &MaxVelocity)
Is (vi <= +vmax)?
The profile is PosTriNegLin.
bool IsSolutionForProfile_PosLinHldNegLin_Possible(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Checks whether a valid solution for the PosLinHldNegLin velocity profile would be possible...
The profile is NegTriPosLin.
The profile is PosLinHldNegLin.
Header file for the Step 1 decision tree 1A of the Type II On-Line Trajectory Generation algorithm...
The profile is NegTrapPosLin.
Header file for the Step 1 motion profiles.
bool IsSolutionForProfile_PosTrapNegLin_Possible(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration)
Checks whether a valid solution for the PosTrapNegLin velocity profile would be possible.
#define RELATIVE_PHASE_SYNC_EPSILON
Relative epsilon to check whether all required vectors are collinear.
void TypeIIRMLDecisionTree1C(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxVelocity, const double &MaxAcceleration, double *AlternativeExecutionTime)
This function contains the decision tree 1C of the Step 1 of the Type II On-Line Trajectory Generatio...
double ProfileStep1PosLinNegLin(const double &CurrentPosition, const double &CurrentVelocity, const double &TargetPosition, const double &TargetVelocity, const double &MaxAcceleration)
Calculates the execution time of the PosLinNegLin velocity profile.
bool Decision_1A__001(const double &CurrentVelocity)
Is (vi >= 0)?
bool IsWithinAnInoperativeTimeInterval(const double &SynchronizationTimeCandidate, const RMLDoubleVector &MaximalExecutionTime, const RMLDoubleVector &AlternativeExecutionTime) const
Checks, whether the value SynchronizationTimeCandidate lies within an inoperative timer interval...
This is a minimalistic dynamic vector class implementation used for the Reflexxes Motion Libraries...
void Step1(void)
Step 1 of the On-Line Trajectory Generation algorithm: Calculate the synchronization time ...
void Quicksort(const int &LeftBound, const int &RightBound, double *ArrayOfValues)
Standard implementation of the Quicksort algorithm for double values.