Gazebo Sim

API Reference

9.0.0
SceneManager.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
18#ifndef GZ_SIM_SCENEMANAGER_HH_
19#define GZ_SIM_SCENEMANAGER_HH_
20
21#include <map>
22#include <memory>
23#include <string>
24#include <unordered_map>
25#include <utility>
26#include <vector>
27
28#include <sdf/Geometry.hh>
29#include <sdf/Actor.hh>
30#include <sdf/Joint.hh>
31#include <sdf/Light.hh>
32#include <sdf/Link.hh>
33#include <sdf/Material.hh>
34#include <sdf/Model.hh>
35#include <sdf/Visual.hh>
36
37#include <gz/common/KeyFrame.hh>
39#include <gz/common/graphics/Types.hh>
40
41#include <gz/math/Inertial.hh>
42#include <gz/math/Matrix4.hh>
43#include <gz/math/Pose3.hh>
45#include <gz/math/Vector3.hh>
46
47#include <gz/msgs/particle_emitter.pb.h>
48
49#include <gz/rendering/RenderTypes.hh>
50
51#include <gz/sim/config.hh>
52#include <gz/sim/Entity.hh>
53#include <gz/sim/rendering/Export.hh>
54
55namespace gz
56{
57namespace sim
58{
59// Inline bracket to help doxygen filtering.
60inline namespace GZ_SIM_VERSION_NAMESPACE {
61 // Forward declaration
62 class SceneManagerPrivate;
63
66 {
72 public: std::chrono::steady_clock::duration time;
73
75 public: bool loop = false;
76
78 public: bool followTrajectory = false;
79
82
86
92
95 public: bool valid = false;
96 };
97
99 class GZ_SIM_RENDERING_VISIBLE SceneManager
100 {
102 public: SceneManager();
103
105 public: ~SceneManager();
106
109 public: void SetScene(rendering::ScenePtr _scene);
110
113 public: rendering::ScenePtr Scene() const;
114
117 public: void SetWorldId(Entity _id);
118
121 public: Entity WorldId() const;
122
127 const math::SphericalCoordinates &_sphericalCoordinates);
128
134 public: rendering::VisualPtr CreateModel(Entity _id,
135 const sdf::Model &_model, Entity _parentId = 0);
136
142 public: rendering::VisualPtr CreateLink(Entity _id,
143 const sdf::Link &_link, Entity _parentId = 0);
144
154 std::function<bool(
155 const rendering::NodePtr _nodeToFilter)> _filter) const;
156
167 Entity _id, const std::string &_visual, Entity _parentId = 0);
168
174 public: rendering::VisualPtr CreateVisual(Entity _id,
175 const sdf::Visual &_visual, Entity _parentId = 0);
176
182 public: rendering::VisualPtr CreateCOMVisual(Entity _id,
183 const math::Inertiald &_inertial, Entity _parentId = 0);
184
190 public: rendering::VisualPtr CreateInertiaVisual(Entity _id,
191 const math::Inertiald &_inertial, Entity _parentId = 0);
192
199 public: rendering::VisualPtr CreateJointVisual(Entity _id,
200 const sdf::Joint &_joint, Entity _childId = 0,
201 Entity _parentId = 0);
202
208 public: rendering::VisualPtr CreateCollision(Entity _id,
209 const sdf::Collision &_collision, Entity _parentId = 0);
210
214 public: rendering::VisualPtr VisualById(Entity _id);
215
220 LoadAnimations(const sdf::Actor &_actor);
221
227 std::chrono::steady_clock::time_point _time);
228
235 public: rendering::VisualPtr CreateActor(Entity _id,
236 const sdf::Actor &_actor, const std::string &_name,
237 Entity _parentId = 0);
238
245 public: rendering::LightPtr CreateLight(Entity _id,
246 const sdf::Light &_light, const std::string &_name, Entity _parentId);
247
254 public: rendering::VisualPtr CreateLightVisual(Entity _id,
255 const sdf::Light &_light, const std::string &_name, Entity _parentId);
256
262 public: rendering::ParticleEmitterPtr CreateParticleEmitter(
263 Entity _id, const msgs::ParticleEmitter &_emitter, Entity _parentId);
264
269 public: rendering::ParticleEmitterPtr UpdateParticleEmitter(Entity _id,
270 const msgs::ParticleEmitter &_emitter);
271
277 public: rendering::ProjectorPtr CreateProjector(
278 Entity _id, const sdf::Projector &_projector, Entity _parentId);
279
287 public: bool AddSensor(Entity _simId, const std::string &_sensorName,
288 Entity _parentGazeboId = 0);
289
293 public: bool HasEntity(Entity _id) const;
294
298 public: rendering::NodePtr NodeById(Entity _id) const;
299
303 public: rendering::MeshPtr ActorMeshById(Entity _id) const;
304
309
317 Entity _id, std::chrono::steady_clock::duration _time) const;
318
327 Entity _id, std::chrono::steady_clock::duration _time) const;
328
331 public: void RemoveEntity(Entity _id);
332
339 private: rendering::GeometryPtr LoadGeometry(const sdf::Geometry &_geom,
340 math::Vector3d &_scale, math::Pose3d &_localPose);
341
345 private: rendering::MaterialPtr LoadMaterial(
346 const sdf::Material &_material);
347
353 public: rendering::VisualPtr TopLevelVisual(
354 const rendering::VisualPtr &_visual) const;
355
361 public: rendering::NodePtr TopLevelNode(
362 const rendering::NodePtr &_node) const;
363
371 public: void UpdateTransparency(const rendering::NodePtr &_node,
372 bool _makeTransparent);
373
377 public: void UpdateJointParentPose(Entity _jointId);
378
382 public: Entity UniqueId() const;
383
387 public: void Clear();
388
392 };
393}
394}
395}
396
397#endif