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 (C) 2012-2014 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 /* 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 "gazebo/math/Angle.hh"
30 #include "gazebo/math/Pose.hh"
32 #include "gazebo/sensors/Sensor.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 
77  // Documentation inherited
78  public: virtual std::string GetTopic() const;
79 
83  {return this->laserCam;}
84 
87  public: math::Angle GetAngleMin() const;
88 
91  public: void SetAngleMin(double _angle);
92 
95  public: math::Angle GetAngleMax() const;
96 
99  public: void SetAngleMax(double _angle);
100 
102  public: double GetAngleResolution() const;
103 
106  public: double GetRangeMin() const;
107 
110  public: double GetRangeMax() const;
111 
119  public: double GetRangeResolution() const;
120 
123  public: int GetRayCount() const;
124 
127  public: int GetRangeCount() const;
128 
131  public: int GetVerticalRayCount() const;
132 
135  public: int GetVerticalRangeCount() const;
136 
139  public: math::Angle GetVerticalAngleMin() const;
140 
143  public: void SetVerticalAngleMin(double _angle);
144 
147  public: math::Angle GetVerticalAngleMax() const;
148 
151  public: void SetVerticalAngleMax(double _angle);
152 
162  public: double GetRange(int _index);
163 
166  public: void GetRanges(std::vector<double> &_ranges);
167 
177  public: double GetRetro(int _index) const;
178 
188  public: int GetFiducial(int _index) const;
189 
192  public: unsigned int GetCameraCount() const;
193 
196  public: bool IsHorizontal() const;
197 
204  public: double GetRayCountRatio() const;
205 
212  public: double GetRangeCountRatio() const;
213 
216  public: double GetHorzFOV() const;
217 
220  public: double GetCosHorzFOV() const;
221 
223  public: double GetVertFOV() const;
224 
227  public: double GetCosVertFOV() const;
228 
231  public: double GetHorzHalfAngle() const;
232 
235  public: double GetVertHalfAngle() const;
236 
240  boost::function<void(const float *, unsigned int, unsigned int,
241  unsigned int, const std::string &)> _subscriber);
242 
245  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
246 
247  // Documentation inherited
248  public: virtual bool IsActive();
249 
251  protected: sdf::ElementPtr scanElem;
252 
254  protected: sdf::ElementPtr horzElem;
255 
257  protected: sdf::ElementPtr vertElem;
258 
260  protected: sdf::ElementPtr rangeElem;
261 
263  protected: sdf::ElementPtr cameraElem;
264 
266  protected: unsigned int horzRayCount;
267 
269  protected: unsigned int vertRayCount;
270 
272  protected: unsigned int horzRangeCount;
273 
275  protected: unsigned int vertRangeCount;
276 
278  protected: double rangeCountRatio;
279 
281  private: rendering::GpuLaserPtr laserCam;
282 
284  private: rendering::ScenePtr scene;
285 
287  private: boost::mutex mutex;
288 
290  private: msgs::LaserScanStamped laserMsg;
291 
293  private: physics::EntityPtr parentEntity;
294 
296  private: transport::PublisherPtr scanPub;
297 
298  // Which noise type we support
299  private: enum NoiseModelType
300  {
301  NONE,
302  GAUSSIAN
303  };
304 
305  // If true, apply the noise model specified by other noise parameters
306  private: bool noiseActive;
307 
308  // Which type of noise we're applying
309  private: enum NoiseModelType noiseType;
310 
311  // If noiseType==GAUSSIAN, noiseMean is the mean of the distibution
312  // from which we sample
313  private: double noiseMean;
314 
315  // If noiseType==GAUSSIAN, noiseStdDev is the standard devation of
316  // the distibution from which we sample
317  private: double noiseStdDev;
318  };
320  }
321 }
322 #endif