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 
149  public: void SetScaleToHFOV(const bool _scale);
150 
156  public: void SetUniformVariables(Ogre::Pass *_pass, const float _ratio,
157  const float _hfov);
158 
161  private: void ConvertToCustom();
162 
165  private: std::unique_ptr<CameraLensPrivate> dataPtr;
166  };
167 
171  public Camera,
172  protected Ogre::CompositorInstance::Listener
173  {
180  public: WideAngleCamera(const std::string &_namePrefix, ScenePtr _scene,
181  const bool _autoRender = true,
182  const int _textureSize = 256);
183 
185  public: virtual ~WideAngleCamera();
186 
187  // Documentation inherited
188  public: void Init() override;
189 
190  // Documentation inherited
191  public: void Load() override;
192  using Camera::Load;
193 
194  // Documentation inherited
195  public: virtual void Fini() override;
196 
199  public: int EnvTextureSize() const;
200 
203  public: CameraLens *Lens() const;
204 
205  // Documentation inherited
206  public: void SetRenderTarget(Ogre::RenderTarget *_target) override;
207 
210  public: void SetEnvTextureSize(const int _size);
211 
213  protected: void CreateEnvCameras();
214 
215  // Documentation inherited
216  public: void SetClipDist() override;
217  using Camera::SetClipDist;
218 
219  // Documentation inherited
220  public: bool SetBackgroundColor(const common::Color &_color) override;
221 
224  protected: void CreateEnvRenderTexture(const std::string &_textureName);
225 
226  // Documentation inherited
227  protected: void RenderImpl() override;
228 
229  // Documentation inherited
230  protected: void UpdateFOV() override;
231 
236  protected: void notifyMaterialRender(Ogre::uint32 _pass_id,
237  Ogre::MaterialPtr &_material) override;
238 
241  private: std::unique_ptr<WideAngleCameraPrivate> dataPtr;
242  };
244  }
245 }
246 #endif
Basic camera sensor.
Definition: Camera.hh:80
Camera with variable mapping function.
Definition: WideAngleCamera.hh:170
Forward declarations for the common classes.
Definition: Animation.hh:33
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:81
virtual void SetClipDist()
Set the clip distance based on stored SDF values.
Defines a color.
Definition: Color.hh:35
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:58