Gazebo Sim
API Reference
9.3.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-sim
include
gz
sim
Util.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019 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
#ifndef GZ_SIM_UTIL_HH_
18
#define GZ_SIM_UTIL_HH_
19
20
#include <gz/msgs/entity.pb.h>
21
22
#include <memory>
23
#include <string>
24
#include <unordered_set>
25
#include <vector>
26
27
#include <
gz/common/Mesh.hh
>
28
#include <
gz/math/AxisAlignedBox.hh
>
29
#include <
gz/math/Pose3.hh
>
30
#include <sdf/Mesh.hh>
31
32
#include "
gz/sim/components/Environment.hh
"
33
#include "gz/sim/config.hh"
34
#include "
gz/sim/Entity.hh
"
35
#include "
gz/sim/EntityComponentManager.hh
"
36
#include "gz/sim/Export.hh"
37
#include "
gz/sim/Types.hh
"
38
39
40
namespace
gz
41
{
42
namespace
sim
43
{
44
// Inline bracket to help doxygen filtering.
45
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
46
//
51
math::Pose3d
GZ_SIM_VISIBLE
worldPose
(
const
Entity
&_entity,
52
const
EntityComponentManager
&_ecm);
53
58
math::Vector3d
GZ_SIM_VISIBLE
relativeVel
(
const
Entity
&_entity,
59
const
EntityComponentManager
&_ecm);
60
67
std::string
GZ_SIM_VISIBLE
scopedName
(
const
Entity
&_entity,
68
const
EntityComponentManager
&_ecm,
const
std::string
&_delim =
"/"
,
69
bool
_includePrefix =
true
);
70
94
std::unordered_set<Entity>
GZ_SIM_VISIBLE
entitiesFromScopedName
(
95
const
std::string
&_scopedName,
const
EntityComponentManager
&_ecm,
96
Entity
_relativeTo =
kNullEntity
,
97
const
std::string
&_delim =
"::"
);
98
119
ComponentTypeId
GZ_SIM_VISIBLE
entityTypeId
(
const
Entity
&_entity,
120
const
EntityComponentManager
&_ecm);
121
139
std::string
GZ_SIM_VISIBLE
entityTypeStr
(
const
Entity
&_entity,
140
const
EntityComponentManager
&_ecm);
141
146
Entity
GZ_SIM_VISIBLE
worldEntity
(
const
Entity
&_entity,
147
const
EntityComponentManager
&_ecm);
148
152
Entity
GZ_SIM_VISIBLE
worldEntity
(
153
const
EntityComponentManager
&_ecm);
154
160
std::string
GZ_SIM_VISIBLE
removeParentScope
(
161
const
std::string
&_name,
const
std::string
&_delim);
162
171
std::string
GZ_SIM_VISIBLE
asFullPath
(
const
std::string
&_uri,
172
const
std::string
&_filePath);
173
176
std::vector<std::string>
GZ_SIM_VISIBLE
resourcePaths
();
177
182
void
GZ_SIM_VISIBLE
addResourcePaths
(
183
const
std::vector<std::string>
&_paths = {});
184
190
gz::sim::Entity
GZ_SIM_VISIBLE
topLevelModel
(
191
const
Entity
&_entity,
192
const
EntityComponentManager
&_ecm);
193
206
std::string
GZ_SIM_VISIBLE
validTopic
(
207
const
std::vector<std::string>
&_topics);
208
224
std::string
GZ_SIM_VISIBLE
topicFromScopedName
(
225
const
Entity
&_entity,
226
const
EntityComponentManager
&_ecm,
227
bool
_excludeWorld =
true
);
228
244
std::string
GZ_SIM_VISIBLE
resolveSdfWorldFile
(
245
const
std::string
&_sdfFilename,
246
const
std::string
&_fuelResourceCache =
""
);
247
258
template
<
class
ComponentType>
259
bool
enableComponent
(
EntityComponentManager
&_ecm,
260
Entity
_entity,
261
bool
_enable =
true
,
262
const
ComponentType &_comp = ComponentType())
263
{
264
bool
changed{
false
};
265
266
auto
exists = _ecm.
Component
<ComponentType>(_entity);
267
if
(_enable && !exists)
268
{
269
_ecm.
CreateComponent
(_entity, _comp);
270
changed =
true
;
271
}
272
else
if
(!_enable && exists)
273
{
274
_ecm.
RemoveComponent
<ComponentType>(_entity);
275
changed =
true
;
276
}
277
return
changed;
278
}
279
297
Entity
GZ_SIM_VISIBLE
entityFromMsg
(
298
const
EntityComponentManager
&_ecm,
const
msgs::Entity &_msg);
299
306
std::optional<math::Vector3d> GZ_SIM_VISIBLE
sphericalCoordinates
(
307
Entity
_entity,
const
EntityComponentManager
&_ecm);
308
314
std::optional<math::Vector3d> GZ_SIM_VISIBLE
getGridFieldCoordinates
(
315
const
EntityComponentManager
&_ecm,
316
const
math::Vector3d
& _worldPosition,
317
const
std::shared_ptr<components::EnvironmentalData>
& _gridField);
318
322
GZ_SIM_VISIBLE
const
common::Mesh
*
loadMesh
(
const
sdf::Mesh &_meshSdf);
323
328
GZ_SIM_VISIBLE
const
common::Mesh
*
optimizeMesh
(
const
sdf::Mesh &_meshSdf,
329
const
common::Mesh
&_mesh);
330
335
GZ_SIM_VISIBLE
math::AxisAlignedBox
transformAxisAlignedBox
(
336
const
math::AxisAlignedBox
& _aabb,
337
const
math::Pose3d
& _pose);
338
342
GZ_SIM_VISIBLE std::optional<math::AxisAlignedBox>
meshAxisAlignedBox
(
343
const
sdf::Mesh &_sdfMesh);
344
347
GZ_SIM_VISIBLE
const
std::string
&
staticPluginPrefixStr
();
348
352
GZ_SIM_VISIBLE
bool
isStaticPlugin
(
const
std::string
&_filename);
353
355
const
std::string
kResourcePathEnv
{
"GZ_SIM_RESOURCE_PATH"
};
356
359
const
std::string
kSdfPathEnv
{
"SDF_PATH"
};
360
362
const
std::string
kServerConfigPathEnv
{
"GZ_SIM_SERVER_CONFIG_PATH"
};
363
366
const
std::string
kRenderPluginPathEnv
{
"GZ_SIM_RENDER_ENGINE_PATH"
};
367
369
const
std::string
kStaticPluginFilenamePrefix
{
"static://"
};
370
}
371
}
372
}
373
#endif