All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GpuRaySensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 /* Desc: RaySensor proximity sensor
18  * Author: Mihai Emanuel Dolha
19  * Date: 29 March 2012
20 */
21 
22 #ifndef _GPURAYSENSOR_HH_
23 #define _GPURAYSENSOR_HH_
24 
25 #include <vector>
26 #include <string>
27 #include <boost/thread/mutex.hpp>
28 
29 #include "math/Angle.hh"
30 #include "math/Pose.hh"
32 #include "sensors/Sensor.hh"
33 #include "rendering/RenderTypes.hh"
34 
35 namespace gazebo
36 {
39  namespace sensors
40  {
49  class GpuRaySensor: public Sensor
50  {
52  public: GpuRaySensor();
53 
55  public: virtual ~GpuRaySensor();
56 
60  public: virtual void Load(const std::string &_worldName,
61  sdf::ElementPtr &_sdf);
62 
65  public: virtual void Load(const std::string &_worldName);
66 
68  public: virtual void Init();
69 
72  protected: virtual void UpdateImpl(bool _force);
73 
75  protected: virtual void Fini();
76 
80  {return this->laserCam;}
81 
84  public: math::Angle GetAngleMin() const;
85 
88  public: void SetAngleMin(double _angle);
89 
92  public: math::Angle GetAngleMax() const;
93 
96  public: void SetAngleMax(double _angle);
97 
99  public: double GetAngleResolution() const;
100 
103  public: double GetRangeMin() const;
104 
107  public: double GetRangeMax() const;
108 
116  public: double GetRangeResolution() const;
117 
120  public: int GetRayCount() const;
121 
124  public: int GetRangeCount() const;
125 
128  public: int GetVerticalRayCount() const;
129 
132  public: int GetVerticalRangeCount() const;
133 
136  public: math::Angle GetVerticalAngleMin() const;
137 
140  public: void SetVerticalAngleMin(double _angle);
141 
144  public: math::Angle GetVerticalAngleMax() const;
145 
148  public: void SetVerticalAngleMax(double _angle);
149 
159  public: double GetRange(int _index);
160 
163  public: void GetRanges(std::vector<double> &_ranges) const;
164 
174  public: double GetRetro(int _index) const;
175 
185  public: int GetFiducial(int _index) const;
186 
189  public: unsigned int GetCameraCount() const;
190 
193  public: bool IsHorizontal() const;
194 
197  public: double Get1stRatio() const GAZEBO_DEPRECATED;
198 
205  public: double GetRayCountRatio() const;
206 
209  public: double Get2ndRatio() const GAZEBO_DEPRECATED;
210 
217  public: double GetRangeCountRatio() const;
218 
221  public: double GetHFOV() const GAZEBO_DEPRECATED;
222 
225  public: double GetHorzFOV() const;
226 
228  public: double GetCHFOV() const GAZEBO_DEPRECATED;
229 
232  public: double GetCosHorzFOV() const;
233 
236  public: double GetVFOV() const GAZEBO_DEPRECATED;
237 
239  public: double GetVertFOV() const;
240 
243  public: double GetCVFOV() const GAZEBO_DEPRECATED;
244 
247  public: double GetCosVertFOV() const;
248 
251  public: double GetHAngle() const GAZEBO_DEPRECATED;
252 
255  public: double GetHorzHalfAngle() const;
256 
259  public: double GetVAngle() const GAZEBO_DEPRECATED;
260 
263  public: double GetVertHalfAngle() const;
264 
267  public: event::ConnectionPtr ConnectNewLaserFrame(
268  boost::function<void(const float *, unsigned int, unsigned int,
269  unsigned int, const std::string &)> _subscriber);
270 
273  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
274 
276  protected: sdf::ElementPtr scanElem;
277 
279  protected: sdf::ElementPtr horzElem;
280 
282  protected: sdf::ElementPtr vertElem;
283 
285  protected: sdf::ElementPtr rangeElem;
286 
288  protected: sdf::ElementPtr cameraElem;
289 
291  protected: unsigned int cameraCount;
292 
294  protected: double hfov;
295 
297  protected: double vfov;
298 
300  protected: double chfov;
301 
303  protected: double cvfov;
304 
306  protected: double horzHalfAngle;
307 
309  protected: double vertHalfAngle;
310 
312  protected: double near;
313 
315  protected: double far;
316 
318  protected: unsigned int horzRayCount;
319 
321  protected: unsigned int vertRayCount;
322 
324  protected: unsigned int horzRangeCount;
325 
327  protected: unsigned int vertRangeCount;
328 
330  protected: double rayCountRatio;
331 
333  protected: double rangeCountRatio;
334 
336  protected: bool isHorizontal;
337 
339  private: rendering::GpuLaserPtr laserCam;
340 
342  private: rendering::ScenePtr scene;
343 
345  private: boost::mutex mutex;
346 
348  private: msgs::LaserScan laserMsg;
349  };
351  }
352 }
353 #endif