DepthCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 _GAZEBO_RENDERING_DEPTHCAMERA_HH_
19 #define _GAZEBO_RENDERING_DEPTHCAMERA_HH_
20 
21 #include <memory>
22 #include <string>
23 
24 #include <sdf/sdf.hh>
25 
27 
29 #include "gazebo/util/system.hh"
30 
31 namespace Ogre
32 {
33  class Material;
34  class RenderTarget;
35  class Texture;
36  class Viewport;
37 }
38 
39 namespace gazebo
40 {
41  namespace rendering
42  {
43  // Forward declare private data.
44  class DepthCameraPrivate;
45 
48 
51  class GZ_RENDERING_VISIBLE DepthCamera : public Camera
52  {
57  public: DepthCamera(const std::string &_namePrefix,
58  ScenePtr _scene, bool _autoRender = true);
59 
61  public: virtual ~DepthCamera();
62 
65  public: void Load(sdf::ElementPtr _sdf);
66 
68  public: void Load();
69 
71  public: void Init();
72 
74  public: void Fini();
75 
78  public: void CreateDepthTexture(const std::string &_textureName);
79 
81  public: virtual void PostRender();
82 
86  public: virtual const float *GetDepthData() GAZEBO_DEPRECATED(7.0);
87 
90  public: virtual const float *DepthData() const;
91 
94  public: virtual void SetDepthTarget(Ogre::RenderTarget *_target);
95 
99  public: event::ConnectionPtr ConnectNewDepthFrame(
100  std::function<void (const float *, unsigned int, unsigned int,
101  unsigned int, const std::string &)> _subscriber);
102 
105  public: void DisconnectNewDepthFrame(event::ConnectionPtr &_c);
106 
110  public: event::ConnectionPtr ConnectNewRGBPointCloud(
111  std::function<void (const float *, unsigned int, unsigned int,
112  unsigned int, const std::string &)> _subscriber);
113 
116  public: void DisconnectNewRGBPointCloud(event::ConnectionPtr &_c);
117 
119  private: virtual void RenderImpl();
120 
125  private: void UpdateRenderTarget(Ogre::RenderTarget *_target,
126  Ogre::Material *_material,
127  const std::string &_matName);
128 
130  protected: Ogre::Texture *depthTexture;
131 
133  protected: Ogre::RenderTarget *depthTarget;
134 
136  protected: Ogre::Viewport *depthViewport;
137 
140  private: std::unique_ptr<DepthCameraPrivate> dataPtr;
141  };
143  }
144 }
145 #endif
Basic camera sensor.
Definition: Camera.hh:85
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:48
Ogre::Texture * depthTexture
Pointer to the depth texture.
Definition: DepthCamera.hh:130
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
Ogre::RenderTarget * depthTarget
Pointer to the depth target.
Definition: DepthCamera.hh:133
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Ogre::Viewport * depthViewport
Pointer to the depth viewport.
Definition: DepthCamera.hh:136
Depth camera used to render depth data into an image buffer.
Definition: DepthCamera.hh:51