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 <sdf/sdf.hh>
23 
24 #include "gazebo/msgs/msgs.hh"
25 
26 #include "gazebo/transport/Node.hh"
28 
30 #include "gazebo/msgs/MessageTypes.hh"
32 #include "gazebo/util/system.hh"
33 
35 
36 namespace gazebo
37 {
40  namespace rendering
41  {
44 
45  // forward declarations
46  class WideAngleCamera;
47  class CameraLensPrivate;
48  class WideAngleCameraPrivate;
49 
54  {
56  public: CameraLens();
57 
59  public: virtual ~CameraLens();
60 
67  public: void Init(const double _c1, const double _c2,
68  const std::string &_fun, const double _f,
69  const double _c3);
70 
73  public: void Init(const std::string &_name);
74 
77  public: void Load(sdf::ElementPtr _sdf);
78 
80  public: void Load();
81 
84  public: std::string Type() const;
85 
88  public: bool IsCustom() const;
89 
92  public: double C1() const;
93 
96  public: double C2() const;
97 
100  public: double C3() const;
101 
104  public: double F() const;
105 
108  public: std::string Fun() const;
109 
112  public: double CutOffAngle() const;
113 
116  public: bool ScaleToHFOV() const;
117 
120  public: void SetType(const std::string &_type);
121 
124  public: void SetC1(const double _c);
125 
128  public: void SetC2(const double _c);
129 
132  public: void SetC3(const double _c);
133 
136  public: void SetF(const double _f);
137 
140  public: void SetFun(const std::string &_fun);
141 
144  public: void SetCutOffAngle(const double _angle);
145 
151  public: void SetScaleToHFOV(const bool _scale);
152 
158  public: void SetUniformVariables(Ogre::Pass *_pass, const float _ratio,
159  const float _hfov);
160 
163  private: void ConvertToCustom();
164 
167  private: std::unique_ptr<CameraLensPrivate> dataPtr;
168  };
169 
173  public Camera,
174  protected Ogre::CompositorInstance::Listener
175  {
182  public: WideAngleCamera(const std::string &_namePrefix, ScenePtr _scene,
183  const bool _autoRender = true,
184  const int _textureSize = 256);
185 
187  public: virtual ~WideAngleCamera();
188 
189  // Documentation inherited
190  public: void Init() override;
191 
192  // Documentation inherited
193  public: void Load() override;
194  using Camera::Load;
195 
196  // Documentation inherited
197  public: virtual void Fini() override;
198 
201  public: int EnvTextureSize() const;
202 
205  public: CameraLens *Lens() const;
206 
207  // Documentation inherited
208  public: void SetRenderTarget(Ogre::RenderTarget *_target) override;
209 
212  public: void SetEnvTextureSize(const int _size);
213 
215  protected: void CreateEnvCameras();
216 
217  // Documentation inherited
218  public: void SetClipDist() override;
219  using Camera::SetClipDist;
220 
221  // Documentation inherited
222  public: bool SetBackgroundColor(const ignition::math::Color &_color)
223  override;
224 
229  public: ignition::math::Vector3d Project3d(
230  const ignition::math::Vector3d &_pt) const;
231 
234  protected: void CreateEnvRenderTexture(const std::string &_textureName);
235 
236  // Documentation inherited
237  protected: void RenderImpl() override;
238 
239  // Documentation inherited
240  protected: void UpdateFOV() override;
241 
246  protected: void notifyMaterialRender(Ogre::uint32 _pass_id,
247  Ogre::MaterialPtr &_material) override;
248 
251  private: std::unique_ptr<WideAngleCameraPrivate> dataPtr;
252  };
254  }
255 }
256 #endif
Basic camera sensor.
Definition: Camera.hh:81
Camera with variable mapping function.
Definition: WideAngleCamera.hh:172
Describes a lens of a camera as amapping function of type r = c1*f*fun(theta/c2+c3) ...
Definition: WideAngleCamera.hh:53
virtual void Load()
Load the camera with default parmeters.
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