ArticulatedTree Class Reference

This class defines a tree of rigid transformation able to represent a body schema. More...

#include <KinematicTree.h>

Inheritance diagram for ArticulatedTree:
EmbodiedArticulatedTree

Public Member Functions

 ArticulatedTree (const pTree tree)
 ArticulatedTree (const pArticulatedTree_t tree)
void CopyTree (pArticulatedTree_t tree)
 copies the values from another tree with the same structure.
void AddTree (pArticulatedTree_t ptree)
virtual void StreamTree (ostream &out) const
int GetSize () const
pArticulatedTree_t FindJoint (string &name)
pArticulatedTree_t FindSubTree (pArticulatedTree_t t, pArticulatedTree_t exclude=NULL)
 tells whether the tree contains a given subtree.
pArticulatedTree_t GetParent ()
ArticulatedTreeList_t * GetChildren ()
RigidTransfoGetJoint ()
void RandomAxis ()
void NoTranslation ()
void RandomAngle ()
void ZeroPosition ()
void Reshape (CVector3_t offset=NULL)
void Reshape2 (CVector3_t offset=NULL)
void GetAxis (CVector3_t axis)
int CheckPairsOfNodes (int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg)
 goes through all pairs of nodes in the tree and performed a given function
int CheckTreeNode1 (pArticulatedTree_t tree, int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg)
int CheckTreeNode2 (pArticulatedTree_t tree, int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg)
int GetAngleList (float *list)
 @ brief puts all the joint angles into a list @ param list the array of angles.
int SetAngleList (float *list)
int GetAngleRangeList (float *list_min, float *list_max)
float GetLowerRange ()
float GetUpperRange ()
int FindAngleRanges (float *lower_range, float *upper_range, KinematicChain *chain)
 recursively looks in the tree for the ranges corresponding to the joints in a KinematicChain
int Serialize (float *data, int data_size) const
 Serializes the translation vectors and rotation axes.
int Deserialize (const float *data, int data_size)
 Deserializes the translation vectors and rotation axes.
void PrintList ()
void PrintAngles ()

Data Fields

string name

Protected Attributes

RigidTransfo joint
ArticulatedTreeparent
ArticulatedTreeList_t children
float range [2]

Detailed Description

This class defines a tree of rigid transformation able to represent a body schema.

Definition at line 57 of file KinematicTree.h.


Member Function Documentation

int ArticulatedTree::CheckPairsOfNodes ( int(*)(pArticulatedTree_t, pArticulatedTree_t, void *)  f,
void *  arg 
)

goes through all pairs of nodes in the tree and performed a given function

goes through all unordered pairs of nodes in the tree and performs a given function.

Parameters:
f the function performed with all pairs of nodes
arg a pointer to an addition argument that is passed to f

Pairs of the sames nodes are skipped. Uncomment the corresponding line of code if you want them.

Parameters:
f the function performed with all pairs of nodes
arg a pointer to an addition argument that is passed to f

Definition at line 339 of file KinematicTree.cpp.

00339                                                                                                         {
00340   unsigned int i,j;
00341   int nb=0;
00342   //nb = (*f)(this,this,arg); //if one wants pairs of same elements
00343    for(i=0; i<children.size();i++){ 
00344      nb+=children[i]->CheckPairsOfNodes(f,arg); // the pair of nodes is in the same subtree i
00345      nb+=children[i]->CheckTreeNode1(this,f,arg); // the pairs composed of this and all descent of i
00346      for(j=i+1; j<children.size();j++){           // the pairs composed of one elmnt in i and one in j 
00347        nb+= children[j]->CheckTreeNode2(children[i],f,arg);
00348      }
00349    }
00350    return nb;
00351 }

void ArticulatedTree::CopyTree ( pArticulatedTree_t  tree  ) 

copies the values from another tree with the same structure.

Assumes that all the tree structure is already allocated

Parameters:
tree the tree to be copied

Definition at line 213 of file KinematicTree.cpp.

