Gazebo Gazebo

API Reference

6.16.0
gz/sim/Light.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 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_GAZEBO_LIGHT_HH_
18 #define GZ_GAZEBO_LIGHT_HH_
19 
20 #include <memory>
21 #include <optional>
22 #include <string>
23 #include <vector>
24 
25 #include <gz/utils/ImplPtr.hh>
26 
27 #include <gz/math/Angle.hh>
28 #include <gz/math/Color.hh>
29 #include <gz/math/Pose3.hh>
30 #include <gz/math/Vector3.hh>
31 
32 #include "gz/sim/config.hh"
34 #include "gz/sim/Export.hh"
35 #include "gz/sim/Types.hh"
36 
37 namespace ignition
38 {
39  namespace gazebo
40  {
41  // Inline bracket to help doxygen filtering.
42  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
43  //
63  class IGNITION_GAZEBO_VISIBLE Light
64  {
67  public: explicit Light(gazebo::Entity _entity = kNullEntity);
68 
71  public: gazebo::Entity Entity() const;
72 
75  public: void ResetEntity(gazebo::Entity _newEntity);
76 
81  public: bool Valid(const EntityComponentManager &_ecm) const;
82 
87  public: std::optional<std::string> Name(
88  const EntityComponentManager &_ecm) const;
89 
96  public: std::optional<math::Pose3d> Pose(
97  const EntityComponentManager &_ecm) const;
98 
103  public: std::optional<std::string> Type(
104  const EntityComponentManager &_ecm) const;
105 
110  public: std::optional<math::Color> DiffuseColor(
111  const EntityComponentManager &_ecm) const;
112 
117  public: std::optional<math::Color> SpecularColor(
118  const EntityComponentManager &_ecm) const;
119 
124  public: std::optional<bool> CastShadows(
125  const EntityComponentManager &_ecm) const;
126 
131  public: std::optional<double> Intensity(
132  const EntityComponentManager &_ecm) const;
133 
138  public: std::optional<math::Vector3d> Direction(
139  const EntityComponentManager &_ecm) const;
140 
146  public: std::optional<double> AttenuationRange(
147  const EntityComponentManager &_ecm) const;
148 
154  public: std::optional<double> AttenuationConstant(
155  const EntityComponentManager &_ecm) const;
156 
162  public: std::optional<double> AttenuationLinear(
163  const EntityComponentManager &_ecm) const;
164 
170  public: std::optional<double> AttenuationQuadratic(
171  const EntityComponentManager &_ecm) const;
172 
177  public: std::optional<math::Angle> SpotInnerAngle(
178  const EntityComponentManager &_ecm) const;
179 
184  public: std::optional<math::Angle> SpotOuterAngle(
185  const EntityComponentManager &_ecm) const;
186 
191  public: std::optional<double> SpotFalloff(
192  const EntityComponentManager &_ecm) const;
193 
198  public: void SetPose(EntityComponentManager &_ecm,
199  const math::Pose3d &_pose);
200 
204  public: void SetDiffuseColor(EntityComponentManager &_ecm,
205  const math::Color &_color);
206 
210  public: void SetSpecularColor(EntityComponentManager &_ecm,
211  const math::Color &_color);
212 
216  public: void SetCastShadows(EntityComponentManager &_ecm,
217  bool _castShadows);
218 
222  public: void SetIntensity(EntityComponentManager &_ecm,
223  double _value);
224 
229  public: void SetDirection(EntityComponentManager &_ecm,
230  const math::Vector3d &_dir);
231 
236  public: void SetAttenuationRange(EntityComponentManager &_ecm,
237  double _range);
238 
243  public: void SetAttenuationConstant(EntityComponentManager &_ecm,
244  double _value);
245 
250  public: void SetAttenuationLinear(EntityComponentManager &_ecm,
251  double _value);
252 
257  public: void SetAttenuationQuadratic(EntityComponentManager &_ecm,
258  double _value);
259 
263  public: void SetSpotInnerAngle(EntityComponentManager &_ecm,
264  const math::Angle &_angle);
265 
269  public: void SetSpotOuterAngle(EntityComponentManager &_ecm,
270  const math::Angle &_angle);
271 
275  public: void SetSpotFalloff(EntityComponentManager &_ecm,
276  double _falloff);
277 
282  public: std::optional<gazebo::Entity> Parent(
283  const EntityComponentManager &_ecm) const;
284 
286  IGN_UTILS_IMPL_PTR(dataPtr)
287  };
288  }
289  }
290 }
291 #endif
void SetAttenuationQuadratic(EntityComponentManager &_ecm, double _value)
Set attenuation quadratic value of this light.
std::optional< math::Angle > SpotOuterAngle(const EntityComponentManager &_ecm) const
Get the outer angle of light. Applies to spot lights only.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
void SetDirection(EntityComponentManager &_ecm, const math::Vector3d &_dir)
Set light direction. Applies to directional lights.
This library is part of the Gazebo project.
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:66
std::optional< math::Color > SpecularColor(const EntityComponentManager &_ecm) const
Get the light specular color.
void SetSpecularColor(EntityComponentManager &_ecm, const math::Color &_color)
Set the specular color of this light.
Light(gazebo::Entity _entity=kNullEntity)
Constructor.
void SetSpotInnerAngle(EntityComponentManager &_ecm, const math::Angle &_angle)
Set inner angle for this light. Applies to spot lights only.
std::optional< double > AttenuationConstant(const EntityComponentManager &_ecm) const
Get the light attenuation constant value. Light attenuation is not applicable to directional lights.
std::optional< math::Vector3d > Direction(const EntityComponentManager &_ecm) const
Get the light direction.
std::optional< double > AttenuationQuadratic(const EntityComponentManager &_ecm) const
Get the light attenuation quadratic value. Light attenuation is not applicable to directional lights.
void SetCastShadows(EntityComponentManager &_ecm, bool _castShadows)
Set whether the light casts shadows.
std::optional< double > Intensity(const EntityComponentManager &_ecm) const
Get the light intensity.
This class provides wrappers around entities and components which are more convenient and straight-fo...
Definition: gz/sim/Light.hh:63
std::optional< std::string > Type(const EntityComponentManager &_ecm) const
Get the light type.
std::optional< double > SpotFalloff(const EntityComponentManager &_ecm) const
Get the fall off value of light. Applies to spot lights only.
void SetAttenuationConstant(EntityComponentManager &_ecm, double _value)
Set attenuation constant value of this light.
std::optional< math::Color > DiffuseColor(const EntityComponentManager &_ecm) const
Get the light diffuse color.
void ResetEntity(gazebo::Entity _newEntity)
Reset Entity to a new one.
std::optional< gazebo::Entity > Parent(const EntityComponentManager &_ecm) const
Get the parent entity. This can be a world or a link.
Component< gz::math::Pose3d, class PoseTag > Pose
A component type that contains pose, gz::math::Pose3d, information.
Definition: gz/sim/components/Pose.hh:35
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
const Entity kNullEntity
Indicates a non-existant or invalid Entity.
Definition: gz/sim/Entity.hh:61
std::optional< math::Angle > SpotInnerAngle(const EntityComponentManager &_ecm) const
Get the inner angle of light. Applies to spot lights only.
void SetSpotFalloff(EntityComponentManager &_ecm, double _falloff)
Set fall off value for this light. Applies to spot lights only.
std::optional< bool > CastShadows(const EntityComponentManager &_ecm) const
Get whether the light casts shadows.
std::optional< double > AttenuationLinear(const EntityComponentManager &_ecm) const
Get the light attenuation linear value. Light attenuation is not applicable to directional lights.
gazebo::Entity Entity() const
Get the entity which this Light is related to.
void SetAttenuationLinear(EntityComponentManager &_ecm, double _value)
Set attenuation linear value of this light.
Component< bool, class CastShadowsTag > CastShadows
A component used to indicate that an entity casts shadows e.g. visual entities.
Definition: gz/sim/components/CastShadows.hh:34
void SetAttenuationRange(EntityComponentManager &_ecm, double _range)
Set attenuation range of this light.
std::optional< std::string > Name(const EntityComponentManager &_ecm) const
Get the light's unscoped name.
std::optional< math::Pose3d > Pose(const EntityComponentManager &_ecm) const
Get the pose of the light. The pose is given w.r.t the light's parent. which can be a world or a link...
std::optional< double > AttenuationRange(const EntityComponentManager &_ecm) const
Get the light attenuation range. Light attenuation is not applicable to directional lights.
void SetDiffuseColor(EntityComponentManager &_ecm, const math::Color &_color)
Set the diffuse color of this light.
void SetPose(EntityComponentManager &_ecm, const math::Pose3d &_pose)
Set the pose of this light.
bool Valid(const EntityComponentManager &_ecm) const
Check whether this light correctly refers to an entity that has a components::Light.
void SetIntensity(EntityComponentManager &_ecm, double _value)
Set light intensity.
Component< std::string, class NameTag, serializers::StringSerializer > Name
This component holds an entity's name. The component has no concept of scoped names nor does it care ...
Definition: gz/sim/components/Name.hh:37
void SetSpotOuterAngle(EntityComponentManager &_ecm, const math::Angle &_angle)
Set outer angle for this light. Applies to spot lights only.