GpuLaser.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-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 #ifndef _GAZEBO_RENDERING_GPULASER_HH_
18 #define _GAZEBO_RENDERING_GPULASER_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <sdf/sdf.hh>
24 
29 #include "gazebo/util/system.hh"
30 
31 namespace Ogre
32 {
33  class Material;
34  class Renderable;
35  class Pass;
36  class AutoParamDataSource;
37  class Matrix4;
38  class MovableObject;
39 }
40 
41 namespace gazebo
42 {
43  namespace common
44  {
45  class Mesh;
46  }
47 
48  namespace rendering
49  {
50  // Forward declare private data.
51  class GpuLaserPrivate;
52 
55 
59  : public Camera, public Ogre::RenderObjectListener
60  {
65  public: GpuLaser(const std::string &_namePrefix,
66  ScenePtr _scene, const bool _autoRender = true);
67 
69  public: virtual ~GpuLaser();
70 
71  // Documentation inherited
72  public: virtual void Load(sdf::ElementPtr _sdf);
73 
74  // Documentation inherited
75  public: virtual void Load();
76 
77  // Documentation inherited
78  public: virtual void Init();
79 
80  // Documentation inherited
81  public: virtual void Fini();
82 
85  public: void CreateLaserTexture(const std::string &_textureName);
86 
87  // Documentation inherited
88  public: virtual void PostRender();
89 
93  public: const float *GetLaserData() GAZEBO_DEPRECATED(7.0);
94 
97  public: const float *LaserData() const;
98 
103  public: event::ConnectionPtr ConnectNewLaserFrame(
104  std::function<void (const float *_frame, unsigned int _width,
105  unsigned int _height, unsigned int _depth,
106  const std::string &_format)> _subscriber);
107 
110  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_c);
111 
115  public: void SetRangeCount(const unsigned int _w,
116  const unsigned int _h = 1);
117 
120  public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend,
121  const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s,
122  const Ogre::LightList *_ll, bool _supp);
123 
127  public: double GetHorzHalfAngle() const GAZEBO_DEPRECATED(7.0);
128 
131  public: double HorzHalfAngle() const;
132 
136  public: double GetVertHalfAngle() const GAZEBO_DEPRECATED(7.0);
137 
140  public: double VertHalfAngle() const;
141 
144  public: void SetHorzHalfAngle(const double _angle);
145 
148  public: void SetVertHalfAngle(const double _angle);
149 
152  public: void SetIsHorizontal(const bool _horizontal);
153 
156  public: bool IsHorizontal() const;
157 
161  public: double GetHorzFOV() const GAZEBO_DEPRECATED(7.0);
162 
165  public: double HorzFOV() const;
166 
170  public: double GetCosHorzFOV() const GAZEBO_DEPRECATED(7.0);
171 
174  public: double CosHorzFOV() const;
175 
178  public: void SetCosHorzFOV(const double _chfov);
179 
183  public: double GetVertFOV() const GAZEBO_DEPRECATED(7.0);
184 
187  public: double VertFOV() const;
188 
192  public: double GetCosVertFOV() const GAZEBO_DEPRECATED(7.0);
193 
196  public: double CosVertFOV() const;
197 
200  public: void SetCosVertFOV(const double _cvfov);
201 
205  public: double GetNearClip() const GAZEBO_DEPRECATED(7.0);
206 
209  public: double NearClip() const;
210 
214  public: double GetFarClip() const GAZEBO_DEPRECATED(7.0);
215 
218  public: double FarClip() const;
219 
222  public: void SetNearClip(const double _near);
223 
226  public: void SetFarClip(const double _far);
227 
230  public: void SetHorzFOV(const double _hfov);
231 
234  public: void SetVertFOV(const double _vfov);
235 
239  public: double GetCameraCount() const GAZEBO_DEPRECATED(7.0);
240 
243  public: unsigned int CameraCount() const;
244 
248  public: void SetCameraCount(const unsigned int _cameraCount);
249 
253  public: double GetRayCountRatio() const GAZEBO_DEPRECATED(7.0);
254 
257  public: double RayCountRatio() const;
258 
261  public: void SetRayCountRatio(const double _rayCountRatio);
262 
263  // Documentation inherited.
264  private: virtual void RenderImpl();
265 
271  private: void UpdateRenderTarget(Ogre::RenderTarget *_target,
272  Ogre::Material *_material,
273  Ogre::Camera *_cam,
274  const bool _updateTex = false);
275 
277  private: void CreateOrthoCam();
278 
280  private: void CreateMesh();
281 
283  private: void CreateCanvas();
284 
293  private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left,
294  const float _right, const float _bottom, const float _top,
295  const float _near, const float _far);
296 
300  private: virtual void Set1stPassTarget(Ogre::RenderTarget *_target,
301  const unsigned int _index);
302 
305  private: virtual void Set2ndPassTarget(Ogre::RenderTarget *_target);
306 
308  protected: double horzHalfAngle;
309 
311  protected: double vertHalfAngle;
312 
314  protected: double rayCountRatio;
315 
317  protected: double hfov;
318 
320  protected: double vfov;
321 
323  protected: double chfov;
324 
326  protected: double cvfov;
327 
329  protected: double nearClip;
330 
332  protected: double farClip;
333 
335  protected: bool isHorizontal;
336 
338  protected: unsigned int cameraCount;
339 
342  private: std::unique_ptr<GpuLaserPrivate> dataPtr;
343  };
345  }
346 }
347 #endif
Basic camera sensor.
Definition: Camera.hh:85
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
GPU based laser distance sensor.
Definition: GpuLaser.hh:58
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:48
double rayCountRatio
Ray count ratio.
Definition: GpuLaser.hh:314
double vertHalfAngle
Vertical half angle.
Definition: GpuLaser.hh:311
unsigned int cameraCount
Number of cameras needed to generate the rays.
Definition: GpuLaser.hh:338
double farClip
Far clip plane.
Definition: GpuLaser.hh:332
double nearClip
Near clip plane.
Definition: GpuLaser.hh:329
#define GZ_RENDERING_VISIBLE
Definition: system.hh:209
double hfov
Horizontal field-of-view.
Definition: GpuLaser.hh:317
double horzHalfAngle
Horizontal half angle.
Definition: GpuLaser.hh:308
double cvfov
Cos vertical field-of-view.
Definition: GpuLaser.hh:326
double chfov
Cos horizontal field-of-view.
Definition: GpuLaser.hh:323
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
bool isHorizontal
True if the sensor is horizontal only.
Definition: GpuLaser.hh:335
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
double vfov
Vertical field-of-view.
Definition: GpuLaser.hh:320