62 ,
const double &CycleTimeInSeconds)
64 this->CurrentTrajectoryIsPhaseSynchronized = false ;
65 this->CalculatePositionalExtremsFlag = false ;
66 this->CurrentTrajectoryIsNotSynchronized = false ;
69 this->DOFWithGreatestExecutionTime = 0 ;
71 this->NumberOfDOFs = DegreesOfFreedom ;
72 this->CycleTime = CycleTimeInSeconds ;
73 this->InternalClockInSeconds = 0.0 ;
74 this->SynchronizationTime = 0.0 ;
76 this->PhaseSyncSelectionVector =
new RMLBoolVector (this->NumberOfDOFs);
79 this->PhaseSynchronizationReferenceVector =
new RMLDoubleVector (this->NumberOfDOFs);
80 this->PhaseSynchronizationCurrentVelocityVector =
new RMLDoubleVector (this->NumberOfDOFs);
81 this->PhaseSynchronizationTargetVelocityVector =
new RMLDoubleVector (this->NumberOfDOFs);
82 this->PhaseSynchronizationMaxAccelerationVector =
new RMLDoubleVector (this->NumberOfDOFs);
98 delete this->PhaseSyncSelectionVector ;
100 delete this->ExecutionTimes ;
101 delete this->PhaseSynchronizationReferenceVector ;
102 delete this->PhaseSynchronizationCurrentVelocityVector ;
103 delete this->PhaseSynchronizationTargetVelocityVector ;
104 delete this->PhaseSynchronizationMaxAccelerationVector ;
106 delete this->OldInputParameters ;
107 delete this->CurrentInputParameters ;
108 delete this->OutputParameters ;
110 delete[] this->Polynomials ;
112 this->PhaseSyncSelectionVector = NULL ;
113 this->ExecutionTimes = NULL ;
114 this->PhaseSynchronizationReferenceVector = NULL ;
115 this->PhaseSynchronizationCurrentVelocityVector = NULL ;
116 this->PhaseSynchronizationTargetVelocityVector = NULL ;
117 this->PhaseSynchronizationMaxAccelerationVector = NULL ;
119 this->OldInputParameters = NULL ;
120 this->CurrentInputParameters = NULL ;
121 this->OutputParameters = NULL ;
123 this->Polynomials = NULL ;
134 bool ErroneousInputValues = false
135 , StartANewCalculation = false ;
139 if ( (OutputValues == NULL)
140 || (&InputValues == NULL)
141 || (&Flags == NULL) )
144 return(this->ReturnValue);
151 return(this->ReturnValue);
156 *(this->CurrentInputParameters) = InputValues;
158 if (Flags != this->OldFlags)
160 StartANewCalculation =
true;
164 if (!StartANewCalculation)
166 if ( *(this->CurrentInputParameters->SelectionVector)
168 *(this->OldInputParameters->SelectionVector) )
170 StartANewCalculation =
true;
174 for (i = 0; i < this->NumberOfDOFs; i++)
176 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
179 (this->CurrentInputParameters->CurrentVelocityVector->VecData)[i]
180 , (this->OutputParameters->NewVelocityVector->VecData)[i])
182 (this->CurrentInputParameters->MaxAccelerationVector->VecData)[i]
183 , (this->OldInputParameters->MaxAccelerationVector->VecData)[i])
185 (this->CurrentInputParameters->TargetVelocityVector->VecData)[i]
186 , (this->OldInputParameters->TargetVelocityVector->VecData)[i])
188 (this->CurrentInputParameters->CurrentPositionVector->VecData)[i]
189 , (this->OutputParameters->NewPositionVector->VecData)[i])))
191 StartANewCalculation =
true;
199 if ( (StartANewCalculation)
203 this->InternalClockInSeconds = this->CycleTime;
204 StartANewCalculation =
true;
208 this->SynchronizationTime = 0.0;
212 this->InternalClockInSeconds += this->CycleTime;
213 this->SynchronizationTime -= this->CycleTime;
215 if (this->SynchronizationTime < 0.0)
217 this->SynchronizationTime = 0.0;
221 *(this->OldInputParameters) = InputValues ;
222 this->OldFlags = Flags ;
224 if (StartANewCalculation)
229 for (i = 0; i < this->NumberOfDOFs; i++)
231 if ((this->CurrentInputParameters->SelectionVector->VecData)[i])
233 if (this->CurrentInputParameters->MaxAccelerationVector->VecData[i] <= 0.0)
235 ErroneousInputValues =
true;
240 if (ErroneousInputValues)
242 this->FallBackStrategy( *(this->CurrentInputParameters)
243 , this->OutputParameters );
245 *OutputValues = *(this->OutputParameters);
247 return(this->ReturnValue);
256 this->CalculateExecutionTimes();
258 this->SynchronizationTime = 0.0;
260 for(i = 0; i < this->NumberOfDOFs; i++)
262 if(this->CurrentInputParameters->SelectionVector->VecData[i])
264 if ( (this->ExecutionTimes->VecData)[i] > this->SynchronizationTime )
266 this->SynchronizationTime = (this->ExecutionTimes->VecData)[i];
267 this->DOFWithGreatestExecutionTime = i;
278 if (this->CurrentTrajectoryIsPhaseSynchronized)
280 this->ComputePhaseSynchronizationParameters();
283 if ( (!this->CurrentTrajectoryIsPhaseSynchronized )
286 this->FallBackStrategy( *(this->CurrentInputParameters)
287 , this->OutputParameters );
289 *OutputValues = *(this->OutputParameters);
298 return(this->ReturnValue);
303 && (this->CurrentTrajectoryIsPhaseSynchronized ==
false ) ) )
305 for (i = 0; i < this->NumberOfDOFs; i++)
307 this->CurrentInputParameters->MaxAccelerationVector->VecData[i] =
308 fabs( (this->CurrentInputParameters->CurrentVelocityVector->VecData )[i]
309 - (this->CurrentInputParameters->TargetVelocityVector->VecData )[i])
310 / this->SynchronizationTime;
314 this->ComputeTrajectoryParameters();
317 this->OutputParameters->ANewCalculationWasPerformed = StartANewCalculation;
319 this->ReturnValue = this->ComputeAndSetOutputParameters( this->InternalClockInSeconds
320 , this->OutputParameters );
322 this->OutputParameters->TrajectoryIsPhaseSynchronized = this->CurrentTrajectoryIsPhaseSynchronized;
324 if (this->CurrentTrajectoryIsNotSynchronized)
326 this->OutputParameters->SynchronizationTime = 0.0;
327 this->OutputParameters->DOFWithTheGreatestExecutionTime = this->DOFWithGreatestExecutionTime;
329 for (i = 0; i < this->NumberOfDOFs; i++)
331 if (this->CurrentInputParameters->SelectionVector->VecData[i])
333 this->OutputParameters->ExecutionTimes->VecData[i] = (this->ExecutionTimes->VecData)[i]
334 - this->InternalClockInSeconds
337 if (this->OutputParameters->ExecutionTimes->VecData[i] < 0.0)
339 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
344 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
350 this->OutputParameters->SynchronizationTime = this->SynchronizationTime;
351 this->OutputParameters->DOFWithTheGreatestExecutionTime = 0;
353 for (i = 0; i < this->NumberOfDOFs; i++)
355 if (this->CurrentInputParameters->SelectionVector->VecData[i])
357 this->OutputParameters->ExecutionTimes->VecData[i] = this->SynchronizationTime;
361 this->OutputParameters->ExecutionTimes->VecData[i] = 0.0;
366 if (this->CalculatePositionalExtremsFlag)
368 this->CalculatePositionalExtrems( this->InternalClockInSeconds - this->CycleTime
369 , this->OutputParameters );
373 this->SetPositionalExtremsToZero(this->OutputParameters);
376 *OutputValues = *(this->OutputParameters);
378 return(this->ReturnValue);
392 double InternalTime = TimeValueInSeconds
393 + this->InternalClockInSeconds
399 return(this->ReturnValue);
402 if ( ( TimeValueInSeconds < 0.0 )
408 if ( OutputValues == NULL )
420 ReturnValueOfThisMethod = this->ComputeAndSetOutputParameters( InternalTime
425 if (this->CurrentTrajectoryIsNotSynchronized)
430 for (i = 0; i < this->NumberOfDOFs; i++)
432 if (this->CurrentInputParameters->SelectionVector->VecData[i])
435 - this->InternalClockInSeconds
455 for (i = 0; i < this->NumberOfDOFs; i++)
457 if (this->CurrentInputParameters->SelectionVector->VecData[i])
474 if (this->CalculatePositionalExtremsFlag)
476 this->CalculatePositionalExtrems( InternalTime
481 this->SetPositionalExtremsToZero(OutputValues);
484 return(ReturnValueOfThisMethod);
503 this->CycleTime = TypeIIRMLObject.
CycleTime ;
520 for ( i = 0; i < this->NumberOfDOFs; i++)
522 this->Polynomials[i] = TypeIIRMLObject.
Polynomials[i];
550 *
this = TypeIIRMLObject ;
Header file for the dynamic vector class used for the Reflexxes Motion Libraries. ...
RMLVector< double > RMLDoubleVector
Type definition for vectors of double elements.
double InternalClockInSeconds
In order to prevent from recalculating the trajectory within every control cycle and to safe CPU time...
Header file for the class ReflexxesAPI (API of the Reflexxes Motion Libraries)
double SynchronizationTime
The synchronization time in seconds.
RMLDoubleVector * PhaseSynchronizationTargetVelocityVector
Target velocity vector used for the calculation of phase-synchronized motion trajectories.
Data structure containing flags to parameterize the execution of the velocity-based On-Line Trajector...
Header file for the class TypeIIRMLVelocity.
TypeIIRMLVelocity(const unsigned int &DegreesOfFreedom, const double &CycleTimeInSeconds)
Constructor of the class TypeIIRMLVelocity.
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.
int GetNextStateOfMotionAtTime(const double &TimeValueInSeconds, RMLVelocityOutputParameters *OutputValues) const
Once the method of TypeIIRMLVelocity::GetNextStateOfMotion() was successfully called to compute a tra...
double SynchronizationTime
If the trajectory is time- or phase-synchronized, this attribute will contain the synchronization tim...
Header file for decisions of the two decision trees of the Type II On-Line Trajectory Generation algo...
Three arrays of TypeIIRMLMath::TypeIIRMLPolynomial.
bool CalculatePositionalExtremsFlag
Indicates, whether the positional extremes are to be calculated.
unsigned int NumberOfDOFs
The number of degrees of freedom .
Header file for functions and definitions of constant values and macros.
unsigned int GetNumberOfDOFs(void) const
Returns the number of degrees of freedom.
RMLDoubleVector * ExecutionTimes
Vector of double values, each of which represents an execution time that is used internally.
Header file for the class RMLVelocityFlags.
TypeIIRMLVelocity & operator=(const TypeIIRMLVelocity &TypeIIRMLObject)
Copy operator.
unsigned char SynchronizationBehavior
This value specifies the desired synchronization behavior.
RMLBoolVector * PhaseSyncSelectionVector
Boolean vector, which contains the modified selection vector that is based on the original selection ...
unsigned int DOFWithTheGreatestExecutionTime
Index of the degree of freedom that requires the greatest execution time to reach its desired target ...
RMLVelocityInputParameters * CurrentInputParameters
Pointer to an RMLVelocityInputParameters object. This object contains a complete set of input values ...
double CycleTime
Contains the cycle time in seconds.
bool CurrentTrajectoryIsPhaseSynchronized
Indicates, whether the current trajectory is phase-synchronized.
Header file for the class RMLVelocityOutputParameters.
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.
RMLDoubleVector * PhaseSynchronizationMaxAccelerationVector
Contains the adapted maximum acceleration vector for phase-synchronized trajectories.
RMLVelocityOutputParameters * OutputParameters
Pointer to an RMLVelocityOutputParameters object. This object contains the output parameters of the m...
RMLDoubleVector * PhaseSynchronizationCurrentVelocityVector
Current velocity vector used for the calculation of phase-synchronized motion trajectories.
Only phase-synchronized trajectories are allowed. If it is not possible calculate a phase-synchronize...
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.
RMLDoubleVector * PhaseSynchronizationReferenceVector
Reference vector for phase-synchronized trajectories, with .
No synchronization will be performed, and all selected degrees of freedom are treated independently...
unsigned int NumberOfDOFs
The number of degrees of freedom .
unsigned int DOFWithGreatestExecutionTime
Index of the degree of freedom that requires the greatest execution time.
#define RML_MAX_EXECUTION_TIME
Maximum value for the for the minimum trajectory execution time .
int ReturnValue
Contains the return value of the method TypeIIRMLVelocity::GetNextStateOfMotion() ...
bool TrajectoryIsPhaseSynchronized
Boolean flag that indicates whether the current trajectory is phase-synchronized. ...
~TypeIIRMLVelocity(void)
Destructor of the class TypeIIRMLVelocity.
int GetNextStateOfMotion(const RMLVelocityInputParameters &InputValues, RMLVelocityOutputParameters *OutputValues, const RMLVelocityFlags &Flags)
The main method of the class TypeIIRMLVelocity. It executes the velocity-based Type II On-Line Trajec...
bool CurrentTrajectoryIsNotSynchronized
Indicates, that the current trajectory is not synchronized.
MotionPolynomials * Polynomials
Pointer to an array of MotionPolynomials objects, which contains the actual trajectory ...
RMLVector< bool > RMLBoolVector
Type definition for vectors of bool elements.
#define IsInputEpsilonEqual(A, B)
A macro that checks, whether the difference between the values 'A' and 'B' is less than RML_INPUT_VAL...
RMLVelocityInputParameters * OldInputParameters
Pointer to an RMLVelocityInputParameters object. In order to check, whether a new calculation has to ...
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...