Gazebo Sim
API Reference
9.0.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/Pose3.hh
>
29
#include <sdf/Mesh.hh>
30
31
#include "
gz/sim/components/Environment.hh
"
32
#include "gz/sim/config.hh"
33
#include "
gz/sim/Entity.hh
"
34
#include "
gz/sim/EntityComponentManager.hh
"
35
#include "gz/sim/Export.hh"
36
#include "
gz/sim/Types.hh
"
37
38
39
namespace
gz
40
{
41
namespace
sim
42
{
43
// Inline bracket to help doxygen filtering.
44
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
45
//
50
math::Pose3d
GZ_SIM_VISIBLE
worldPose
(
const
Entity
&_entity,
51
const
EntityComponentManager
&_ecm);
52
57
math::Vector3d
GZ_SIM_VISIBLE
relativeVel
(
const
Entity
&_entity,
58
const
EntityComponentManager
&_ecm);
59
66
std::string
GZ_SIM_VISIBLE
scopedName
(
const
Entity
&_entity,
67
const
EntityComponentManager
&_ecm,
const
std::string
&_delim =
"/"
,
68
bool
_includePrefix =
true
);
69
93
std::unordered_set<Entity>
GZ_SIM_VISIBLE
entitiesFromScopedName
(
94
const
std::string
&_scopedName,
const
EntityComponentManager
&_ecm,
95
Entity
_relativeTo =
kNullEntity
,
96
const
std::string
&_delim =
"::"
);
97
118
ComponentTypeId
GZ_SIM_VISIBLE
entityTypeId
(
const
Entity
&_entity,
119
const
EntityComponentManager
&_ecm);
120
138
std::string
GZ_SIM_VISIBLE
entityTypeStr
(
const
Entity
&_entity,
139
const
EntityComponentManager
&_ecm);
140
145
Entity
GZ_SIM_VISIBLE
worldEntity
(
const
Entity
&_entity,
146
const
EntityComponentManager
&_ecm);
147
151
Entity
GZ_SIM_VISIBLE
worldEntity
(
152
const
EntityComponentManager
&_ecm);
153
159
std::string
GZ_SIM_VISIBLE
removeParentScope
(
160
const
std::string
&_name,
const
std::string
&_delim);
161
170
std::string
GZ_SIM_VISIBLE
asFullPath
(
const
std::string
&_uri,
171
const
std::string
&_filePath);
172
175
std::vector<std::string>
GZ_SIM_VISIBLE
resourcePaths
();
176
181
void
GZ_SIM_VISIBLE
addResourcePaths
(
182
const
std::vector<std::string>
&_paths = {});
183
189
gz::sim::Entity
GZ_SIM_VISIBLE
topLevelModel
(
190
const
Entity
&_entity,
191
const
EntityComponentManager
&_ecm);
192
205
std::string
GZ_SIM_VISIBLE
validTopic
(
206
const
std::vector<std::string>
&_topics);
207
223
std::string
GZ_SIM_VISIBLE
topicFromScopedName
(
224
const
Entity
&_entity,
225
const
EntityComponentManager
&_ecm,
226
bool
_excludeWorld =
true
);
227
243
std::string
GZ_SIM_VISIBLE
resolveSdfWorldFile
(
244
const
std::string
&_sdfFilename,
245
const
std::string
&_fuelResourceCache =
""
);
246
255
template
<
class
ComponentType>
256
bool
enableComponent
(
EntityComponentManager
&_ecm,
257
Entity
_entity,
bool
_enable =
true
)
258
{
259
bool
changed{
false
};
260
261
auto
exists = _ecm.
Component
<ComponentType>(_entity);
262
if
(_enable && !exists)
263
{
264
_ecm.
CreateComponent
(_entity, ComponentType());
265
changed =
true
;
266
}
267
else
if
(!_enable && exists)
268
{
269
_ecm.
RemoveComponent
<ComponentType>(_entity);
270
changed =
true
;
271
}
272
return
changed;
273
}
274
292
Entity
GZ_SIM_VISIBLE
entityFromMsg
(
293
const
EntityComponentManager
&_ecm,
const
msgs::Entity &_msg);
294
301
std::optional<math::Vector3d> GZ_SIM_VISIBLE
sphericalCoordinates
(
302
Entity
_entity,
const
EntityComponentManager
&_ecm);
303
309
std::optional<math::Vector3d> GZ_SIM_VISIBLE
getGridFieldCoordinates
(
310
const
EntityComponentManager
&_ecm,
311
const
math::Vector3d
& _worldPosition,
312
const
std::shared_ptr<components::EnvironmentalData>
& _gridField);
313
317
GZ_SIM_VISIBLE
const
common::Mesh
*
loadMesh
(
const
sdf::Mesh &_meshSdf);
318
323
GZ_SIM_VISIBLE
const
common::Mesh
*
optimizeMesh
(
const
sdf::Mesh &_meshSdf,
324
const
common::Mesh
&_mesh);
325
327
const
std::string
kResourcePathEnv
{
"GZ_SIM_RESOURCE_PATH"
};
328
331
const
std::string
kSdfPathEnv
{
"SDF_PATH"
};
332
334
const
std::string
kServerConfigPathEnv
{
"GZ_SIM_SERVER_CONFIG_PATH"
};
335
338
const
std::string
kRenderPluginPathEnv
{
"GZ_SIM_RENDER_ENGINE_PATH"
};
339
}
340
}
341
}
342
#endif