RMLPositionInputParameters.h
Go to the documentation of this file.
1 // ---------------------- Doxygen info ----------------------
43 // ----------------------------------------------------------
44 // For a convenient reading of this file's source code,
45 // please use a tab width of four characters.
46 // ----------------------------------------------------------
47 
48 
49 #ifndef __RMLPositionInputParameters__
50 #define __RMLPositionInputParameters__
51 
52 
53 #include "RMLInputParameters.h"
54 #include "RMLVector.h"
55 #include <string.h>
56 #include <math.h>
57 
58 
59 // ---------------------- Doxygen info ----------------------
78 // ----------------------------------------------------------
80 {
81 public:
82 
83 
84 // ---------------------- Doxygen info ----------------------
96 // ----------------------------------------------------------
97  RMLPositionInputParameters(const unsigned int DegreesOfFreedom) : RMLInputParameters(DegreesOfFreedom)
98  {
99  this->MaxVelocityVector = new RMLDoubleVector (DegreesOfFreedom) ;
100  this->TargetPositionVector = new RMLDoubleVector (DegreesOfFreedom) ;
101  this->AlternativeTargetVelocityVector = new RMLDoubleVector (DegreesOfFreedom) ;
102 
103  memset(this->MaxVelocityVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double));
104  memset(this->TargetPositionVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double));
105  memset(this->AlternativeTargetVelocityVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double));
106  }
107 
108 
109 // ---------------------- Doxygen info ----------------------
121 // ----------------------------------------------------------
123  {
124  this->MaxVelocityVector = new RMLDoubleVector ((IP.CurrentPositionVector)->GetVecDim()) ;
125  this->TargetPositionVector = new RMLDoubleVector ((IP.CurrentPositionVector)->GetVecDim()) ;
127 
128  *(this->MaxVelocityVector) = *(IP.MaxVelocityVector) ;
129  *(this->TargetPositionVector) = *(IP.TargetPositionVector) ;
131  }
132 
133 
134 // ---------------------- Doxygen info ----------------------
139 // ----------------------------------------------------------
141  {
142  delete this->MaxVelocityVector ;
143  delete this->TargetPositionVector ;
144  delete this->AlternativeTargetVelocityVector ;
145 
146  this->MaxVelocityVector = NULL ;
147  this->TargetPositionVector = NULL ;
148  this->AlternativeTargetVelocityVector = NULL ;
149  }
150 
151 
152 // ---------------------- Doxygen info ----------------------
160 // ----------------------------------------------------------
162  {
164 
165  *(this->MaxVelocityVector ) = *(IP.MaxVelocityVector) ;
166  *(this->TargetPositionVector ) = *(IP.TargetPositionVector) ;
168 
169  return(*this);
170  }
171 
172 
173 // #############################################################################
174 
175 
176 // ---------------------- Doxygen info ----------------------
190 // ----------------------------------------------------------
191  inline void SetMaxVelocityVector(const RMLDoubleVector &InputVector)
192  {
193  *(this->MaxVelocityVector) = InputVector;
194  }
195 
196 
197 // ---------------------- Doxygen info ----------------------
211 // ----------------------------------------------------------
212  inline void SetMaxVelocityVector(const double *InputVector)
213  {
214  memcpy( (void*)this->MaxVelocityVector->VecData
215  , (void*)InputVector
216  , (this->MaxVelocityVector->GetVecDim() * sizeof(double)) );
217  }
218 
219 
220 // ---------------------- Doxygen info ----------------------
236 // ----------------------------------------------------------
237  inline void SetMaxVelocityVectorElement( const double &InputValue
238  , const unsigned int &Index)
239  {
240  (*this->MaxVelocityVector)[Index] = InputValue;
241  }
242 
243 
244 // ---------------------- Doxygen info ----------------------
259 // ----------------------------------------------------------
260  inline void GetMaxVelocityVector(RMLDoubleVector *InputVector) const
261  {
262  *InputVector = *(this->MaxVelocityVector);
263  }
264 
265 
266 // ---------------------- Doxygen info ----------------------
289 // ----------------------------------------------------------
290  inline void GetMaxVelocityVector( double *InputVector
291  , const unsigned int &SizeInBytes) const
292  {
293  memcpy( (void*)InputVector
294  , (void*)this->MaxVelocityVector->VecData
295  , SizeInBytes );
296  }
297 
298 
299 // ---------------------- Doxygen info ----------------------
320 // ----------------------------------------------------------
321  inline void GetMaxVelocityVectorElement( double *InputValue
322  , const unsigned int &Index) const
323  {
324  if ( ( Index + 1 ) > ((unsigned int) this->MaxVelocityVector->GetVecDim() ) )
325  {
326  *InputValue = 0.0;
327  }
328  else
329  {
330  *InputValue = (*this->MaxVelocityVector)[Index];
331  }
332  }
333 
334 
335 // ---------------------- Doxygen info ----------------------
350 // ----------------------------------------------------------
351  inline double GetMaxVelocityVectorElement(const unsigned int &Index) const
352  {
353  if ( ( Index + 1 ) > ((unsigned int) this->MaxVelocityVector->GetVecDim() ) )
354  {
355  return(0.0);
356  }
357  else
358  {
359  return( (*this->MaxVelocityVector)[Index] );
360  }
361  }
362 
363 
364 // #############################################################################
365 
366 
367 // ---------------------- Doxygen info ----------------------
381 // ----------------------------------------------------------
382  inline void SetTargetPositionVector(const RMLDoubleVector &InputVector)
383  {
384  *(this->TargetPositionVector) = InputVector;
385  }
386 
387 
388 // ---------------------- Doxygen info ----------------------
402 // ----------------------------------------------------------
403  inline void SetTargetPositionVector(const double *InputVector)
404  {
405  memcpy( (void*)this->TargetPositionVector->VecData
406  , (void*)InputVector
407  , (this->TargetPositionVector->GetVecDim() * sizeof(double)) );
408  }
409 
410 
411 // ---------------------- Doxygen info ----------------------
427 // ----------------------------------------------------------
428  inline void SetTargetPositionVectorElement( const double &InputValue
429  , const unsigned int &Index)
430  {
431  (*this->TargetPositionVector)[Index] = InputValue;
432  }
433 
434 
435 // ---------------------- Doxygen info ----------------------
450 // ----------------------------------------------------------
451  inline void GetTargetPositionVector(RMLDoubleVector *InputVector) const
452  {
453  *InputVector = *(this->TargetPositionVector);
454  }
455 
456 
457 // ---------------------- Doxygen info ----------------------
480 // ----------------------------------------------------------
481  inline void GetTargetPositionVector( double *InputVector
482  , const unsigned int &SizeInBytes) const
483  {
484  memcpy( (void*)InputVector
485  , (void*)this->TargetPositionVector->VecData
486  , SizeInBytes );
487  }
488 
489 
490 // ---------------------- Doxygen info ----------------------
511 // ----------------------------------------------------------
512  inline void GetTargetPositionVectorElement( double *InputValue
513  , const unsigned int &Index) const
514  {
515  if ( ( Index + 1 ) > ((unsigned int) this->TargetPositionVector->GetVecDim() ) )
516  {
517  *InputValue = 0.0;
518  }
519  else
520  {
521  *InputValue = (*this->TargetPositionVector)[Index];
522  }
523  }
524 
525 
526 // ---------------------- Doxygen info ----------------------
541 // ----------------------------------------------------------
542  inline double GetTargetPositionVectorElement(const unsigned int &Index) const
543  {
544  if ( ( Index + 1 ) > ((unsigned int) this->TargetPositionVector->GetVecDim() ) )
545  {
546  return(0.0);
547  }
548  else
549  {
550  return( (*this->TargetPositionVector)[Index] );
551  }
552  }
553 
554 
555 // #############################################################################
556 
557 
558 // ---------------------- Doxygen info ----------------------
580 // ----------------------------------------------------------
581  inline void SetAlternativeTargetVelocityVector(const RMLDoubleVector &InputVector)
582  {
583  *(this->AlternativeTargetVelocityVector) = InputVector;
584  }
585 
586 
587 // ---------------------- Doxygen info ----------------------
609 // ----------------------------------------------------------
610  inline void SetAlternativeTargetVelocityVector(const double *InputVector)
611  {
612  memcpy( (void*)this->AlternativeTargetVelocityVector->VecData
613  , (void*)InputVector
614  , (this->AlternativeTargetVelocityVector->GetVecDim() * sizeof(double)) );
615  }
616 
617 
618 // ---------------------- Doxygen info ----------------------
643 // ----------------------------------------------------------
644  inline void SetAlternativeTargetVelocityVectorElement( const double &InputValue
645  , const unsigned int &Index)
646  {
647  (*this->AlternativeTargetVelocityVector)[Index] = InputValue;
648  }
649 
650 
651 // ---------------------- Doxygen info ----------------------
667 // ----------------------------------------------------------
668  inline void GetAlternativeTargetVelocityVector(RMLDoubleVector *InputVector) const
669  {
670  *InputVector = *(this->AlternativeTargetVelocityVector);
671  }
672 
673 
674 // ---------------------- Doxygen info ----------------------
698 // ----------------------------------------------------------
699  inline void GetAlternativeTargetVelocityVector( double *InputVector
700  , const unsigned int &SizeInBytes) const
701  {
702  memcpy( (void*)InputVector
704  , SizeInBytes );
705  }
706 
707 
708 // ---------------------- Doxygen info ----------------------
730 // ----------------------------------------------------------
731  inline void GetAlternativeTargetVelocityVectorElement( double *InputValue
732  , const unsigned int &Index) const
733  {
734  if ( ( Index + 1 ) > ((unsigned int) this->AlternativeTargetVelocityVector->GetVecDim() ) )
735  {
736  *InputValue = 0.0;
737  }
738  else
739  {
740  *InputValue = (*this->AlternativeTargetVelocityVector)[Index];
741  }
742  }
743 
744 
745 // ---------------------- Doxygen info ----------------------
760 // ----------------------------------------------------------
761  inline double GetAlternativeTargetVelocityVectorElement(const unsigned int &Index) const
762  {
763  if ( ( Index + 1 ) > ((unsigned int) this->AlternativeTargetVelocityVector->GetVecDim() ) )
764  {
765  return(0.0);
766  }
767  else
768  {
769  return( (*this->AlternativeTargetVelocityVector)[Index] );
770  }
771  }
772 
773 
774 // #############################################################################
775 
776 
777 // ---------------------- Doxygen info ----------------------
822 // ----------------------------------------------------------
823  bool CheckForValidity(void) const
824  {
825  unsigned int i = 0;
826 
827  double MinimumOrderOfMagnitude = 0.0
828  , MaximumOrderOfMagnitude = 0.0;
829 
830  for (i = 0; i < this->NumberOfDOFs; i++)
831  {
832  if ((this->SelectionVector->VecData)[i])
833  {
834  if ( (this->MaxVelocityVector->VecData [i] <= 0.0 )
835  || (this->MaxAccelerationVector->VecData [i] <= 0.0 )
836  || ( fabs(this->TargetVelocityVector->VecData [i] )
837  > (this->MaxVelocityVector->VecData) [i] ) )
838  {
839  return(false);
840  }
841 
842  if ( ((this->MaxVelocityVector->VecData)[i] >= (this->MaxAccelerationVector->VecData) [i] )
843  && ((this->MaxVelocityVector->VecData)[i] >= fabs((this->CurrentPositionVector->VecData) [i]))
844  && ((this->MaxVelocityVector->VecData)[i] >= fabs((this->TargetPositionVector->VecData) [i]))
845  && ((this->MaxVelocityVector->VecData)[i] >= fabs((this->CurrentVelocityVector->VecData) [i]))
846  && ((this->MaxVelocityVector->VecData)[i] >= fabs((this->CurrentAccelerationVector->VecData) [i])))
847  {
848  MaximumOrderOfMagnitude = (this->MaxVelocityVector->VecData)[i];
849  }
850  else
851  {
852  if ( ((this->MaxAccelerationVector->VecData)[i] >= fabs((this->CurrentPositionVector->VecData) [i]))
853  && ((this->MaxAccelerationVector->VecData)[i] >= fabs((this->TargetPositionVector->VecData) [i]))
854  && ((this->MaxAccelerationVector->VecData)[i] >= fabs((this->CurrentVelocityVector->VecData) [i]))
855  && ((this->MaxAccelerationVector->VecData)[i] >= fabs((this->CurrentAccelerationVector->VecData) [i])))
856  {
857  MaximumOrderOfMagnitude = (this->MaxAccelerationVector->VecData)[i];
858  }
859  else
860  {
861  if ( (fabs((this->CurrentPositionVector->VecData)[i]) >= fabs((this->TargetPositionVector->VecData) [i]))
862  && (fabs((this->CurrentPositionVector->VecData)[i]) >= fabs((this->CurrentVelocityVector->VecData) [i]))
863  && (fabs((this->CurrentPositionVector->VecData)[i]) >= fabs((this->CurrentAccelerationVector->VecData) [i])))
864  {
865  MaximumOrderOfMagnitude = fabs((this->CurrentPositionVector->VecData)[i]);
866  }
867  else
868  {
869  if ( (fabs((this->TargetPositionVector->VecData)[i]) >= fabs((this->CurrentVelocityVector->VecData) [i]))
870  && (fabs((this->TargetPositionVector->VecData)[i]) >= fabs((this->CurrentAccelerationVector->VecData) [i])))
871  {
872  MaximumOrderOfMagnitude = fabs((this->TargetPositionVector->VecData)[i]);
873  }
874  else
875  {
876  MaximumOrderOfMagnitude = fabs((this->CurrentAccelerationVector->VecData)[i]);
877  }
878  }
879  }
880  }
881 
882  if ((this->MaxVelocityVector->VecData)[i] <= (this->MaxAccelerationVector->VecData) [i] )
883  {
884  MinimumOrderOfMagnitude = (this->MaxVelocityVector->VecData)[i];
885  }
886  else
887  {
888  MinimumOrderOfMagnitude = (this->MaxAccelerationVector->VecData)[i];
889  }
890 
891  // The target velocity value does not have to be checked as we
892  // already know that is lesser than the maximum velocity value.
893  // The alternative target velocity vector does not have to be
894  // checked.
895 
896  // The value of MinimumOrderOfMagnitude is greater than
897  // zero:
898  if ( (MaximumOrderOfMagnitude / MinimumOrderOfMagnitude)
899  > (double)pow((float)10, (int)(RMLPositionInputParameters::MAXIMUM_MAGNITUDE_RANGE)))
900  {
901  return(false);
902  }
903  }
904  }
905 
906  if (this->MinimumSynchronizationTime > 1e10)
907  {
908  return(false);
909  }
910 
911  return(true);
912  }
913 
914 
915 // ---------------------- Doxygen info ----------------------
923 // ----------------------------------------------------------
924  void Echo(FILE* FileHandler = stdout) const
925  {
926  unsigned int i = 0;
927 
928  if (FileHandler == NULL)
929  {
930  return;
931  }
932 
933  RMLInputParameters::Echo(FileHandler);
934 
935  fprintf(FileHandler, "Max. velocity vector : ");
936  for (i = 0; i < this->NumberOfDOFs; i++)
937  {
938  fprintf(FileHandler, " %.20le ", this->MaxVelocityVector->VecData[i]);
939  }
940  fprintf(FileHandler, "\nTarget position vector : ");
941  for (i = 0; i < this->NumberOfDOFs; i++)
942  {
943  fprintf(FileHandler, " %.20le ", this->TargetPositionVector->VecData[i]);
944  }
945  fprintf(FileHandler, "\nAlternative trgt vel. vector: ");
946  for (i = 0; i < this->NumberOfDOFs; i++)
947  {
948  fprintf(FileHandler, " %.20le ", this->AlternativeTargetVelocityVector->VecData[i]);
949  }
950  fprintf(FileHandler, "\n");
951 
952 
953  return;
954  }
955 
956 
957 protected:
958 
959 
960  enum
961  {
962 // ---------------------- Doxygen info ----------------------
966 // ----------------------------------------------------------
968  };
969 
970 
971 public:
972 
973 
974 // ---------------------- Doxygen info ----------------------
989 // ----------------------------------------------------------
991 
992 
993 // ---------------------- Doxygen info ----------------------
1008 // ----------------------------------------------------------
1010 
1011 
1012 // ---------------------- Doxygen info ----------------------
1051 // ----------------------------------------------------------
1053 
1054 
1055 };// class RMLPositionInputParameters
1056 
1057 
1058 
1059 #endif
1060 
1061 
Header file for the dynamic vector class used for the Reflexxes Motion Libraries. ...
RMLVector< double > RMLDoubleVector
Type definition for vectors of double elements.
Definition: RMLVector.h:548
RMLPositionInputParameters(const unsigned int DegreesOfFreedom)
Constructor of class RMLPositionInputParameters.
void SetTargetPositionVector(const RMLDoubleVector &InputVector)
Sets the target position vector by using the an RMLDoubleVector object.
RMLPositionInputParameters(const RMLPositionInputParameters &IP)
Copy constructor of class RMLPositionInputParameters.
RMLDoubleVector * CurrentVelocityVector
A pointer to the current velocity vector .
unsigned int NumberOfDOFs
The number of degrees of freedom .
RMLDoubleVector * MaxAccelerationVector
A pointer to the maximum acceleration vector .
void SetMaxVelocityVectorElement(const double &InputValue, const unsigned int &Index)
Sets one element of the maximum velocity vector .
T * VecData
Pointer to the actual vector data, that is, an array of type T objects.
Definition: RMLVector.h:524
RMLPositionInputParameters & operator=(const RMLPositionInputParameters &IP)
Copy operator.
void Echo(FILE *FileHandler=stdout) const
Prints the complete set of input parameters to *FileHandler.
double MinimumSynchronizationTime
Minimum trajectory execution time in seconds specified by the user (optional input parameter) ...
void Echo(FILE *FileHandler=stdout) const
Prints the complete set of input parameters to *FileHandler.
double GetAlternativeTargetVelocityVectorElement(const unsigned int &Index) const
Returns one single element of the alternative target velocity vector .
double GetTargetPositionVectorElement(const unsigned int &Index) const
Returns one single element of the target position vector .
Specifies the maximum allowed range for the orders of magnitude of the input values.
void SetTargetPositionVector(const double *InputVector)
Sets the target position vector by using a native C double array.
double GetMaxVelocityVectorElement(const unsigned int &Index) const
Returns one single element of the maximum velocity vector .
RMLDoubleVector * MaxVelocityVector
A pointer to the maximum velocity vector .
RMLBoolVector * SelectionVector
A pointer to the selection vector .
void SetMaxVelocityVector(const RMLDoubleVector &InputVector)
Sets the maximum velocity vector by using the an RMLDoubleVector object.
void GetTargetPositionVectorElement(double *InputValue, const unsigned int &Index) const
Copies one element of the target position vector to the memory pointed to by InputValue.
void GetAlternativeTargetVelocityVector(RMLDoubleVector *InputVector) const
Copies the contents of the RMLDoubleVector object containing the alternative target velocity vector ...
void GetMaxVelocityVector(double *InputVector, const unsigned int &SizeInBytes) const
Copies the array of double values representing the maximum velocity vector to the memory pointed to ...
RMLDoubleVector * TargetPositionVector
A pointer to the target position vector .
void GetAlternativeTargetVelocityVectorElement(double *InputValue, const unsigned int &Index) const
Copies one element of the alternative target velocity vector to the memory pointed to by InputValue...
void SetAlternativeTargetVelocityVector(const double *InputVector)
Sets the alternative target velocity vector by using the an RMLDoubleVector object.
void SetAlternativeTargetVelocityVectorElement(const double &InputValue, const unsigned int &Index)
Sets one element of the alternative target velocity vector .
bool CheckForValidity(void) const
Checks the input parameters for validity.
~RMLPositionInputParameters(void)
Destructor of class RMLPositionInputParameters.
void SetTargetPositionVectorElement(const double &InputValue, const unsigned int &Index)
Sets one element of the target position vector .
void GetAlternativeTargetVelocityVector(double *InputVector, const unsigned int &SizeInBytes) const
Copies the array of double values representing the alternative target velocity vector to the memory ...
void GetMaxVelocityVectorElement(double *InputValue, const unsigned int &Index) const
Copies one element of the maximum velocity vector to the memory pointed to by InputValue.
RMLDoubleVector * TargetVelocityVector
A pointer to the target velocity vector .
Class for the input parameters of the position-based On-Line Trajectory Generation algorithm...
void SetAlternativeTargetVelocityVector(const RMLDoubleVector &InputVector)
Sets the alternative target velocity vector by using the an RMLDoubleVector object.
RMLDoubleVector * AlternativeTargetVelocityVector
A pointer to an alternative target velocity vector .
void GetMaxVelocityVector(RMLDoubleVector *InputVector) const
Copies the contents of the RMLDoubleVector object containing the maximum velocity vector to the RMLD...
RMLDoubleVector * CurrentAccelerationVector
A pointer to the current acceleration vector .
RMLInputParameters & operator=(const RMLInputParameters &IP)
Copy operator.
Class for the input parameters of the On-Line Trajectory Generation algorithm.
RMLDoubleVector * CurrentPositionVector
A pointer to the current position vector .
void GetTargetPositionVector(RMLDoubleVector *InputVector) const
Copies the contents of the RMLDoubleVector object containing the target position vector to the RMLDo...
unsigned int GetVecDim(void) const
Returns the dimension of the vector.
Definition: RMLVector.h:497
This is a minimalistic dynamic vector class implementation used for the Reflexxes Motion Libraries...
Definition: RMLVector.h:77
Header file for the class RMLInputParameters.
void SetMaxVelocityVector(const double *InputVector)
Sets the maximum velocity vector by using a native C double array.
void GetTargetPositionVector(double *InputVector, const unsigned int &SizeInBytes) const
Copies the array of double values representing the target position vector to the memory pointed to b...


libreflexxestype2
Author(s):
autogenerated on Sat Nov 21 2020 03:17:34