DART 6.10.1
Loading...
Searching...
No Matches
Group.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, 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
38namespace dart {
39namespace dynamics {
40
42{
43public:
48 static GroupPtr create(
49 const std::string& _name = "Group",
50 const std::vector<BodyNode*>& _bodyNodes = std::vector<BodyNode*>(),
51 bool _includeJoints = true,
52 bool _includeDofs = true);
53
58 static GroupPtr create(
59 const std::string& _name,
60 const std::vector<DegreeOfFreedom*>& _dofs,
61 bool _includeBodyNodes = true,
62 bool _includeJoints = true);
63
65 static GroupPtr create(
66 const std::string& _name, const MetaSkeletonPtr& _metaSkeleton);
67
69 virtual ~Group() = default;
70
72 GroupPtr cloneGroup() const;
73
75 GroupPtr cloneGroup(const std::string& cloneName) const;
76
77 // To expose MetaSkeleton::cloneMetaSkeleton(), which takes no cloneName.
79
80 // Documentation inherited
82 const std::string& cloneName) const override;
83
85 void swapBodyNodeIndices(std::size_t _index1, std::size_t _index2);
86
88 void swapDofIndices(std::size_t _index1, std::size_t _index2);
89
96 bool addComponent(BodyNode* _bn, bool _warning = true);
97
104 bool addComponents(
105 const std::vector<BodyNode*>& _bodyNodes, bool _warning = true);
106
113 bool removeComponent(BodyNode* _bn, bool _warning = true);
114
121 bool removeComponents(
122 const std::vector<BodyNode*>& _bodyNodes, bool _warning = true);
123
129 bool addBodyNode(BodyNode* _bn, bool _warning = true);
130
137 bool addBodyNodes(
138 const std::vector<BodyNode*>& _bodyNodes, bool _warning = true);
139
145 bool removeBodyNode(BodyNode* _bn, bool _warning = true);
146
153 bool removeBodyNodes(
154 const std::vector<BodyNode*>& _bodyNodes, bool _warning = true);
155
163 bool addJoint(Joint* _joint, bool _addDofs = true, bool _warning = true);
164
173 bool addJoints(
174 const std::vector<Joint*>& _joints,
175 bool _addDofs = true,
176 bool _warning = true);
177
186 bool removeJoint(
187 Joint* _joint, bool _removeDofs = true, bool _warning = true);
188
197 bool removeJoints(
198 const std::vector<Joint*>& _joints,
199 bool _removeDofs = true,
200 bool _warning = true);
201
209 bool addDof(
210 DegreeOfFreedom* _dof, bool _addJoint = true, bool _warning = true);
211
219 bool addDofs(
220 const std::vector<DegreeOfFreedom*>& _dofs,
221 bool _addJoint = true,
222 bool _warning = true);
223
232 bool removeDof(
233 DegreeOfFreedom* _dof, bool _cleanupJoint = true, bool _warning = true);
234
243 bool removeDofs(
244 const std::vector<DegreeOfFreedom*>& _dofs,
245 bool _cleanupJoint = true,
246 bool _warning = true);
247
248protected:
250 Group(
251 const std::string& _name,
252 const std::vector<BodyNode*>& _bodyNodes,
253 bool _includeJoints,
254 bool _includeDofs);
255
257 Group(
258 const std::string& _name,
259 const std::vector<DegreeOfFreedom*>& _dofs,
260 bool _includeBodyNodes,
261 bool _includeJoints);
262
264 Group(const std::string& _name, const MetaSkeletonPtr& _metaSkeleton);
265};
266
267} // namespace dynamics
268} // namespace dart
269
270#endif // DART_DYNAMICS_GROUP_HPP_
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:79
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition DegreeOfFreedom.hpp:55
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:420
bool removeBodyNode(BodyNode *_bn, bool _warning=true)
Remove a BodyNode from this Group.
Definition Group.cpp:387
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:333
void swapDofIndices(std::size_t _index1, std::size_t _index2)
Swap the index of DegreeOfFreedom _index1 with _index2.
Definition Group.cpp:201
bool removeDof(DegreeOfFreedom *_dof, bool _cleanupJoint=true, bool _warning=true)
Remove a DegreeOfFreedom from this Group.
Definition Group.cpp:611
bool addBodyNode(BodyNode *_bn, bool _warning=true)
Add a BodyNode to this Group.
Definition Group.cpp:344
bool removeComponent(BodyNode *_bn, bool _warning=true)
Remove a BodyNode and its parent DegreesOfFreedom from this Group.
Definition Group.cpp:299
bool addDofs(const std::vector< DegreeOfFreedom * > &_dofs, bool _addJoint=true, bool _warning=true)
Add a set of DegreesOfFreedom to this Group.
Definition Group.cpp:600
GroupPtr cloneGroup() const
Creates and returns a clone of this Group.
Definition Group.cpp:76
bool removeJoints(const std::vector< Joint * > &_joints, bool _removeDofs=true, bool _warning=true)
Remove a set of Joints from this Group.
Definition Group.cpp:543
bool addComponents(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Add set of BodyNodes and their parent DegreesOfFreedom to this Group.
Definition Group.cpp:288
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:255
bool addBodyNodes(const std::vector< BodyNode * > &_bodyNodes, bool _warning=true)
Add a set of BodyNodes to this Group.
Definition Group.cpp:376
bool removeDofs(const std::vector< DegreeOfFreedom * > &_dofs, bool _cleanupJoint=true, bool _warning=true)
Remove a set of DegreesOfFreedom from this Group.
Definition Group.cpp:679
bool addJoint(Joint *_joint, bool _addDofs=true, bool _warning=true)
Add a Joint to this Group.
Definition Group.cpp:431
MetaSkeletonPtr cloneMetaSkeleton() const
Creates an identical clone of this MetaSkeleton.
Definition MetaSkeleton.cpp:328
void swapBodyNodeIndices(std::size_t _index1, std::size_t _index2)
Swap the index of BodyNode _index1 with _index2.
Definition Group.cpp:151
bool removeJoint(Joint *_joint, bool _removeDofs=true, bool _warning=true)
Remove a Joint from this Group.
Definition Group.cpp:491
bool addJoints(const std::vector< Joint * > &_joints, bool _addDofs=true, bool _warning=true)
Add a set of Joints to this Group.
Definition Group.cpp:480
virtual ~Group()=default
Destructor.
bool addDof(DegreeOfFreedom *_dof, bool _addJoint=true, bool _warning=true)
Add a DegreeOfFreedom to this Group.
Definition Group.cpp:554
class Joint
Definition Joint.hpp:60
MetaSkeletonPtr cloneMetaSkeleton() const
Creates an identical clone of this MetaSkeleton.
Definition MetaSkeleton.cpp:328
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:65