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: ~CameraLens() = default;
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 
199  // Documentation inherited
200  public: virtual void Fini() override;
201 
204  public: int EnvTextureSize() const;
205 
208  public: CameraLens *Lens() const;
209 
210  // Documentation inherited
211  public: void SetRenderTarget(Ogre::RenderTarget *_target) override;
212 
215  public: void SetEnvTextureSize(const int _size);
216 
218  protected: void CreateEnvCameras();
219 
220  // Documentation inherited
221  public: void SetClipDist() override;
222 
225  protected: void CreateEnvRenderTexture(const std::string &_textureName);
226 
227  // Documentation inherited
228  protected: void RenderImpl() override;
229 
234  protected: void notifyMaterialRender(Ogre::uint32 _pass_id,
235  Ogre::MaterialPtr &_material) override;
236 
239  private: std::unique_ptr<WideAngleCameraPrivate> dataPtr;
240  };
242  }
243 }
244 
245 
246 #endif
Basic camera sensor.
Definition: Camera.hh:85
Camera with variable mapping function.
Definition: WideAngleCamera.hh:176
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:59
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