optimizer_container.h
Go to the documentation of this file.
1 
19 #ifndef __INC_OPTIMIZER_CONTAINER
20 #define __INC_OPTIMIZER_CONTAINER
21 
22 
23 namespace robotLibPbD {
24 
26 {
27 public:
29  std::vector<double> dofs_max, dofs_min;
30  std::vector<unsigned int> dofs;
31  void setValue(double *x, unsigned int index)
32  {
33  CMatrix pose;
34  CVec axis, position;
35 
36  for (unsigned int i=0; i<dofs.size(); i++)
37  {
38  LOG_MSG(11, "DOF %d -> %d: %f ( %f %f )\n", i, dofs[i], x[index + i], dofs_min[dofs[i]], dofs_max[dofs[i]]);
39  switch (dofs[i])
40  {
41  case 0:
42  position.x = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
43  break;
44  case 1:
45  position.y = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
46  break;
47  case 2:
48  position.z = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
49  break;
50  case 3:
51  axis.x = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
52  break;
53  case 4:
54  axis.y = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
55  break;
56  case 5:
57  axis.z = dofs_min[dofs[i]] + x[index + i] * (dofs_max[dofs[i]] - dofs_min[dofs[i]]);
58  break;
59  };
60  }
61 
62  double angle = axis.length();
63  axis.normalize();
64  CMathLib::getMatrixFromRotation(pose, axis, angle);
65  pose.a[12] = position.x;
66  pose.a[13] = position.y;
67  pose.a[14] = position.z;
68 
69 
70  frame->setPose(pose);
71 
72  LOG_MSG(11, "%s:\n%s", frame->getName(), pose.toString().c_str());
73  frame->invalidate();
74  };
75 };
76 
77 };
78 
79 
80 #endif
PRECISION z
Definition: vecmath.h:60
PRECISION length() const
Definition: vecmath.h:168
void setValue(double *x, unsigned int index)
static void getMatrixFromRotation(CMatrix &mat, const CVec &axis, double angle)
Transforms axis-angle representation into homogenous matrix representation.
Definition: vecmath.cpp:409
PRECISION a[16]
Definition: vecmath.h:190
Homogenous vector.
Definition: vecmath.h:57
Homogenous matrix.
Definition: vecmath.h:187
std::string toString(bool round=false)
Definition: vecmath.cpp:221
#define LOG_MSG(index, format,...)
Definition: log.h:32
virtual char * getName()
Definition: frame.h:103
virtual void setPose(const CMatrix &pose)
Definition: frame.h:120
std::vector< unsigned int > dofs
Robot types with implemented inverse kinematics.
Definition: frame.h:39
void normalize()
Definition: vecmath.h:172
virtual void invalidate()
Definition: frame.cpp:1292
PRECISION y
Definition: vecmath.h:60
PRECISION x
Definition: vecmath.h:60


asr_kinematic_chain_optimizer
Author(s): Aumann Florian, Heller Florian, Jäkel Rainer, Wittenbeck Valerij
autogenerated on Mon Jun 10 2019 12:35:36