Gazebo Gazebo

API Reference

6.16.0
gz/sim/rendering/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_GAZEBO_SCENEMANAGER_HH_
19 #define GZ_GAZEBO_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>
38 #include <gz/common/Animation.hh>
39 #include <gz/common/graphics/Types.hh>
40 
41 #include <gz/msgs/particle_emitter.pb.h>
42 
43 #include <gz/rendering/RenderTypes.hh>
44 
45 #include <gz/sim/config.hh>
46 #include <gz/sim/Entity.hh>
47 #include <gz/sim/rendering/Export.hh>
48 
49 namespace ignition
50 {
51 namespace gazebo
52 {
53 // Inline bracket to help doxygen filtering.
54 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
55  // Forward declaration
56  class SceneManagerPrivate;
57 
60  {
66  public: std::chrono::steady_clock::duration time;
67 
69  public: bool loop = false;
70 
72  public: bool followTrajectory = false;
73 
76 
80 
86 
89  public: bool valid = false;
90  };
91 
93  class IGNITION_GAZEBO_RENDERING_VISIBLE SceneManager
94  {
96  public: SceneManager();
97 
99  public: ~SceneManager();
100 
103  public: void SetScene(rendering::ScenePtr _scene);
104 
107  public: rendering::ScenePtr Scene() const;
108 
111  public: void SetWorldId(Entity _id);
112 
115  public: Entity WorldId() const;
116 
122  public: rendering::VisualPtr CreateModel(Entity _id,
123  const sdf::Model &_model, Entity _parentId = 0);
124 
130  public: rendering::VisualPtr CreateLink(Entity _id,
131  const sdf::Link &_link, Entity _parentId = 0);
132 
141  public: std::vector<rendering::NodePtr> Filter(const std::string &_node,
142  std::function<bool(
143  const rendering::NodePtr _nodeToFilter)> _filter) const;
144 
155  Entity _id, const std::string &_visual, Entity _parentId = 0);
156 
162  public: rendering::VisualPtr CreateVisual(Entity _id,
163  const sdf::Visual &_visual, Entity _parentId = 0);
164 
170  public: rendering::VisualPtr CreateCOMVisual(Entity _id,
171  const math::Inertiald &_inertial, Entity _parentId = 0);
172 
178  public: rendering::VisualPtr CreateInertiaVisual(Entity _id,
179  const math::Inertiald &_inertial, Entity _parentId = 0);
180 
187  public: rendering::VisualPtr CreateJointVisual(Entity _id,
188  const sdf::Joint &_joint, Entity _childId = 0,
189  Entity _parentId = 0);
190 
196  public: rendering::VisualPtr CreateCollision(Entity _id,
197  const sdf::Collision &_collision, Entity _parentId = 0);
198 
202  public: rendering::VisualPtr VisualById(Entity _id);
203 
208  LoadAnimations(const sdf::Actor &_actor);
209 
213  public: void SequenceTrajectories(
215  std::chrono::steady_clock::time_point _time);
216 
223  public: rendering::VisualPtr CreateActor(Entity _id,
224  const sdf::Actor &_actor, const std::string &_name,
225  Entity _parentId = 0);
226 
233  public: rendering::LightPtr CreateLight(Entity _id,
234  const sdf::Light &_light, const std::string &_name, Entity _parentId);
235 
242  public: rendering::VisualPtr CreateLightVisual(Entity _id,
243  const sdf::Light &_light, const std::string &_name, Entity _parentId);
244 
250  public: rendering::ParticleEmitterPtr CreateParticleEmitter(
251  Entity _id, const msgs::ParticleEmitter &_emitter, Entity _parentId);
252 
257  public: rendering::ParticleEmitterPtr UpdateParticleEmitter(Entity _id,
258  const msgs::ParticleEmitter &_emitter);
259 
267  public: bool AddSensor(Entity _gazeboId, const std::string &_sensorName,
268  Entity _parentGazeboId = 0);
269 
273  public: bool HasEntity(Entity _id) const;
274 
278  public: rendering::NodePtr NodeById(Entity _id) const;
279 
283  public: rendering::MeshPtr ActorMeshById(Entity _id) const;
284 
288  public: common::SkeletonPtr ActorSkeletonById(Entity _id) const;
289 
296  public: std::map<std::string, math::Matrix4d> ActorSkeletonTransformsAt(
297  Entity _id, std::chrono::steady_clock::duration _time) const;
298 
306  public: AnimationUpdateData ActorAnimationAt(
307  Entity _id, std::chrono::steady_clock::duration _time) const;
308 
311  public: void RemoveEntity(Entity _id);
312 
319  private: rendering::GeometryPtr LoadGeometry(const sdf::Geometry &_geom,
320  math::Vector3d &_scale, math::Pose3d &_localPose);
321 
325  private: rendering::MaterialPtr LoadMaterial(
326  const sdf::Material &_material);
327 
333  public: rendering::VisualPtr TopLevelVisual(
334  const rendering::VisualPtr &_visual) const;
335 
341  public: rendering::NodePtr TopLevelNode(
342  const rendering::NodePtr &_node) const;
343 
351  public: void UpdateTransparency(const rendering::NodePtr &_node,
352  bool _makeTransparent);
353 
357  public: void UpdateJointParentPose(Entity _jointId);
358 
362  public: Entity UniqueId() const;
363 
366  private: std::unique_ptr<SceneManagerPrivate> dataPtr;
367  };
368 }
369 }
370 }
371 
372 #endif
Data structure for updating skeleton animations.
Definition: gz/sim/rendering/SceneManager.hh:59
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
This library is part of the Gazebo project.
STL class.
STL class.
common::TrajectoryInfo trajectory
Trajectory to be followed.
Definition: gz/sim/rendering/SceneManager.hh:75
std::string animationName
Name of animation to play. This field is set only if the actor is not animated by manually using skel...
Definition: gz/sim/rendering/SceneManager.hh:79
STL class.
math::Matrix4d rootTransform
Transform of the root node in the skeleton. The actor's skeleton's root node transform needs to be se...
Definition: gz/sim/rendering/SceneManager.hh:85
bool loop
True if animation is looped.
Definition: gz/sim/rendering/SceneManager.hh:69
Component< NoData, class JointTag > Joint
A component that identifies an entity as being a joint.
Definition: gz/sim/components/Joint.hh:33
Component< NoData, class CollisionTag > Collision
A component that identifies an entity as being a collision.
Definition: gz/sim/components/Collision.hh:42
Scene manager class for loading and managing objects in the scene.
Definition: gz/sim/rendering/SceneManager.hh:93
Component< sdf::Light, class LightTag, serializers::LightSerializer > Light
This component contains light source information. For more information on lights, see SDF's Light ele...
Definition: gz/sim/components/Light.hh:48
Component< sdf::Actor, class ActorTag, serializers::ActorSerializer > Actor
This component contains actor source information. For more information on actors, see SDF's Actor ele...
Definition: gz/sim/components/Actor.hh:80
Component< sdf::Geometry, class GeometryTag, serializers::GeometrySerializer > Geometry
This component holds an entity's geometry.
Definition: gz/sim/components/Geometry.hh:46
Component< sdf::Scene, class SceneTag, serializers::SceneSerializer > Scene
This component holds scene properties of the world.
Definition: gz/sim/components/Scene.hh:45
STL class.
std::chrono::steady_clock::duration time
Timepoint in the animation. Note that animation time is different from sim time. An actor can have mu...
Definition: gz/sim/rendering/SceneManager.hh:66
Component< NoData, class ModelTag > Model
A component that identifies an entity as being a model.
Definition: gz/sim/components/Model.hh:111
Component< NoData, class LinkTag > Link
A component that identifies an entity as being a link.
Definition: gz/sim/components/Link.hh:33
bool followTrajectory
True if trajectory animation is on.
Definition: gz/sim/rendering/SceneManager.hh:72
Component< NoData, class VisualTag > Visual
A component that identifies an entity as being a visual.
Definition: gz/sim/components/Visual.hh:80
Component< sdf::Material, class MaterialTag, serializers::MaterialSerializer > Material
This component holds an entity's material.
Definition: gz/sim/components/Material.hh:44
bool valid
True if this animation update data is valid. If false, this update data should be ignored.
Definition: gz/sim/rendering/SceneManager.hh:89