Parasol Planning Library (PPL)
GroupUtils.h
Go to the documentation of this file.
1 #ifndef GROUP_UTILS_H_
2 #define GROUP_UTILS_H_
3 
4 //#include "Transformation.h"
5 //#include <iostream>
6 
13 
14 
15 
24 //template <typename MPTraits>
25 //typename MPTraits::CfgType
26 //RotateCfgAboutBody(const std::vector<unsigned int>& _bodyList,
27 // const typename MPTraits::CfgType& _cfg,
28 // const mathtool::Orientation& _rotation,
29 // const unsigned int _dofsPerBody,
30 // const bool _debug = false) {
31 // typedef typename MPTraits::CfgType CfgType;
32 //
33 // // compute position and rotation of part A, BEFORE rotation:
34 // _cfg.GetMultiBody()->Configure(_cfg);//Update transform
35 // mathtool::Transformation initTA = _cfg.GetMultiBody()->
36 // GetBody(_bodyList[0])->GetWorldTransformation();
37 //
38 // const mathtool::Transformation rotation(mathtool::Vector3d(0,0,0), _rotation);
39 //
40 // if(_debug)
41 // std::cout << "Rotating bodies " << _bodyList << " with rotation = "
42 // << rotation << std::endl;
43 //
44 // // The transform to be applied to all parts (including the first one). We
45 // // move the part to its relative world position with A at the world origin,
46 // // then the rotation is applied, and we return the part to its relative
47 // // position from A.
48 // const mathtool::Transformation transform = initTA * rotation;
49 //
50 // //Since we deal with composite CSpace, DOFs not in _bodyList should be
51 // // unchanged wrt the input cfg.
52 // CfgType rotatedCfg = _cfg;
53 //
54 // //Compute each body's needed transformation and set dofs in cfg.
55 // for (const unsigned int body : _bodyList) {
56 // // compute position and rotation of part B
57 // const mathtool::Transformation initTB = _cfg.GetMultiBody()->
58 // GetBody(body)->GetWorldTransformation();
59 //
60 // const mathtool::Transformation TB = transform * -initTA * initTB;
61 //
62 // //Extract the transformation:
63 // std::vector<double> transformed = TB.GetCfg();
64 //
65 // for(size_t i = 0; i < _dofsPerBody; ++i)
66 // rotatedCfg[body*_dofsPerBody + i] = transformed[i];
67 // }
68 //
69 // return rotatedCfg;
70 //}
71 //
72 //
89 //
96 //template <typename MPTraits>
97 //void
98 //AddDofsForBodies(typename MPTraits::CfgType& _cfg,
99 // const std::vector<double>& _dofs,
100 // const std::vector<unsigned int>& _bodies) {
101 // // This function adds all dofs (assumes #dofs per body is correct) to each
102 // // body given in _bodies to _cfg.
103 // const unsigned int dofsPerBody = _dofs.size();
104 // for(const unsigned int body : _bodies)
105 // for (unsigned int i = 0; i < dofsPerBody; ++i)
106 // _cfg[(body * dofsPerBody) + i] += _dofs[i];
107 //}
108 //
109 //
115 //template <typename MPTraits>
116 //void
117 //OverwriteDofsFromBodies(typename MPTraits::CfgType& _toCfg,
118 // const typename MPTraits::CfgType& _fromCfg,
119 // const std::vector<unsigned int>& _bodies) {
120 // // This function assigns the values from _fromCfg into _toCfg, based on which
121 // // bodies are given in _bodies.
122 // const unsigned int dofsPerBody = _toCfg.PosDOF() + _toCfg.OriDOF();
123 // for(const unsigned int body : _bodies) {
124 // const unsigned int bodyOffset = body * dofsPerBody;
125 // for (unsigned int i = 0; i < dofsPerBody; ++i) {
126 // const unsigned int dofIndex = bodyOffset + i;
127 // _toCfg[dofIndex] = _fromCfg[dofIndex];
128 // }
129 // }
130 //}
131 
132 #endif