00213                                                      {
00214   unsigned int j;
00215   CVector3_t v;
00216   tree->GetAxis(v);
00217   joint.SetRotationAxis(v);
00218   //  tree->GetJoint()->GetRotationParam(v);
00219   //  joint.SetTransfo(v);
00220   joint.SetTranslation(tree->GetJoint()->GetTranslation());
00221   for(j=0;j<children.size();j++){
00222     children[j]->CopyTree(tree->GetChildren()->at(j));
00223   } 
00224 }

int ArticulatedTree::Deserialize ( const float *  data,
int  data_size 
)

Deserializes the translation vectors and rotation axes.

Assumes that the other side (i.e. Serialize) knows the structure of the tree. No information about joint angles is extracted

Definition at line 392 of file KinematicTree.cpp.

00392                                                                {
00393 
00394     int n=1; 
00395     ArticulatedTreeList_t::const_iterator it;
00396     if(data_size<6){
00397         cout<<"warning: writing outside buffer in ArticulatedTree::Deserialize"
00398             <<endl;
00399         return 0;
00400     }
00401     joint.SetTranslation(data);
00402     joint.SetRotationAxis(data+3);
00403     for(it=children.begin(); it!=children.end(); ++it){
00404         n+=(*it)->Deserialize(data+n*6,data_size-n*6);
00405         
00406     }
00407     return n;
00408 }

pArticulatedTree_t ArticulatedTree::FindSubTree ( pArticulatedTree_t  t,
pArticulatedTree_t  exclude = NULL 
)

tells whether the tree contains a given subtree.

Parameters:
t the subtree to look for
exclude a subtree to exclude from search (typically because it has already been searched) NULL if the tree does not contain the given subtree, a pointer to the subtree (i.e. t) otherwise

Definition at line 139 of file KinematicTree.cpp.

References FindSubTree().

Referenced by FindSubTree(), and KinematicTree::LoadChainRec().

00139                                                                                                {
00140   if(this==t){
00141     return this;
00142   }
00143   else{
00144     ArticulatedTreeList_t::const_iterator it;
00145     pArticulatedTree_t res;
00146     for(it=children.begin(); it!=children.end(); ++it){
00147       if(*it != exclude){
00148         res =(*it)->FindSubTree(t,exclude);
00149         if(res != NULL){ 
00150           return res;
00151         }
00152       }
00153     }
00154     return NULL;
00155   }
00156 }

int ArticulatedTree::GetAngleList ( float *  list  ) 

@ brief puts all the joint angles into a list @ param list the array of angles.

Use GetSize to know with what size to initializze this array

Definition at line 411 of file KinematicTree.cpp.

00411                                             {
00412   ArticulatedTreeList_t::const_iterator it;
00413   int n=1;
00414   *list= joint.GetAngle();
00415   for(it=children.begin(); it!=children.end(); ++it){
00416     n+=(*it)->GetAngleList(list+n);
00417   }
00418   return n;
00419 }

int ArticulatedTree::Serialize ( float *  data,
int  data_size 
) const

Serializes the translation vectors and rotation axes.

Assumes that the other side (i.e. Deserialize) knows the structure of the tree. No information about joint angles is provided

Definition at line 375 of file KinematicTree.cpp.

00375                                                             {
00376     int n=1; 
00377     ArticulatedTreeList_t::const_iterator it;
00378     if(data_size<6){
00379         cout<<"warning: writing outside buffer in ArticulatedTree::Serialize"
00380             <<endl;
00381         return 0;
00382     }
00383     v_copy(joint.GetTranslation(),data);
00384     v_copy(joint.GetRotationAxis(),data+3);
00385     for(it=children.begin(); it!=children.end(); ++it){
00386         n+=(*it)->Serialize(data+n*6,data_size-n*6);
00387         
00388     }
00389     return n;
00390 }


The documentation for this class was generated from the following files:
 All Data Structures Functions Variables

Generated on Wed Sep 22 16:51:26 2010 for Body_Schema_Learning by  doxygen 1.6.1