WideAngleCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-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_WIDEANGLECAMERA_HH_
19 #define _GAZEBO_RENDERING_WIDEANGLECAMERA_HH_
20 
21 
22 #include <string>
23 #include <utility>
24 #include <sdf/sdf.hh>
25 
26 #include "gazebo/msgs/msgs.hh"
27 
28 #include "gazebo/transport/Node.hh"
30 
31 #include "gazebo/math/Angle.hh"
32 #include "gazebo/math/Pose.hh"
33 
35 #include "gazebo/msgs/MessageTypes.hh"
37 #include "gazebo/util/system.hh"
38 
40 
41 
42 namespace gazebo
43 {
46  namespace rendering
47  {
50 
51  // forward declarations
52  class WideAngleCamera;
53  class CameraLensPrivate;
54  class WideAngleCameraPrivate;
55 
60  {
62  public: CameraLens();
63 
65  public: virtual ~CameraLens();
66 
73  public: void Init(const double _c1, const double _c2,
74  const std::string &_fun, const double _f,
75  const double _c3);
76 
79  public: void Init(const std::string &_name);
80 
83  public: void Load(sdf::ElementPtr _sdf);
84 
86  public: void Load();
87 
90  public: std::string Type() const;
91 
94  public: bool IsCustom() const;
95 
98  public: double C1() const;
99 
102  public: double C2() const;
103 
106  public: double C3() const;
107 
110  public: double F() const;
111 
114  public: std::string Fun() const;
115 
118  public: double CutOffAngle() const;
119 
122  public: bool ScaleToHFOV() const;
123 
126  public: void SetType(const std::string &_type);
127 
130  public: void SetC1(const double _c);
131 
134  public: void SetC2(const double _c);
135 
138  public: void SetC3(const double _c);
139 
142  public: void SetF(const double _f);
143 
146  public: void SetFun(const std::string &_fun);
147 
150  public: void SetCutOffAngle(const double _angle);
151 
155  public: void SetScaleToHFOV(const bool _scale);
156 
162  public: void SetUniformVariables(Ogre::Pass *_pass, const float _ratio,
163  const float _hfov);
164 
167  private: void ConvertToCustom();
168 
171  private: std::unique_ptr<CameraLensPrivate> dataPtr;
172  };
173 
177  public Camera,
178  protected Ogre::CompositorInstance::Listener
179  {
186  public: WideAngleCamera(const std::string &_namePrefix, ScenePtr _scene,
187  const bool _autoRender = true,
188  const int _textureSize = 256);
189 
191  public: virtual ~WideAngleCamera();
192 
193  // Documentation inherited
194  public: void Init() override;
195 
196  // Documentation inherited
197  public: void Load() override;
198  using Camera::Load;
199 
200  // Documentation inherited
201  public: virtual void Fini() override;
202 
205  public: int EnvTextureSize() const;
206 
209  public: CameraLens *Lens() const;
210 
211  // Documentation inherited
212  public: void SetRenderTarget(Ogre::RenderTarget *_target) override;
213 
216  public: void SetEnvTextureSize(const int _size);
217 
219  protected: void CreateEnvCameras();
220 
221  // Documentation inherited
222  public: void SetClipDist() override;
223 
226  protected: void CreateEnvRenderTexture(const std::string &_textureName);
227 
228  // Documentation inherited
229  protected: void RenderImpl() override;
230 
235  protected: void notifyMaterialRender(Ogre::uint32 _pass_id,
236  Ogre::MaterialPtr &_material) override;
237 
240  private: std::unique_ptr<WideAngleCameraPrivate> dataPtr;
241  };
243  }
244 }
245 
246 
247 #endif
Basic camera sensor.
Definition: Camera.hh:85
Camera with variable mapping function.
Definition: WideAngleCamera.hh:176
Describes a lens of a camera as amapping function of type r = c1*f*fun(theta/c2+c3) ...
Definition: WideAngleCamera.hh:59
virtual void Load()
Load the camera with default parmeters.
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59