DART  6.7.3
Group.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
35 #ifndef DART_DYNAMICS_GROUP_HPP_
36 #define DART_DYNAMICS_GROUP_HPP_
37 
38 namespace dart {
39 namespace dynamics {
40 
41 class Group : public ReferentialSkeleton
42 {
43 public:
44 
49  static GroupPtr create(
50  const std::string& _name = "Group",
51  const std::vector<BodyNode*>& _bodyNodes = std::vector<BodyNode*>(),
52  bool _includeJoints = true,
53  bool _includeDofs = true);
54 
59  static GroupPtr create(
60  const std::string& _name,
61  const std::vector<DegreeOfFreedom*>& _dofs,
62  bool _includeBodyNodes = true,
63  bool _includeJoints = true);
64 
66  static GroupPtr create(
67  const std::string& _name,
68  const MetaSkeletonPtr& _metaSkeleton);
69 
71  virtual ~Group() = default;
72 
74  GroupPtr cloneGroup() const;
75 
77  GroupPtr cloneGroup(const std::string& cloneName) const;
78 
79  // To expose MetaSkeleton::cloneMetaSkeleton(), which takes no cloneName.
81 
82  // Documentation inherited
83  MetaSkeletonPtr cloneMetaSkeleton(const std::string& cloneName) const override;
84 
86  void swapBodyNodeIndices(std::size_t _index1, std::size_t _index2);
87 
89  void swapDofIndices(std::size_t _index1, std::size_t _index2);
90 
97  bool addComponent(BodyNode* _bn, bool _warning=true);
98 
105  bool addComponents(const std::vector<BodyNode*>& _bodyNodes,
106  bool _warning=true);
107 
114  bool removeComponent(BodyNode* _bn, bool _warning=true);
115 
122  bool removeComponents(const std::vector<BodyNode*>& _bodyNodes,
123  bool _warning=true);
124 
130  bool addBodyNode(BodyNode* _bn, bool _warning=true);
131 
138  bool addBodyNodes(const std::vector<BodyNode*>& _bodyNodes,
139  bool _warning=true);
140 
146  bool removeBodyNode(BodyNode* _bn, bool _warning=true);
147 
153  bool removeBodyNodes(const std::vector<BodyNode*>& _bodyNodes,
154  bool _warning=true);
155 
163  bool addJoint(Joint* _joint, bool _addDofs=true, bool _warning=true);
164 
173  bool addJoints(const std::vector<Joint*>& _joints, bool _addDofs=true,
174  bool _warning=true);
175 
184  bool removeJoint(Joint* _joint, bool _removeDofs=true, bool _warning=true);
185 
194  bool removeJoints(const std::vector<Joint*>& _joints, bool _removeDofs=true,
195  bool _warning=true);
196 
204  bool addDof(DegreeOfFreedom* _dof, bool _addJoint=true, bool _warning=true);
205 
213  bool addDofs(const std::vector<DegreeOfFreedom*>& _dofs,
214  bool _addJoint = true, bool _warning=true);
215 
224  bool removeDof(DegreeOfFreedom* _dof, bool _cleanupJoint=true,
225  bool _warning=true);
226 
235  bool removeDofs(const std::vector<DegreeOfFreedom*>& _dofs,
236  bool _cleanupJoint=true, bool _warning=true);
237 
238 protected:
240  Group(const std::string& _name,
241  const std::vector<BodyNode*>& _bodyNodes,
242  bool _includeJoints,
243  bool _includeDofs);
244 
246  Group(const std::string& _name,
247  const std::vector<DegreeOfFreedom*>& _dofs,
248  bool _includeBodyNodes,
249  bool _includeJoints);
250 
252  Group(const std::string& _name,
253  const MetaSkeletonPtr& _metaSkeleton);
254 };
255 
256 } // dynamics
257 } // dart
258 
259 #endif // DART_DYNAMICS_GROUP_HPP_
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition: DegreeOfFreedom.hpp:53
Definition: Group.hpp:42
bool removeBodyNodes(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Remove a set of BodyNodes from this Group.
Definition: Group.cpp:416
bool removeBodyNode(BodyNode *_bn, bool _warning=true)
Remove a BodyNode from this Group.
Definition: Group.cpp:383
bool removeComponents(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Remove a set of BodyNodes and their parent DegreesOfFreedom from this Group.
Definition: Group.cpp:329
void swapDofIndices(std::size_t _index1, std::size_t _index2)
Swap the index of DegreeOfFreedom _index1 with _index2.
Definition: Group.cpp:197
bool removeDof(DegreeOfFreedom *_dof, bool _cleanupJoint=true, bool _warning=true)
Remove a DegreeOfFreedom from this Group.
Definition: Group.cpp:596
bool addBodyNode(BodyNode *_bn, bool _warning=true)
Add a BodyNode to this Group.
Definition: Group.cpp:340
bool removeComponent(BodyNode *_bn, bool _warning=true)
Remove a BodyNode and its parent DegreesOfFreedom from this Group.
Definition: Group.cpp:295
bool addDofs(const std::vector< DegreeOfFreedom * > &_dofs, bool _addJoint=true, bool _warning=true)
Add a set of DegreesOfFreedom to this Group.
Definition: Group.cpp:585
GroupPtr cloneGroup() const
Creates and returns a clone of this Group.
Definition: Group.cpp:72
bool removeJoints(const std::vector< Joint * > &_joints, bool _removeDofs=true, bool _warning=true)
Remove a set of Joints from this Group.
bool addComponents(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Add set of BodyNodes and their parent DegreesOfFreedom to this Group.
Definition: Group.cpp:284
static GroupPtr create(const std::string &_name="Group", const std::vector< BodyNode * > &_bodyNodes=std::vector< BodyNode * >(), bool _includeJoints=true, bool _includeDofs=true)
Create a Group out of a set of BodyNodes.
Definition: Group.cpp:43
bool addComponent(BodyNode *_bn, bool _warning=true)
Add a BodyNode and its parent DegreesOfFreedom to this Group.
Definition: Group.cpp:251
virtual MetaSkeletonPtr cloneMetaSkeleton(const std::string &cloneName) const=0
Creates an identical clone of this MetaSkeleton.
bool addBodyNodes(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Add a set of BodyNodes to this Group.
Definition: Group.cpp:372
bool removeDofs(const std::vector< DegreeOfFreedom * > &_dofs, bool _cleanupJoint=true, bool _warning=true)
Remove a set of DegreesOfFreedom from this Group.
Definition: Group.cpp:663
bool addJoint(Joint *_joint, bool _addDofs=true, bool _warning=true)
Add a Joint to this Group.
Definition: Group.cpp:427
void swapBodyNodeIndices(std::size_t _index1, std::size_t _index2)
Swap the index of BodyNode _index1 with _index2.
Definition: Group.cpp:147
Group(const std::string &_name, const std::vector< BodyNode * > &_bodyNodes, bool _includeJoints, bool _includeDofs)
Default constructor.
Definition: Group.cpp:674
bool removeJoint(Joint *_joint, bool _removeDofs=true, bool _warning=true)
Remove a Joint from this Group.
Definition: Group.cpp:487
bool addJoints(const std::vector< Joint * > &_joints, bool _addDofs=true, bool _warning=true)
Add a set of Joints to this Group.
Definition: Group.cpp:476
virtual ~Group()=default
Destructor.
bool addDof(DegreeOfFreedom *_dof, bool _addJoint=true, bool _warning=true)
Add a DegreeOfFreedom to this Group.
Definition: Group.cpp:539
class Joint
Definition: Joint.hpp:59
MetaSkeletonPtr cloneMetaSkeleton() const
Creates an identical clone of this MetaSkeleton.
Definition: MetaSkeleton.cpp:318
ReferentialSkeleton is a base class used to implement Linkage, Group, and other classes that are used...
Definition: ReferentialSkeleton.hpp:48
std::shared_ptr< MetaSkeleton > MetaSkeletonPtr
Definition: SmartPointer.hpp:68
std::shared_ptr< Group > GroupPtr
Definition: SmartPointer.hpp:73
Definition: BulletCollisionDetector.cpp:63