60 ,
const double &CycleTimeInSeconds)
62 this->CurrentTrajectoryIsPhaseSynchronized = false ;
63 this->CurrentTrajectoryIsNotSynchronized = false ;
64 this->CalculatePositionalExtremsFlag = false ;
68 this->NumberOfDOFs = DegreesOfFreedom ;
69 this->GreatestDOFForPhaseSynchronization = 0 ;
72 this->CycleTime = CycleTimeInSeconds ;
73 this->SynchronizationTime = 0.0 ;
74 this->InternalClockInSeconds = 0.0 ;
78 this->ModifiedSelectionVector =
new RMLBoolVector (this->NumberOfDOFs);
84 this->BeginningsOfInoperativeTimeIntervals =
new RMLDoubleVector (this->NumberOfDOFs);
85 this->EndingsOfInoperativeTimeIntervals =
new RMLDoubleVector (this->NumberOfDOFs);
86 this->PhaseSynchronizationReferenceVector =
new RMLDoubleVector (this->NumberOfDOFs);
87 this->PhaseSynchronizationCurrentPositionVector =
new RMLDoubleVector (this->NumberOfDOFs);
88 this->PhaseSynchronizationTargetPositionVector =
new RMLDoubleVector (this->NumberOfDOFs);
89 this->PhaseSynchronizationPositionDifferenceVector =
new RMLDoubleVector (this->NumberOfDOFs);
90 this->PhaseSynchronizationCurrentVelocityVector =
new RMLDoubleVector (this->NumberOfDOFs);
91 this->PhaseSynchronizationTargetVelocityVector =
new RMLDoubleVector (this->NumberOfDOFs);
92 this->PhaseSynchronizationMaxVelocityVector =
new RMLDoubleVector (this->NumberOfDOFs);
93 this->PhaseSynchronizationMaxAccelerationVector =
new RMLDoubleVector (this->NumberOfDOFs);
94 this->PhaseSynchronizationTimeVector =
new RMLDoubleVector (this->NumberOfDOFs);
95 this->PhaseSynchronizationCheckVector =
new RMLDoubleVector (this->NumberOfDOFs);
97 this->ArrayOfSortedTimes =
new RMLDoubleVector (2 * this->NumberOfDOFs);
110 , this->CycleTime ) ;
114 this->ZeroVector->Set(0.0);
123 delete this->OldInputParameters ;
124 delete this->CurrentInputParameters ;
125 delete this->OutputParameters ;
126 delete this->RMLVelocityObject ;
127 delete this->ModifiedSelectionVector ;
128 delete this->UsedStep1AProfiles ;
129 delete this->StoredTargetPosition ;
130 delete this->MinimumExecutionTimes ;
131 delete this->BeginningsOfInoperativeTimeIntervals ;
132 delete this->EndingsOfInoperativeTimeIntervals ;
133 delete this->PhaseSynchronizationReferenceVector ;
134 delete this->PhaseSynchronizationPositionDifferenceVector ;
135 delete this->PhaseSynchronizationCurrentPositionVector ;
136 delete this->PhaseSynchronizationTargetPositionVector ;
137 delete this->PhaseSynchronizationCurrentVelocityVector ;
138 delete this->PhaseSynchronizationTargetVelocityVector ;
139 delete this->PhaseSynchronizationMaxVelocityVector ;
140 delete this->PhaseSynchronizationMaxAccelerationVector ;
141 delete this->PhaseSynchronizationTimeVector ;
142 delete this->PhaseSynchronizationCheckVector ;
143 delete this->ArrayOfSortedTimes ;
144 delete this->ZeroVector ;
145 delete this->VelocityInputParameters ;
146 delete this->VelocityOutputParameters ;
150 this->OldInputParameters = NULL ;
151 this->CurrentInputParameters = NULL ;
152 this->OutputParameters = NULL ;
153 this->RMLVelocityObject = NULL ;
154 this->ModifiedSelectionVector = NULL ;
155 this->UsedStep1AProfiles = NULL ;
156 this->StoredTargetPosition = NULL ;
157 this->MinimumExecutionTimes = NULL ;
158 this->BeginningsOfInoperativeTimeIntervals = NULL ;
159 this->EndingsOfInoperativeTimeIntervals = NULL ;
160 this->PhaseSynchronizationReferenceVector = NULL ;
161 this->PhaseSynchronizationCurrentPositionVector = NULL ;
162 this->PhaseSynchronizationTargetPositionVector = NULL ;
163 this->PhaseSynchronizationPositionDifferenceVector = NULL ;
164 this->PhaseSynchronizationCurrentVelocityVector = NULL ;
165 this->PhaseSynchronizationTargetVelocityVector = NULL ;
166 this->PhaseSynchronizationMaxVelocityVector = NULL ;
167 this->PhaseSynchronizationMaxAccelerationVector = NULL ;
168 this->PhaseSynchronizationTimeVector = NULL ;
169 this->PhaseSynchronizationCheckVector = NULL ;
170 this->ArrayOfSortedTimes = NULL ;
171 this->ZeroVector = NULL ;
172 this->VelocityInputParameters = NULL ;
173 this->VelocityOutputParameters = NULL ;
175 this->Polynomials = NULL ;
186 bool StartANewCalculation =
false;
190 if ( (OutputValues == NULL)
191 || (&InputValues == NULL)
192 || (&Flags == NULL) )
195 return(this->ReturnValue);
201 FallBackStrategy( InputValues
202 , this->OutputParameters
205 *OutputValues = *(this->OutputParameters);
207 return(this->ReturnValue);
210 *(this->CurrentInputParameters) = InputValues;
217 StartANewCalculation =
true;
221 StartANewCalculation =
false;
226 if (Flags != this->OldFlags)
228 StartANewCalculation =
true;
231 if (!StartANewCalculation)
233 if ( *(this->CurrentInputParameters->SelectionVector)
235 *(this->OldInputParameters->SelectionVector) )
237 StartANewCalculation =
true;
241 for (i = 0; i < this->NumberOfDOFs; i++)
243 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
246 (this->CurrentInputParameters->CurrentVelocityVector->VecData)[i]
247 , (this->OutputParameters->NewVelocityVector->VecData)[i])
249 (this->CurrentInputParameters->MaxAccelerationVector->VecData)[i]
250 , (this->OldInputParameters->MaxAccelerationVector->VecData)[i])
252 (this->CurrentInputParameters->MaxVelocityVector->VecData)[i]
253 , (this->OldInputParameters->MaxVelocityVector->VecData)[i])
255 (this->CurrentInputParameters->TargetVelocityVector->VecData)[i]
256 , (this->OldInputParameters->TargetVelocityVector->VecData)[i])
258 ((this->CurrentInputParameters->TargetPositionVector->VecData)[i]
259 - (this->CurrentInputParameters->CurrentPositionVector->VecData)[i])
260 , ((this->OldInputParameters->TargetPositionVector->VecData)[i]
261 - (this->OutputParameters->NewPositionVector->VecData)[i]))))
263 StartANewCalculation =
true;
271 if ( (StartANewCalculation)
275 this->InternalClockInSeconds = this->CycleTime;
279 StartANewCalculation =
true;
281 this->SynchronizationTime = 0.0;
283 for (i = 0; i < this->NumberOfDOFs; i++)
285 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
287 if ( ( fabs((this->CurrentInputParameters->TargetVelocityVector->VecData)[i])
289 (this->CurrentInputParameters->MaxVelocityVector->VecData)[i] )
290 || ((this->CurrentInputParameters->MaxVelocityVector->VecData)[i]
293 || ((this->CurrentInputParameters->MaxAccelerationVector->VecData)[i]
297 FallBackStrategy( InputValues
298 , this->OutputParameters
301 *OutputValues = *(this->OutputParameters);
303 return(this->ReturnValue);
310 StartANewCalculation =
false;
315 *(this->OldInputParameters) = InputValues ;
316 this->OldFlags = Flags ;
318 if (StartANewCalculation)
320 *(this->StoredTargetPosition) = *(this->CurrentInputParameters->TargetPositionVector);
322 this->CompareInitialAndTargetStateofMotion();
341 && (!(this->CurrentTrajectoryIsPhaseSynchronized)) )
343 FallBackStrategy( InputValues
344 , this->OutputParameters
347 *OutputValues = *(this->OutputParameters);
356 return(this->ReturnValue);
361 FallBackStrategy( InputValues
362 , this->OutputParameters
365 *OutputValues = *(this->OutputParameters);
374 return(this->ReturnValue);
377 for (i = 0; i < this->NumberOfDOFs; i++)
379 (this->Polynomials)[i].ValidPolynomials = 0;
385 for (i = 0; i < 2 * this->NumberOfDOFs; i++)
396 while((IsWithinAnInoperativeTimeInterval( this->SynchronizationTime
397 , *(this->BeginningsOfInoperativeTimeIntervals)
398 , *(this->EndingsOfInoperativeTimeIntervals) ) )
399 && (i < 2 * this->NumberOfDOFs) )
401 this->SynchronizationTime = (this->ArrayOfSortedTimes->VecData)[i];
410 this->InternalClockInSeconds += this->CycleTime;
411 this->SynchronizationTime -= this->CycleTime;
413 if (this->SynchronizationTime < 0.0)
415 this->SynchronizationTime = 0.0;
419 if (this->GetNumberOfSelectedDOFs(*(this->ModifiedSelectionVector)) == 0)
421 this->SynchronizationTime = 0.0;
424 this->CurrentTrajectoryIsPhaseSynchronized =
false;
428 this->CurrentTrajectoryIsPhaseSynchronized =
true;
432 this->ReturnValue = Step3( this->InternalClockInSeconds
433 , this->OutputParameters );
435 this->OutputParameters->ANewCalculationWasPerformed = StartANewCalculation;
437 this->OutputParameters->TrajectoryIsPhaseSynchronized = this->CurrentTrajectoryIsPhaseSynchronized;
439 if (this->CurrentTrajectoryIsNotSynchronized)
441 this->OutputParameters->SynchronizationTime = 0.0;
442 this->OutputParameters->DOFWithTheGreatestExecutionTime = this->GreatestDOFForPhaseSynchronization;
444 for (i = 0; i < this->NumberOfDOFs; i++)
446 if (this->CurrentInputParameters->SelectionVector->VecData[i])
448 this->OutputParameters->ExecutionTimes->VecData[i] = (this->MinimumExecutionTimes->VecData)[i]
449 - this->InternalClockInSeconds
452 if (this->OutputParameters->ExecutionTimes->VecData[i] < 0.0)
454 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
459 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
465 this->OutputParameters->SynchronizationTime = this->SynchronizationTime;
466 this->OutputParameters->DOFWithTheGreatestExecutionTime = 0;
468 for (i = 0; i < this->NumberOfDOFs; i++)
470 if (this->CurrentInputParameters->SelectionVector->VecData[i])
472 this->OutputParameters->ExecutionTimes->VecData[i] = this->SynchronizationTime;
476 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
481 if (this->CalculatePositionalExtremsFlag)
483 this->CalculatePositionalExtrems( this->InternalClockInSeconds - this->CycleTime
484 , this->OutputParameters );
488 this->SetPositionalExtremsToZero(this->OutputParameters);
491 for (i = 0; i < this->NumberOfDOFs; i++)
493 if ( (this->ModifiedSelectionVector->VecData)[i] )
495 (this->OutputParameters->NewPositionVector->VecData)[i]
496 = (this->CurrentInputParameters->TargetPositionVector->VecData)[i]
497 - ((this->StoredTargetPosition->VecData)[i]
498 - (this->OutputParameters->NewPositionVector->VecData)[i] );
504 this->OutputParameters->SynchronizationTime = this->MinimumExecutionTimes->VecData[this->GreatestDOFForPhaseSynchronization];
507 *OutputValues = *(this->OutputParameters);
509 return(this->ReturnValue);
523 double InternalTime = TimeValueInSeconds
524 + this->InternalClockInSeconds
530 return(this->ReturnValue);
533 if ( ( TimeValueInSeconds < 0.0 )
539 if ( OutputValues == NULL )
551 ReturnValue = Step3( InternalTime
556 if (this->CurrentTrajectoryIsNotSynchronized)
561 for (i = 0; i < this->NumberOfDOFs; i++)
563 if (this->CurrentInputParameters->SelectionVector->VecData[i])
566 - TimeValueInSeconds;
584 for (i = 0; i < this->NumberOfDOFs; i++)
586 if (this->CurrentInputParameters->SelectionVector->VecData[i])
589 - TimeValueInSeconds;
603 if (this->CalculatePositionalExtremsFlag)
605 this->CalculatePositionalExtrems( InternalTime
610 this->SetPositionalExtremsToZero(OutputValues);
613 for (i = 0; i < this->NumberOfDOFs; i++)
615 if ( (this->ModifiedSelectionVector->VecData)[i] )
618 = (this->CurrentInputParameters->TargetPositionVector->VecData)[i]
619 - ((this->StoredTargetPosition->VecData)[i]
635 for (i = 0; i < this->NumberOfDOFs; i++)
655 for (i = 0; i < this->NumberOfDOFs; i++)
657 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
659 if (!(( (this->CurrentInputParameters->CurrentPositionVector->VecData) [i]
660 == (this->CurrentInputParameters->TargetPositionVector->VecData) [i] )
661 && ( (this->CurrentInputParameters->CurrentVelocityVector->VecData) [i]
662 == (this->CurrentInputParameters->TargetVelocityVector->VecData) [i] )
663 && ( (this->CurrentInputParameters->TargetVelocityVector->VecData) [i]
671 for (i = 0; i < this->NumberOfDOFs; i++)
673 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
675 if ((this->CurrentInputParameters->CurrentPositionVector->VecData)[i] != 0.0)
677 (this->CurrentInputParameters->CurrentPositionVector->VecData)[i]
679 +
FSign((this->CurrentInputParameters->CurrentVelocityVector->VecData)[i])
684 (this->CurrentInputParameters->CurrentPositionVector->VecData)[i]
685 +=
FSign((this->CurrentInputParameters->CurrentVelocityVector->VecData)[i])
Header file for the class RMLPositionOutputParameters.
Header file for the dynamic vector class used for the Reflexxes Motion Libraries. ...
RMLVector< double > RMLDoubleVector
Type definition for vectors of double elements.
Header file for the class ReflexxesAPI (API of the Reflexxes Motion Libraries)
Header file for the class RMLPositionFlags.
double SynchronizationTime
The synchronization time in seconds.
Data structure containing flags to parameterize the execution of the position-based On-Line Trajector...
The profile is undefined.
RMLDoubleVector * ExecutionTimes
A pointer to an RMLDoubleVector object that contains the execution times of all selected degrees of f...
T * VecData
Pointer to the actual vector data, that is, an array of type T objects.
Three arrays of TypeIIRMLMath::TypeIIRMLPolynomial.
unsigned int GetNumberOfSelectedDOFs(const RMLBoolVector &BoolVector) const
Returns the number of elements in BoolVector that are true.
unsigned int NumberOfDOFs
The number of degrees of freedom .
After the final state of motion is reached, a new trajectory will be computed, such that the desired ...
RMLDoubleVector * NewPositionVector
A pointer to the new position vector .
Header file for functions and definitions of constant values and macros.
unsigned int GetNumberOfDOFs(void) const
Returns the number of degrees of freedom.
#define RML_ADDITIONAL_ABSOLUTE_POSITION_ERROR_IN_CASE_OF_EQUALITY
If the initial state of motion exactly equals the target state of motion, a negligible position error...
int GetNextStateOfMotionAtTime(const double &TimeValueInSeconds, RMLPositionOutputParameters *OutputValues) const
Once the method of TypeIIRMLPosition::GetNextStateOfMotion() was successfully called to compute a tra...
Header file for the class TypeIIRMLPosition, which constitutes the actual interface of the Type II Re...
unsigned char SynchronizationBehavior
This value specifies the desired synchronization behavior.
unsigned int DOFWithTheGreatestExecutionTime
Index of the degree of freedom that requires the greatest execution time to reach its desired target ...
No value has been assigned yet.
Class for the output parameters of the velocity-based On-Line Trajectory Generation algorithm...
Even if it is possible to calculate a phase-synchronized trajectory, only a time-synchronized traject...
bool ANewCalculationWasPerformed
Indicates, whether a new computation was performed in the last cycle.
int BehaviorAfterFinalStateOfMotionIsReached
This flag defines the behavior for the time after the final state of motion was reached.
void CompareInitialAndTargetStateofMotion(void)
If the initial state of motion exactly equals the target state of motion, an adaptation is performed...
Only phase-synchronized trajectories are allowed. If it is not possible calculate a phase-synchronize...
TypeIIRMLPosition(const unsigned int &DegreesOfFreedom, const double &CycleTimeInSeconds)
Constructor of the class TypeIIRMLPosition.
This is the default value. If it is possible to calculate a phase-synchronized (i.e., homothetic) trajectory, the algorithm will generate it. A more detailed description of this flag can be found on the page page_PSIfPossible.
#define FSign(A)
Sign macro (floating point)
No synchronization will be performed, and all selected degrees of freedom are treated independently...
~TypeIIRMLPosition(void)
Destructor of the class TypeIIRMLPosition.
Header file for the Step 1 motion profiles.
#define RML_MAX_EXECUTION_TIME
Maximum value for the for the minimum trajectory execution time .
Class for the output parameters of the position-based On-Line Trajectory Generation algorithm...
bool TrajectoryIsPhaseSynchronized
Boolean flag that indicates whether the current trajectory is phase-synchronized. ...
int GetNextStateOfMotion(const RMLPositionInputParameters &InputValues, RMLPositionOutputParameters *OutputValues, const RMLPositionFlags &Flags)
The main method of the class TypeIIRMLPosition. It executes the position-based Type II On-Line Trajec...
RMLVector< bool > RMLBoolVector
Type definition for vectors of bool elements.
#define RML_ADDITIONAL_RELATIVE_POSITION_ERROR_IN_CASE_OF_EQUALITY
If the initial state of motion exactly equals the target state of motion, a negligible position error...
#define IsInputEpsilonEqual(A, B)
A macro that checks, whether the difference between the values 'A' and 'B' is less than RML_INPUT_VAL...
This class constitutes the user interface of velocity-based the Type II On-Line Trajectory Generation...
bool EnableTheCalculationOfTheExtremumMotionStates
A flag to enable or disable the calculation of the extremum states of motion of the currently calcula...