Gazebo Physics
API Reference
7.4.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-physics
include
gz
physics
ForwardStep.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#ifndef GZ_PHYSICS_FORWARDSTEP_HH_
19
#define GZ_PHYSICS_FORWARDSTEP_HH_
20
21
#include <string>
22
#include <vector>
23
24
#include <gz/math.hh>
25
26
#include <
gz/physics/SpecifyData.hh
>
27
#include <
gz/physics/FeatureList.hh
>
28
29
namespace
gz
30
{
31
namespace
physics
32
{
33
// ---------------- Output Data Structures -----------------
34
// In the long-term, these data structures should be defined in some kind of
35
// meta-file, and our build system should generate these definitions during
36
// compilation. These are being defined here in this header until we know
37
// more about how the ECS will work.
38
39
struct
WorldPose
40
{
41
gz::math::Pose3d
pose
;
42
43
std::size_t
body
;
44
};
45
46
struct
WorldPoses
47
{
48
std::vector<WorldPose>
entries
;
49
std::string
annotation
;
50
};
51
55
struct
ChangedWorldPoses
56
{
57
std::vector<WorldPose>
entries
;
58
std::string
annotation
;
59
};
60
61
struct
Point
62
{
63
gz::math::Vector3d
point
;
64
65
std::size_t
relativeTo
;
66
std::size_t
inCoordinatesOf
;
67
};
68
69
struct
FreeVector
70
{
71
gz::math::Vector3d
vec
;
72
73
std::size_t
inCoordinatesOf
;
74
};
75
76
struct
JointPositions
77
{
78
std::vector<std::size_t>
dofs
;
79
std::vector<double>
positions
;
80
std::string
annotation
;
81
};
82
83
struct
Contacts
84
{
85
std::vector<Point>
entries
;
86
std::string
annotation
;
87
};
88
89
// ---------------- Input Data Structures -----------------
90
// Same note as for Output Data Structures. Eventually, these should be
91
// defined in some kind of meta files.
92
93
struct
TimeStep
94
{
95
double
dt
;
96
};
97
98
struct
ForceTorque
99
{
100
std::size_t
body
;
101
Point
location
;
102
103
FreeVector
force
;
104
FreeVector
torque
;
105
106
std::string
annotation
;
107
};
108
109
struct
GeneralizedParameters
110
{
111
std::vector<std::size_t>
dofs
;
112
std::vector<double>
forces
;
113
std::string
annotation
;
114
};
115
116
struct
PIDValues
117
{
118
double
P
;
119
double
I
;
120
double
D
;
121
};
122
123
struct
ApplyExternalForceTorques
124
{
125
std::vector<ForceTorque>
entries
;
126
std::string
annotation
;
127
};
128
129
struct
ApplyGeneralizedForces
130
{
131
std::vector<GeneralizedParameters>
forces
;
132
std::string
annotation
;
133
};
134
135
struct
VelocityControlCommands
136
{
137
std::vector<GeneralizedParameters>
commands
;
138
std::string
annotation
;
139
};
140
141
struct
ServoControlCommands
142
{
143
std::vector<GeneralizedParameters>
commands
;
144
std::vector<PIDValues>
gains
;
145
146
std::string
annotation
;
147
};
148
152
class
ForwardStep
:
public
virtual
Feature
153
{
154
public
:
using
Input
= ExpectData<
155
ApplyExternalForceTorques
,
156
ApplyGeneralizedForces
,
157
VelocityControlCommands
,
158
ServoControlCommands
,
159
std::chrono::steady_clock::duration>;
160
161
public
:
using
Output
=
SpecifyData
<
162
RequireData<WorldPoses>,
163
ExpectData<ChangedWorldPoses, Contacts, JointPositions> >;
164
165
public
:
using
State
=
CompositeData
;
166
167
public
:
template
<
typename
PolicyT,
typename
FeaturesT>
168
class
World
:
public
virtual
Feature::World
<PolicyT, FeaturesT>
169
{
170
public
:
void
Step
(
Output
&_h,
State
&_x,
const
Input
&_u)
171
{
172
this->
template
Interface<ForwardStep>()->
173
WorldForwardStep(this->
identity
, _h, _x, _u);
174
}
175
};
176
177
public
:
template
<
typename
PolicyT>
178
class
Implementation
:
public
virtual
Feature::Implementation<PolicyT>
179
{
180
public
:
virtual
void
WorldForwardStep
(
181
const
Identity &_worldID,
182
Output
&_h,
183
State
&_x,
184
const
Input
&_u) = 0;
185
};
186
};
187
188
// ---------------- SetState Interface -----------------
189
// class SetState
190
// {
191
// public: using State = CompositeData;
192
193
// public: virtual void SetStateTo(const State &x) = 0;
194
195
// public: virtual ~SetState() = default;
196
// };
197
}
198
}
199
200
#endif