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 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 "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 
201  public: double GetRayCountRatio() const;
202 
209  public: double GetRangeCountRatio() const;
210 
213  public: double GetHorzFOV() const;
214 
217  public: double GetCosHorzFOV() const;
218 
220  public: double GetVertFOV() const;
221 
224  public: double GetCosVertFOV() const;
225 
228  public: double GetHorzHalfAngle() const;
229 
232  public: double GetVertHalfAngle() const;
233 
237  boost::function<void(const float *, unsigned int, unsigned int,
238  unsigned int, const std::string &)> _subscriber);
239 
242  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
243 
246 
249 
252 
255 
258 
260  protected: unsigned int cameraCount;
261 
263  protected: double hfov;
264 
266  protected: double vfov;
267 
269  protected: double chfov;
270 
272  protected: double cvfov;
273 
275  protected: double horzHalfAngle;
276 
278  protected: double vertHalfAngle;
279 
281  protected: double near;
282 
284  protected: double far;
285 
287  protected: unsigned int horzRayCount;
288 
290  protected: unsigned int vertRayCount;
291 
293  protected: unsigned int horzRangeCount;
294 
296  protected: unsigned int vertRangeCount;
297 
299  protected: double rayCountRatio;
300 
302  protected: double rangeCountRatio;
303 
305  protected: bool isHorizontal;
306 
308  private: rendering::GpuLaserPtr laserCam;
309 
311  private: rendering::ScenePtr scene;
312 
314  private: boost::mutex mutex;
315 
317  private: msgs::LaserScan laserMsg;
318  };
320  }
321 }
322 #endif