-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathFreeGroup.hh
204 lines (175 loc) · 8.35 KB
/
FreeGroup.hh
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
/*
* Copyright (C) 2019 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GZ_PHYSICS_FREEGROUP_HH_
#define GZ_PHYSICS_FREEGROUP_HH_
#include <gz/physics/FeatureList.hh>
#include <gz/physics/FrameSemantics.hh>
#include <gz/physics/Geometry.hh>
namespace gz
{
namespace physics
{
DETAIL_GZ_PHYSICS_DEFINE_ENTITY(FreeGroup)
/////////////////////////////////////////////////
/// \brief This feature provides an interface between the Model and Link
/// classes and the FreeGroup class, which represents a group of links
/// that are not connected to the world with any kinematic constraints.
/// A FreeGroup can represent a single connected group of links that
/// forms a tree with the root of the tree connected to the world with
/// a FreeJoint, but it can also represent a group of other FreeGroups.
/// Each FreeGroup has 1 canonical link, whose frame is used for getting
/// and setting properties like pose and velocity.
/// If the FreeGroup is a single tree of connected links, the canonical
/// link should be the root of that tree.
/// If the FreeGroup contains multiple FreeGroups, the canonical link
/// should be selected from one of the component FreeGroups.
class GZ_PHYSICS_VISIBLE FindFreeGroupFeature : public virtual Feature
{
public: template <typename PolicyT, typename FeaturesT>
class Model : public virtual Feature::Model<PolicyT, FeaturesT>
{
using FreeGroupPtrType = FreeGroupPtr<PolicyT, FeaturesT>;
using ConstFreeGroupPtrType = ConstFreeGroupPtr<PolicyT, FeaturesT>;
/// \brief Find a FreeGroup that includes all the links in this model.
/// \return a FreeGroup that envelops all links in the model if such a
/// group is available. Otherwise a nullptr is returned.
public: FreeGroupPtrType FindFreeGroup();
/// \brief const version of FindFreeGroup()
public: ConstFreeGroupPtrType FindFreeGroup() const;
};
public: template <typename PolicyT, typename FeaturesT>
class Link : public virtual Feature::Link<PolicyT, FeaturesT>
{
using FreeGroupPtrType = FreeGroupPtr<PolicyT, FeaturesT>;
using ConstFreeGroupPtrType = ConstFreeGroupPtr<PolicyT, FeaturesT>;
/// \brief Find the smallest FreeGroup that includes this Link.
/// \return a FreeGroup that includes this link and any connected links.
/// If this link is constrained to the world in some way, then a nullptr
/// is returned.
public: FreeGroupPtrType FindFreeGroup();
/// \brief const version of FindFreeGroup()
public: ConstFreeGroupPtrType FindFreeGroup() const;
};
public: template <typename PolicyT, typename FeaturesT>
class FreeGroup : public virtual Entity<PolicyT, FeaturesT>
{
/// \brief The root link of this FreeGroup. This link is the root of one
/// of the kinematic trees represented by this FreeGroup. Getting and
/// setting properties (like poses and velocities) on the group will be
/// done in terms of this link.
public: LinkPtr<PolicyT, FeaturesT> RootLink();
/// \brief const version of RootLink()
public: ConstLinkPtr<PolicyT, FeaturesT> RootLink() const;
};
public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: virtual Identity FindFreeGroupForModel(
const Identity &_modelID) const = 0;
public: virtual Identity FindFreeGroupForLink(
const Identity &_linkID) const = 0;
public: virtual Identity GetFreeGroupRootLink(
const Identity &_groupID) const = 0;
};
};
/////////////////////////////////////////////////
class GZ_PHYSICS_VISIBLE FreeGroupFrameSemantics
: public virtual FeatureWithRequirements<
FindFreeGroupFeature, FrameSemantics>
{
public: template <typename PolicyT, typename FeaturesT>
using FreeGroup = FrameSemantics::Frame<PolicyT, FeaturesT>;
};
/////////////////////////////////////////////////
/// \brief This features sets the FreeGroup pose in world frame. However,
/// while a physics engine with maximal coordinates can provide
/// Link::SetWorldPose and similar functions for setting velocity
/// regardless of the kinematic constraints on that link, this behavior
/// for FreeGroup is not well defined and difficult to implement
/// with generalized coordinates. The FreeGroup::SetWorldPose function
/// should provide an analog to both Link::SetWorldPose and
/// Model::SetWorldPose.
class GZ_PHYSICS_VISIBLE SetFreeGroupWorldPose
: public virtual FeatureWithRequirements<FindFreeGroupFeature>
{
/// \brief This class defines the FreeGroup concept, which represents a
/// group of links that are not connected to the world with any kinematic
/// constraints. This class also provides a rough definition of this
/// FreeGroup pose in world frame. See FindFreeGroupFeature class
/// documentation for more detail.
public: template <typename PolicyT, typename FeaturesT>
class FreeGroup : public virtual Entity<PolicyT, FeaturesT>
{
public: using PoseType =
typename FromPolicy<PolicyT>::template Use<Pose>;
/// \brief Set this FreeGroup pose in world frame.
public: void SetWorldPose(const PoseType &_pose);
};
public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: using PoseType =
typename FromPolicy<PolicyT>::template Use<Pose>;
public: virtual void SetFreeGroupWorldPose(
const Identity &_groupID,
const PoseType &_pose) = 0;
};
};
/////////////////////////////////////////////////
/// \brief This features sets the FreeGroup linear and angular velocity in
/// world frame.
class GZ_PHYSICS_VISIBLE SetFreeGroupWorldVelocity
: public virtual FeatureWithRequirements<FindFreeGroupFeature>
{
/// \brief This class defines the FreeGroup concept, which represents a
/// group of links that are not connected to the world with any kinematic
/// constraints. This class also provides a rough definition of this
/// FreeGroup linear and angular velocity in world frame. See
/// FindFreeGroupFeature class documentation for more detail.
public: template <typename PolicyT, typename FeaturesT>
class FreeGroup : public virtual Entity<PolicyT, FeaturesT>
{
public: using LinearVelocity =
typename FromPolicy<PolicyT>::template Use<LinearVector>;
public: using AngularVelocity =
typename FromPolicy<PolicyT>::template Use<AngularVector>;
/// \brief Set this FreeGroup linear velocity in world frame.
public: void SetWorldLinearVelocity(
const LinearVelocity &_linearVelocity);
/// \brief Set this FreeGroup angular velocity in world frame.
public: void SetWorldAngularVelocity(
const AngularVelocity &_angularVelocity);
};
public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: using LinearVelocity =
typename FromPolicy<PolicyT>::template Use<LinearVector>;
public: using AngularVelocity =
typename FromPolicy<PolicyT>::template Use<AngularVector>;
public: virtual void SetFreeGroupWorldLinearVelocity(
const Identity &_groupID,
const LinearVelocity &_linearVelocity) = 0;
public: virtual void SetFreeGroupWorldAngularVelocity(
const Identity &_groupID,
const AngularVelocity &_angularVelocity) = 0;
};
};
}
}
#include <gz/physics/detail/FreeGroup.hh>
#endif