ocra-recipes
Doxygen documentation for the ocra-recipes repository
ControlEnum.h
Go to the documentation of this file.
1 
10 #ifndef _OCRACONTROL_CONTROL_ENUM_H_
11 #define _OCRACONTROL_CONTROL_ENUM_H_
12 
14 #include <iostream>
15 
16 namespace ocra
17 {
19  {
20  NONE=0,
21  X,
22  Y,
23  XY,
24  Z,
25  XZ,
26  YZ,
28  };
29 
30  namespace utils
31  {
33 
39  inline int computeDimensionFor(ECartesianDof fixedPosition, ECartesianDof fixedOrientation)
40  {
41  return (fixedPosition&0x1) + ((fixedPosition>>1)&0x1) + ((fixedPosition>>2)&0x1)
42  +(fixedOrientation&0x1) + ((fixedOrientation>>1)&0x1) + ((fixedOrientation>>2)&0x1);
43  }
44 
46  {
47  if (cDoF == ECartesianDof::X || cDoF == ECartesianDof::Y || cDoF == ECartesianDof::Z) {
48  return 1;
49  } else if (cDoF == ECartesianDof::XY || cDoF == ECartesianDof::YZ || cDoF == ECartesianDof::XZ) {
50  return 2;
51  } else if (cDoF == ECartesianDof::XYZ) {
52  return 3;
53  } else {
54  return 0;
55  }
56  }
57 
58  inline ECartesianDof cartesianDofFromString(const std::string& dofString)
59  {
60  std::string tmpString = util::convertToUpperCase(dofString);
61  if (tmpString == "NONE") {return ECartesianDof::NONE;}
62  else if (tmpString == "X") {return ECartesianDof::X;}
63  else if (tmpString == "Y") {return ECartesianDof::Y;}
64  else if (tmpString == "XY") {return ECartesianDof::XY;}
65  else if (tmpString == "Z") {return ECartesianDof::Z;}
66  else if (tmpString == "XZ") {return ECartesianDof::XZ;}
67  else if (tmpString == "YZ") {return ECartesianDof::YZ;}
68  else if (tmpString == "XYZ") {return ECartesianDof::XYZ;}
69  else {
70  std::cout << "[WARNING] (cartesianDofFromString): Couldn't find a match for: " << tmpString << std::endl;
71  return ECartesianDof::NONE;
72  }
73  }
74 
75  inline std::string cartesianDofToString(const ECartesianDof dofEnum)
76  {
77  std::string tmpString;
78  switch (dofEnum) {
79  case ECartesianDof::NONE: {tmpString = "NONE";} break;
80  case ECartesianDof::X: {tmpString = "X";} break;
81  case ECartesianDof::Y: {tmpString = "Y";} break;
82  case ECartesianDof::XY: {tmpString = "XY";} break;
83  case ECartesianDof::Z: {tmpString = "Z";} break;
84  case ECartesianDof::XZ: {tmpString = "XZ";} break;
85  case ECartesianDof::YZ: {tmpString = "YZ";} break;
86  case ECartesianDof::XYZ: {tmpString = "XYZ";} break;
87  default: {tmpString = "NONE";} break;
88  }
89  return tmpString;
90  }
91  }
92 }
93 
94 #endif //_OCRACONTROL_CONTROL_ENUM_H_
95 
96 // cmake:sourcegroup=Api
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
std::string cartesianDofToString(const ECartesianDof dofEnum)
Definition: ControlEnum.h:75
ECartesianDof
Definition: ControlEnum.h:18
ECartesianDof cartesianDofFromString(const std::string &dofString)
Definition: ControlEnum.h:58
int computeDimensionFor(ECartesianDof fixedPosition, ECartesianDof fixedOrientation)
Computes the number of directions specified by two ECartesianDof enums.
Definition: ControlEnum.h:39
std::string convertToUpperCase(const std::string &originalString)