Gazebo Rendering

API Reference

8.2.1
OgreDepthCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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_RENDERING_OGRE_OGREDEPTHCAMERA_HH_
19 #define GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_
20 
21 #ifdef _WIN32
22  // Ensure that Winsock2.h is included before Windows.h, which can get
23  // pulled in by anybody (e.g., Boost).
24  #include <Winsock2.h>
25 #endif
26 
27 #include <memory>
28 #include <string>
29 
40 
41 #include "gz/common/Event.hh"
42 #include "gz/common/Console.hh"
43 
44 
45 namespace Ogre
46 {
47  class Material;
48  class RenderTarget;
49  class Texture;
50  class Viewport;
51 }
52 
53 namespace gz
54 {
55  namespace rendering
56  {
57  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
58  //
59  // forward declaration
60  class OgreDepthCameraPrivate;
61 
66  class GZ_RENDERING_OGRE_VISIBLE OgreDepthCamera :
67  public virtual BaseDepthCamera<OgreSensor>,
68  public virtual OgreObjectInterface
69  {
71  protected: OgreDepthCamera();
72 
74  public: virtual ~OgreDepthCamera();
75 
77  public: virtual void Init() override;
78 
80  public: virtual void CreateDepthTexture() override;
81 
84  protected: void DestroyDepthTexture();
85 
87  public: virtual void PostRender() override;
88 
91  public: virtual const float *DepthData() const override;
92 
97  std::function<void(const float *, unsigned int, unsigned int,
98  unsigned int, const std::string &)> _subscriber) override;
99 
104  std::function<void(const float *, unsigned int, unsigned int,
105  unsigned int, const std::string &)> _subscriber) override;
106 
107  // Documentation inherited.
108  public: virtual void PreRender() override;
109 
111  public: virtual void Render() override;
112 
115  public: virtual void SetFarClipPlane(const double _far) override;
116 
119  public: virtual void SetNearClipPlane(const double _near) override;
120 
124  public: double NearClipPlane() const override;
125 
129  public: double FarClipPlane() const override;
130 
131  // Documentation inherited
132  public: virtual void Destroy() override;
133 
134  // Documentation inherited.
135  public: virtual Ogre::Camera *Camera() const override;
136 
141  protected: void UpdateRenderTarget(OgreRenderTexturePtr _target,
142  Ogre::Material *_material,
143  const std::string &_matName);
144 
147  protected: virtual RenderTargetPtr RenderTarget() const override;
148 
153  protected: static double LimitFOV(const double _fov);
154 
156  protected: void CreateCamera();
157 
159  private: void CreatePointCloudTexture();
160 
163  protected: void DestroyPointCloudTexture();
164 
166  protected: bool newData = false;
167 
168  protected: bool captureData = false;
169 
172 
174  protected: Ogre::Viewport *depthViewport = nullptr;
175 
177  protected: Ogre::Camera *ogreCamera;
178 
182 
183  private: friend class OgreScene;
184  private: friend class OgreRayQuery;
185  };
186  }
187  }
188 }
189 #endif