/usr/include/sofa/component/container/ArticulatedHierarchyContainer.h is in libsofa1-dev 1.0~beta4-10ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | /******************************************************************************
* SOFA, Simulation Open-Framework Architecture, version 1.0 beta 4 *
* (c) 2006-2009 MGH, INRIA, USTL, UJF, CNRS *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
*******************************************************************************
* SOFA :: Modules *
* *
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_COMPONENT_CONTAINER_ARTICULATEDHIERARCHYCONTAINER_H
#define SOFA_COMPONENT_CONTAINER_ARTICULATEDHIERARCHYCONTAINER_H
#include <sofa/core/objectmodel/BaseObject.h>
#include <sofa/defaulttype/VecTypes.h>
#include <sofa/simulation/tree/GNode.h>
#include <sofa/helper/io/bvh/BVHLoader.h>
#include <sofa/component/component.h>
#include <sofa/component/container/MechanicalObject.h>
#include <sofa/defaulttype/SolidTypes.h>
#include <sofa/core/objectmodel/DataFileName.h>
namespace sofa
{
namespace component
{
namespace container
{
using namespace sofa::defaulttype;
using namespace sofa::simulation::tree;
/**
* This class allow to store and retrieve all the articulation centers from an articulated rigid object
* @see ArticulatedCenter
* @see Articulation
*/
class SOFA_COMPONENT_CONTAINER_API ArticulatedHierarchyContainer : public virtual core::objectmodel::BaseObject
{
public:
typedef SolidTypes<double>::Transform Transform;
/**
* This class defines an articulation center. This contains a set of articulations.
* An articulation center is always defined between two DOF's (ParentDOF and ChildDOF).
* It stores the local position of the center articulation in relation to this DOF's (posOnParent, posOnChild),
* theirs indices (parentIndex, childIndex) and the global position of the articulation center.
* The local positions and indices have to be provided at initialization.
* For the same articulation center can be defined several articulations.
* All the variables which are defined in this class can be modified once sofa is running.
*/
class ArticulationCenter : public virtual core::objectmodel::BaseObject
{
public:
/**
* This class defines an articulation.
* An articulation is defined by an axis, an orientation and an index.
* All the variables which are defined in this class can be modified once sofa is running.
*/
class Articulation : public virtual core::objectmodel::BaseObject
{
public:
/**
* An articulation is defined by an axis, an orientation and an index.
* @param axis is a Vector3. It determines the motion axis
* @param rotation is a boolean. If true, it defines a rotation motion. Otherwise it does nothing.
* @param translation is a boolean. If true, it defines a translation motion. Otherwise it does nothing.
* @param articulationIndex is an integer. This index identifies, in an univocal way, one articulation
* from the set of articulations of a rigid object.
*/
Articulation();
~Articulation(){};
/**
* this variable defines the motion axis
*/
Data<Vector3> axis;
/**
* If true, this variable sets a rotation motion
* otherwise it does nothing
*/
Data<bool> rotation;
/**
* If true, this variable sets a translation motion
* otherwise it does nothing
*/
Data<bool> translation;
/**
* This is global index to number the articulations
*/
Data<int> articulationIndex;
std::vector<double> motion;
/**
* For Arboris Mapping H_pLc_a : transformation accumulates the successive transformation provided by articulations on the
* same articulation center
*/
Transform H_pLc_a;
};
/**
* This class contain a set of articulations.
* @see Articulation
* @param parentIndex. It stores the index of the parentDOF of the articulation center
* @param childIndex. It stores the index of the childDOF of the articulation center
* @param posOnParent. It stores the local position of the center articulation in relation
* to the global position of the parentDOF
* @param posOnChild. It stores the local position of the center articulation in relation
* to the global position of the childDOF
*/
ArticulationCenter();
~ArticulationCenter(){};
/**
* All DOF's can be identified, in an univocal way, by an index
* this variable will store the index of the parentDOF of the articulation center
*/
Data<int> parentIndex;
/**
* All DOF's can be identified, in an univocal way, by an index
* this variable will store the index of the childDOF of the articulation center
*/
Data<int> childIndex;
/**
* Global position for the articulation center. It's not necessary to provide it at initialization.
* This will be computed in mapping using the global position of the parent DOF and the local position
* of the center articulation
*/
Data<Vector3> globalPosition;
/**
* It stores the local position of the center articulation in relation to the global position of the parentDOF
*/
Data<Vector3> posOnParent;
/**
* It stores the local position of the center articulation in relation to the global position of the childDOF
*/
Data<Vector3> posOnChild;
/**
* It tells if the articulations of the articulation center are processed one by one or globally:
* 0 - (default ) articulation are treated one by one, the axis of the second articulation is updated by the potential rotation of the first articulation
potential problems could arise when rotation exceed 90° (known problem of euler angles)
* 1 - (Attach on Parent) the axis of the articulations are linked to the parent - rotations are treated by successive increases -
* 2 - (Attach on Child ) the axis of the articulations are linked to the child (estimate position from the previous time step) - rotations are treated by successive increases -
*/
Data<int> articulationProcess;
/**
* for ARBORIS Mapping
* Store information about the transformation induced by the articulation center (joint)
* H_p_pLc and H_c_cLp redefine posOnParent, posOnChild (a local rotation between the center of the articualtion and the parent/child bodies can be defined)
* H_pLc_cLp is transformation induced by the articulations of the articulation center (joint)
it is updated during "apply" function of the Mapping
*/
Transform H_p_pLc, H_c_cLp, H_pLc_cLp;
vector<Articulation*> articulations;
Vector3 posOnChildGlobal(Quat localToGlobal)
{
Vector3 result = localToGlobal.rotate(posOnChild.getValue());
return result;
}
Vector3 initTranslateChild(Quat objectRotation)
{
Vector3 PAParent = posOnParent.getValue() - Vector3(0,0,0);
Vector3 PAChild = posOnChild.getValue() - Vector3(0,0,0);
return objectRotation.rotate(PAParent - PAChild);
}
Vector3 translateChild(Quat object1Rotation, Quat object2Rotation)
{
Vector3 APChild = Vector3(0,0,0) - posOnChild.getValue();
Vector3 AP1 = object2Rotation.rotate(APChild);
Vector3 AP2 = object1Rotation.rotate(AP1);
return AP2 - AP1;
}
Vector3 correctPosChild(Vector3 object1Pos, Quat object1Rot, Vector3 object2Pos, Quat object2Rot)
{
Vector3 result;
Vector3 PAParent = posOnParent.getValue() - Vector3(0,0,0);
Vector3 PAChild = posOnChild.getValue() - Vector3(0,0,0);
Vector3 A1 = object1Pos + object1Rot.rotate(PAParent);
Vector3 A2 = object2Pos + object2Rot.rotate(PAChild);
result = A1 - A2;
return result;
}
vector<Articulation*>& getArticulations() { return articulations; }
Quat OrientationArticulationCenter;
Vector3 DisplacementArticulationCenter;
Vector3 Disp_Rotation;
}; // end ArticulationCenter
ArticulatedHierarchyContainer();
~ArticulatedHierarchyContainer(){}
void init();
void setFilename(std::string f){filename.setValue(f);}
vector<ArticulationCenter*> getArticulationCenters() { return articulationCenters; }
ArticulationCenter* getArticulationCenterAsChild(int index);
vector<ArticulationCenter*> getAcendantList(int index);
vector<ArticulationCenter*> articulationCenters;
vector<ArticulationCenter*> acendantList;
bool chargedFromFile;
int numOfFrames;
double dtbvh;
protected:
sofa::core::objectmodel::DataFileName filename;
private:
unsigned int id;
sofa::helper::io::bvh::BVHJoint* joint;
void buildCenterArticulationsTree(sofa::helper::io::bvh::BVHJoint*, int id_buf, const char* name, simulation::Node* node);
};
} // namespace container
} // namespace component
} // namespace sofa
#endif
|