Gazebo Sim
API Reference
9.5.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 <string_view>
25
#include <unordered_set>
26
#include <vector>
27
28
#include <
gz/common/Mesh.hh
>
29
#include <
gz/math/AxisAlignedBox.hh
>
30
#include <
gz/math/Pose3.hh
>
31
#include <sdf/Mesh.hh>
32
33
#include "
gz/sim/components/Environment.hh
"
34
#include "gz/sim/config.hh"
35
#include "
gz/sim/Entity.hh
"
36
#include "
gz/sim/EntityComponentManager.hh
"
37
#include "gz/sim/Export.hh"
38
#include "
gz/sim/Types.hh
"
39
40
41
namespace
gz
42
{
43
namespace
sim
44
{
45
// Inline bracket to help doxygen filtering.
46
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
47
//
52
math::Pose3d
GZ_SIM_VISIBLE
worldPose
(
const
Entity
&_entity,
53
const
EntityComponentManager
&_ecm);
54
59
math::Vector3d
GZ_SIM_VISIBLE
relativeVel
(
const
Entity
&_entity,
60
const
EntityComponentManager
&_ecm);
61
68
std::string
GZ_SIM_VISIBLE
scopedName
(
const
Entity
&_entity,
69
const
EntityComponentManager
&_ecm,
const
std::string
&_delim =
"/"
,
70
bool
_includePrefix =
true
);
71
95
std::unordered_set<Entity>
GZ_SIM_VISIBLE
entitiesFromScopedName
(
96
const
std::string
&_scopedName,
const
EntityComponentManager
&_ecm,
97
Entity
_relativeTo =
kNullEntity
,
98
const
std::string
&_delim =
"::"
);
99
120
ComponentTypeId
GZ_SIM_VISIBLE
entityTypeId
(
const
Entity
&_entity,
121
const
EntityComponentManager
&_ecm);
122
140
std::string_view GZ_SIM_VISIBLE
entityTypeStrView
(
const
Entity
&_entity,
141
const
EntityComponentManager
&_ecm);
142
161
std::string
GZ_SIM_VISIBLE
entityTypeStr
(
162
const
Entity
&_entity,
163
const
EntityComponentManager
&_ecm);
164
169
Entity
GZ_SIM_VISIBLE
worldEntity
(
const
Entity
&_entity,
170
const
EntityComponentManager
&_ecm);
171
175
Entity
GZ_SIM_VISIBLE
worldEntity
(
176
const
EntityComponentManager
&_ecm);
177
183
std::string
GZ_SIM_VISIBLE
removeParentScope
(
184
const
std::string
&_name,
const
std::string
&_delim);
185
190
std::string
GZ_SIM_VISIBLE
normalizePluginName
(
191
const
std::string
&_name);
192
197
std::string
GZ_SIM_VISIBLE
normalizePluginFilename
(
198
const
std::string
&_filename);
199
208
std::string
GZ_SIM_VISIBLE
asFullPath
(
const
std::string
&_uri,
209
const
std::string
&_filePath);
210
213
std::vector<std::string>
GZ_SIM_VISIBLE
resourcePaths
();
214
219
void
GZ_SIM_VISIBLE
addResourcePaths
(
220
const
std::vector<std::string>
&_paths = {});
221
227
gz::sim::Entity
GZ_SIM_VISIBLE
topLevelModel
(
228
const
Entity
&_entity,
229
const
EntityComponentManager
&_ecm);
230
243
std::string
GZ_SIM_VISIBLE
validTopic
(
244
const
std::vector<std::string>
&_topics);
245
261
std::string
GZ_SIM_VISIBLE
topicFromScopedName
(
262
const
Entity
&_entity,
263
const
EntityComponentManager
&_ecm,
264
bool
_excludeWorld =
true
);
265
281
std::string
GZ_SIM_VISIBLE
resolveSdfWorldFile
(
282
const
std::string
&_sdfFilename,
283
const
std::string
&_fuelResourceCache =
""
);
284
295
template
<
class
ComponentType>
296
bool
enableComponent
(
EntityComponentManager
&_ecm,
297
Entity
_entity,
298
bool
_enable =
true
,
299
const
ComponentType &_comp = ComponentType())
300
{
301
bool
changed{
false
};
302
303
auto
exists = _ecm.
Component
<ComponentType>(_entity);
304
if
(_enable && !exists)
305
{
306
_ecm.
CreateComponent
(_entity, _comp);
307
changed =
true
;
308
}
309
else
if
(!_enable && exists)
310
{
311
_ecm.
RemoveComponent
<ComponentType>(_entity);
312
changed =
true
;
313
}
314
return
changed;
315
}
316
334
Entity
GZ_SIM_VISIBLE
entityFromMsg
(
335
const
EntityComponentManager
&_ecm,
const
msgs::Entity &_msg);
336
343
std::optional<math::Vector3d> GZ_SIM_VISIBLE
sphericalCoordinates
(
344
Entity
_entity,
const
EntityComponentManager
&_ecm);
345
351
std::optional<math::Vector3d> GZ_SIM_VISIBLE
getGridFieldCoordinates
(
352
const
EntityComponentManager
&_ecm,
353
const
math::Vector3d
& _worldPosition,
354
const
std::shared_ptr<components::EnvironmentalData>
& _gridField);
355
359
GZ_SIM_VISIBLE
const
common::Mesh
*
loadMesh
(
const
sdf::Mesh &_meshSdf);
360
365
GZ_SIM_VISIBLE
const
common::Mesh
*
optimizeMesh
(
const
sdf::Mesh &_meshSdf,
366
const
common::Mesh
&_mesh);
367
372
GZ_SIM_VISIBLE
math::AxisAlignedBox
transformAxisAlignedBox
(
373
const
math::AxisAlignedBox
& _aabb,
374
const
math::Pose3d
& _pose);
375
379
GZ_SIM_VISIBLE std::optional<math::AxisAlignedBox>
meshAxisAlignedBox
(
380
const
sdf::Mesh &_sdfMesh);
381
384
GZ_SIM_VISIBLE
const
std::string
&
staticPluginPrefixStr
();
385
389
GZ_SIM_VISIBLE
bool
isStaticPlugin
(
const
std::string
&_filename);
390
392
const
std::string
kResourcePathEnv
{
"GZ_SIM_RESOURCE_PATH"
};
393
396
const
std::string
kSdfPathEnv
{
"SDF_PATH"
};
397
399
const
std::string
kServerConfigPathEnv
{
"GZ_SIM_SERVER_CONFIG_PATH"
};
400
403
const
std::string
kRenderPluginPathEnv
{
"GZ_SIM_RENDER_ENGINE_PATH"
};
404
406
const
std::string
kStaticPluginFilenamePrefix
{
"static://"
};
407
}
408
}
409
}
410
#endif