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
void SetEnvTextureSize(const int _size)
Sets environment texture size.
void SetF(const double _f)
Sets f parameter.
ignition::math::Vector3d Project3d(const ignition::math::Vector3d &_pt) const
Project 3D world coordinates to screen coordinates.
void SetClipDist() override
Set the clip distance based on stored SDF values.
std::string Type() const
Get lens projection type.
void SetC2(const double _c)
Sets c2 parameter.
double C2() const
Gets c2 parameter.
bool ScaleToHFOV() const
Checks if image should be scaled to fit horizontal FOV.
Forward declarations for the common classes.
Definition: Animation.hh:27
WideAngleCamera(const std::string &_namePrefix, ScenePtr _scene, const bool _autoRender=true, const int _textureSize=256)
Constructor.
virtual ~WideAngleCamera()
Destructor.
std::vector< Ogre::Camera * > OgreEnvCameras() const
Get the list of ogre cameras used to create the cube map for generating the wide angle camera image.
void Init(const std::string &_name)
Init camera lens with standard mapping function.
int EnvTextureSize() const
Gets the environment texture size.
void CreateEnvCameras()
Creates a set of 6 cameras pointing in different directions.
void Load(sdf::ElementPtr _sdf)
Load camera lens from SDF file.
void SetCutOffAngle(const double _angle)
Sets cut-off angle.
CameraLens()
Constructor.
bool SetBackgroundColor(const ignition::math::Color &_color) override
Set background color for viewport (if viewport is not null)
virtual void Fini() override
Finalize the camera.
void UpdateFOV() override
Update the camera's field of view.
Camera with variable mapping function.
Definition: WideAngleCamera.hh:177
double C1() const
Gets c1 parameter.
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
virtual ~CameraLens()
Destructor.
rendering
Definition: RenderEngine.hh:31
std::string Fun() const
Gets angle transform function.
void SetScaleToHFOV(const bool _scale)
Sets whether the image should be scaled to fit horizontal FOV If True, the projection will compute a ...
void SetType(const std::string &_type)
Set lens projection type.
Describes a lens of a camera as amapping function of type r = c1*f*fun(theta/c2+c3)
Definition: WideAngleCamera.hh:56
void Init(const double _c1, const double _c2, const std::string &_fun, const double _f, const double _c3)
Init custom camera lens with specified parameters.
void Load() override
Load the camera with default parameters.
void SetC3(const double _c)
Sets c3 parameter.
void notifyMaterialRender(Ogre::uint32 _pass_id, Ogre::MaterialPtr &_material) override
\bried Callback that is used to set mapping material uniform values, implements Ogre::CompositorInsta...
bool IsCustom() const
Checks if lens type is of the custom type.
CameraLens * Lens() const
Gets camera's lens description.
virtual void SetClipDist()
Set the clip distance based on stored SDF values.
void SetFun(const std::string &_fun)
Sets angle transform function.
virtual void Load()
Load the camera with default parameters.
void SetC1(const double _c)
Sets c1 parameter.
void CreateEnvRenderTexture(const std::string &_textureName)
Set the camera's render target.
double C3() const
Gets c3 parameter.
void RenderImpl() override
Implementation of the render call.
void SetRenderTarget(Ogre::RenderTarget *_target) override
Set the camera's render target.
double CutOffAngle() const
Gets cut off angle.
Basic camera sensor.
Definition: Camera.hh:86
void SetUniformVariables(Ogre::Pass *_pass, const float _ratio, const float _hfov)
Set uniform variables of a shader for the provided material technique pass.
double F() const
Gets f parameter.
void Init() override
Initialize the camera.
void Load()
Load camera lens with default parameters.
#define GAZEBO_VISIBLE
Definition: system.hh:59