V-ART
ikchain.cpp
Go to the documentation of this file.
1 
5 #include "vart/ikchain.h"
6 #include "vart/collector.h"
7 #include "vart/joint.h"
8 #include <list>
9 //#include <iostream>
10 using namespace std;
11 
13  eePosition(eePos), eeOrientation(eeOri)
14 {
15  Collector<Joint> jointCollector;
16  path.Traverse(&jointCollector);
17  list<const Joint*>::const_iterator iter = jointCollector.begin();
18  for(; iter != jointCollector.end(); ++iter)
19  {
20  // get dofs from joint
21  const_cast<Joint*>(*iter)->GetDofs(&dofChain);
22  }
23 }
24 
26 {
27  eePosition = eePos;
28 }
29 
31 {
32  // Compute every dof position in world coordinates
33  unsigned int i = dofChain.size();
34  vector<Point4D> dofPosVec(i);
35  --i; // i is now the index of the last dof
36  Transform lim; // local instance matrix
37  Transform gim; // global instance matrix (accumulation of LIMs)
38  gim.MakeIdentity();
39  list<Dof*>::iterator iter = dofChain.begin();
40  for (; iter != dofChain.end(); ++iter)
41  {
42  (*iter)->GetLim(&lim);
43  gim.CopyMatrix(lim * gim);
44  dofPosVec.push_back(gim * (*iter)->GetPosition());
45  }
46  // For each dof inwards to the base
47  Point4D vectorToEE;
48  Point4D vectorToTarget;
49  list<Dof*>::reverse_iterator rIter = dofChain.rbegin();
50  for (; rIter != dofChain.rend(); ++rIter)
51  {
52  // rotate dof so that the end effector gets close to target by ...
53  // 1) computing the vector from dof to end effector
54  vectorToEE = eePosition - dofPosVec[i];
55  // 2) computing the vector from dof to target position
56  vectorToTarget = targetPos - dofPosVec[i];
57  --i;
58  // 3) computing the new dof configuration to make (1) close to (2).
59  (*rIter)->Reconfigure(vectorToEE, vectorToTarget);
60  // 4) update end effector position
61  eePosition =
62  }
63 }
std::list< Dof * > dofChain
Chain (list) of DOFs.
Definition: ikchain.h:43
Representation of joints.
Definition: joint.h:34
Header file for V-ART class "Collector".
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
void Traverse(SNOperator *operatorPtr) const
Process all nodes in path.
Definition: sgpath.cpp:65
void MoveTowardsSolution()
Adjusts the chain towards solution.
Definition: ikchain.cpp:30
Geometric transformations.
Definition: transform.h:24
Header file for V-ART class "Joint".
void MakeIdentity()
Turns transform into identity.
Definition: transform.cpp:49
A scene node operator that collects nodes of some kind.
Definition: collector.h:23
void GetDofs(std::list< Dof * > *dofListPtr)
Returns all DOFs.
Definition: joint.cpp:113
IKChain(SGPath path, Point4D eePos, Point4D eeOri)
Main constructor.
Definition: ikchain.cpp:12
void CopyMatrix(const Transform &t)
Copies matrix data from another transform.
Definition: transform.cpp:138
Scene Graph Path.
Definition: sgpath.h:23
void SetEEPosition(const Point4D &eePos)
Sets the position of End Effector.
Definition: ikchain.cpp:25
Header file for V-ART class "IKChain".