WideAngleCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 GAZEBO_RENDERING_WIDEANGLECAMERA_HH_
18 #define GAZEBO_RENDERING_WIDEANGLECAMERA_HH_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include <sdf/sdf.hh>
25 
26 #include "gazebo/msgs/msgs.hh"
27 
28 #include "gazebo/transport/Node.hh"
30 
32 #include "gazebo/msgs/MessageTypes.hh"
34 #include "gazebo/util/system.hh"
35 
37 
38 namespace gazebo
39 {
42  namespace rendering
43  {
46 
47  // forward declarations
48  class WideAngleCamera;
49  class CameraLensPrivate;
50  class WideAngleCameraPrivate;
51 
56  {
58  public: CameraLens();
59 
61  public: virtual ~CameraLens();
62 
69  public: void Init(const double _c1, const double _c2,
70  const std::string &_fun, const double _f,
71  const double _c3);
72 
75  public: void Init(const std::string &_name);
76 
79  public: void Load(sdf::ElementPtr _sdf);
80 
82  public: void Load();
83 
86  public: std::string Type() const;
87 
90  public: bool IsCustom() const;
91 
94  public: double C1() const;
95 
98  public: double C2() const;
99 
102  public: double C3() const;
103 
106  public: double F() const;
107 
110  public: std::string Fun() const;
111 
114  public: double CutOffAngle() const;
115 
118  public: bool ScaleToHFOV() const;
119 
122  public: void SetType(const std::string &_type);
123 
126  public: void SetC1(const double _c);
127 
130  public: void SetC2(const double _c);
131 
134  public: void SetC3(const double _c);
135 
138  public: void SetF(const double _f);
139 
142  public: void SetFun(const std::string &_fun);
143 
146  public: void SetCutOffAngle(const double _angle);
147 
153  public: void SetScaleToHFOV(const bool _scale);
154 
160  public: void SetUniformVariables(Ogre::Pass *_pass, const float _ratio,
161  const float _hfov);
162 
165  private: void ConvertToCustom();
166 
169  private: std::unique_ptr<CameraLensPrivate> dataPtr;
170  };
171 
175  public Camera,
176  protected Ogre::CompositorInstance::Listener
177  {
184  public: WideAngleCamera(const std::string &_namePrefix, ScenePtr _scene,
185  const bool _autoRender = true,
186  const int _textureSize = 256);
187 
189  public: virtual ~WideAngleCamera();
190 
191  // Documentation inherited
192  public: void Init() override;
193 
194  // Documentation inherited
195  public: void Load() override;
196  using Camera::Load;
197 
198  // Documentation inherited
199  public: virtual void Fini() override;
200 
203  public: int EnvTextureSize() const;
204 
207  public: CameraLens *Lens() const;
208 
209  // Documentation inherited
210  public: void SetRenderTarget(Ogre::RenderTarget *_target) override;
211 
214  public: void SetEnvTextureSize(const int _size);
215 
217  protected: void CreateEnvCameras();
218 
219  // Documentation inherited
220  public: void SetClipDist() override;
221  using Camera::SetClipDist;
222 
223  // Documentation inherited
224  public: bool SetBackgroundColor(const ignition::math::Color &_color)
225  override;
226 
231  public: ignition::math::Vector3d Project3d(
232  const ignition::math::Vector3d &_pt) const;
233 
237  public: std::vector<Ogre::Camera *> OgreEnvCameras() const;
238 
241  protected: void CreateEnvRenderTexture(const std::string &_textureName);
242 
243  // Documentation inherited
244  protected: void RenderImpl() override;
245 
246  // Documentation inherited
247  protected: void UpdateFOV() override;
248 
253  protected: void notifyMaterialRender(Ogre::uint32 _pass_id,
254  Ogre::MaterialPtr &_material) override;
255 
258  private: std::unique_ptr<WideAngleCameraPrivate> dataPtr;
259  };
261  }
262 }
263 #endif
Basic camera sensor.
Definition: Camera.hh:84
Camera with variable mapping function.
Definition: WideAngleCamera.hh:174
Forward declarations for the common classes.
Definition: Animation.hh:26
Describes a lens of a camera as amapping function of type r = c1*f*fun(theta/c2+c3) ...
Definition: WideAngleCamera.hh:55
virtual void Load()
Load the camera with default parameters.
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
virtual void SetClipDist()
Set the clip distance based on stored SDF values.
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