Ignition Gazebo

API Reference

6.9.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 IGNITION_GAZEBO_SCENEMANAGER_HH_
19 #define IGNITION_GAZEBO_SCENEMANAGER_HH_
20 
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 #include <sdf/Geometry.hh>
28 #include <sdf/Actor.hh>
29 #include <sdf/Joint.hh>
30 #include <sdf/Light.hh>
31 #include <sdf/Link.hh>
32 #include <sdf/Material.hh>
33 #include <sdf/Model.hh>
34 #include <sdf/Visual.hh>
35 
38 #include <ignition/common/graphics/Types.hh>
39 
41 
42 #include <ignition/rendering/RenderTypes.hh>
43 
44 #include <ignition/gazebo/config.hh>
46 #include <ignition/gazebo/rendering/Export.hh>
47 
48 namespace ignition
49 {
50 namespace gazebo
51 {
52 // Inline bracket to help doxygen filtering.
53 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
54  // Forward declaration
55  class SceneManagerPrivate;
56 
59  {
65  public: std::chrono::steady_clock::duration time;
66 
68  public: bool loop = false;
69 
71  public: bool followTrajectory = false;
72 
75 
79 
85 
88  public: bool valid = false;
89  };
90 
92  class IGNITION_GAZEBO_RENDERING_VISIBLE SceneManager
93  {
95  public: SceneManager();
96 
98  public: ~SceneManager();
99 
102  public: void SetScene(rendering::ScenePtr _scene);
103 
106  public: rendering::ScenePtr Scene() const;
107 
110  public: void SetWorldId(Entity _id);
111 
114  public: Entity WorldId() const;
115 
121  public: rendering::VisualPtr CreateModel(Entity _id,
122  const sdf::Model &_model, Entity _parentId = 0);
123 
129  public: rendering::VisualPtr CreateLink(Entity _id,
130  const sdf::Link &_link, Entity _parentId = 0);
131 
140  public: std::vector<rendering::NodePtr> Filter(const std::string &_node,
141  std::function<bool(
142  const rendering::NodePtr _nodeToFilter)> _filter) const;
143 
154  Entity _id, const std::string &_visual, Entity _parentId = 0);
155 
161  public: rendering::VisualPtr CreateVisual(Entity _id,
162  const sdf::Visual &_visual, Entity _parentId = 0);
163 
169  public: rendering::VisualPtr CreateCOMVisual(Entity _id,
170  const math::Inertiald &_inertial, Entity _parentId = 0);
171 
177  public: rendering::VisualPtr CreateInertiaVisual(Entity _id,
178  const math::Inertiald &_inertial, Entity _parentId = 0);
179 
186  public: rendering::VisualPtr CreateJointVisual(Entity _id,
187  const sdf::Joint &_joint, Entity _childId = 0,
188  Entity _parentId = 0);
189 
195  public: rendering::VisualPtr CreateCollision(Entity _id,
196  const sdf::Collision &_collision, Entity _parentId = 0);
197 
201  public: rendering::VisualPtr VisualById(Entity _id);
202 
209  public: rendering::VisualPtr CreateActor(Entity _id,
210  const sdf::Actor &_actor, const std::string &_name,
211  Entity _parentId = 0);
212 
219  public: rendering::LightPtr CreateLight(Entity _id,
220  const sdf::Light &_light, const std::string &_name, Entity _parentId);
221 
228  public: rendering::VisualPtr CreateLightVisual(Entity _id,
229  const sdf::Light &_light, const std::string &_name, Entity _parentId);
230 
236  public: rendering::ParticleEmitterPtr CreateParticleEmitter(
237  Entity _id, const msgs::ParticleEmitter &_emitter, Entity _parentId);
238 
243  public: rendering::ParticleEmitterPtr UpdateParticleEmitter(Entity _id,
244  const msgs::ParticleEmitter &_emitter);
245 
253  public: bool AddSensor(Entity _gazeboId, const std::string &_sensorName,
254  Entity _parentGazeboId = 0);
255 
259  public: bool HasEntity(Entity _id) const;
260 
264  public: rendering::NodePtr NodeById(Entity _id) const;
265 
269  public: rendering::MeshPtr ActorMeshById(Entity _id) const;
270 
274  public: common::SkeletonPtr ActorSkeletonById(Entity _id) const;
275 
282  public: std::map<std::string, math::Matrix4d> ActorSkeletonTransformsAt(
283  Entity _id, std::chrono::steady_clock::duration _time) const;
284 
292  public: AnimationUpdateData ActorAnimationAt(
293  Entity _id, std::chrono::steady_clock::duration _time) const;
294 
297  public: void RemoveEntity(Entity _id);
298 
305  private: rendering::GeometryPtr LoadGeometry(const sdf::Geometry &_geom,
306  math::Vector3d &_scale, math::Pose3d &_localPose);
307 
311  private: rendering::MaterialPtr LoadMaterial(
312  const sdf::Material &_material);
313 
319  public: rendering::VisualPtr TopLevelVisual(
320  const rendering::VisualPtr &_visual) const;
321 
327  public: rendering::NodePtr TopLevelNode(
328  const rendering::NodePtr &_node) const;
329 
337  public: void UpdateTransparency(const rendering::NodePtr &_node,
338  bool _makeTransparent);
339 
343  public: void UpdateJointParentPose(Entity _jointId);
344 
348  public: Entity UniqueId() const;
349 
352  private: std::unique_ptr<SceneManagerPrivate> dataPtr;
353  };
354 }
355 }
356 }
357 
358 #endif
Component< NoData, class VisualTag > Visual
A component that identifies an entity as being a visual.
Definition: Visual.hh:80
Component< sdf::Geometry, class GeometryTag, serializers::GeometrySerializer > Geometry
This component holds an entity&#39;s geometry.
Definition: Geometry.hh:46
common::TrajectoryInfo trajectory
Trajectory to be followed.
Definition: SceneManager.hh:74
std::string animationName
Name of animation to play. This field is set only if the actor is not animated by manually using skel...
Definition: SceneManager.hh:78
Component< NoData, class JointTag > Joint
A component that identifies an entity as being a joint.
Definition: Joint.hh:33
Data structure for updating skeleton animations.
Definition: SceneManager.hh:58
STL class.
Component< sdf::Scene, class SceneTag, serializers::SceneSerializer > Scene
This component holds scene properties of the world.
Definition: Scene.hh:45
math::Matrix4d rootTransform
Transform of the root node in the skeleton. The actor&#39;s skeleton&#39;s root node transform needs to be se...
Definition: SceneManager.hh:84
STL class.
Component< sdf::Material, class MaterialTag, serializers::MaterialSerializer > Material
This component holds an entity&#39;s material.
Definition: Material.hh:44
Component< NoData, class ModelTag > Model
A component that identifies an entity as being a model.
Definition: components/Model.hh:86
Component< sdf::Light, class LightTag, serializers::LightSerializer > Light
This component contains light source information. For more information on lights, see SDF&#39;s Light ele...
Definition: Light.hh:48
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: SceneManager.hh:65
STL class.
Component< NoData, class CollisionTag > Collision
A component that identifies an entity as being a collision.
Definition: Collision.hh:42
Component< NoData, class LinkTag > Link
A component that identifies an entity as being a link.
Definition: components/Link.hh:33
Scene manager class for loading and managing objects in the scene.
Definition: SceneManager.hh:92
Component< sdf::Actor, class ActorTag, serializers::ActorSerializer > Actor
This component contains actor source information. For more information on actors, see SDF&#39;s Actor ele...
Definition: Actor.hh:80
This library is part of the Ignition Robotics project.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59