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 #include "gazebo/util/system.hh"
35 
36 namespace gazebo
37 {
40  namespace sensors
41  {
51  {
53  public: GpuRaySensor();
54 
56  public: virtual ~GpuRaySensor();
57 
61  public: virtual void Load(const std::string &_worldName,
62  sdf::ElementPtr _sdf);
63 
66  public: virtual void Load(const std::string &_worldName);
67 
69  public: virtual void Init();
70 
71  // Documentation inherited
72  protected: virtual bool 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 
155  public: double GetVerticalAngleResolution() const;
156 
166  public: double GetRange(int _index);
167 
170  public: void GetRanges(std::vector<double> &_ranges);
171 
181  public: double GetRetro(int _index) const;
182 
192  public: int GetFiducial(int _index) const;
193 
196  public: unsigned int GetCameraCount() const;
197 
200  public: bool IsHorizontal() const;
201 
208  public: double GetRayCountRatio() const;
209 
216  public: double GetRangeCountRatio() const;
217 
220  public: double GetHorzFOV() const;
221 
224  public: double GetCosHorzFOV() const;
225 
227  public: double GetVertFOV() const;
228 
231  public: double GetCosVertFOV() const;
232 
235  public: double GetHorzHalfAngle() const;
236 
239  public: double GetVertHalfAngle() const;
240 
243  public: event::ConnectionPtr ConnectNewLaserFrame(
244  boost::function<void(const float *, unsigned int, unsigned int,
245  unsigned int, const std::string &)> _subscriber);
246 
249  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
250 
251  // Documentation inherited
252  public: virtual bool IsActive();
253 
255  private: void Render();
256 
258  protected: sdf::ElementPtr scanElem;
259 
261  protected: sdf::ElementPtr horzElem;
262 
264  protected: sdf::ElementPtr vertElem;
265 
267  protected: sdf::ElementPtr rangeElem;
268 
270  protected: sdf::ElementPtr cameraElem;
271 
273  protected: unsigned int horzRayCount;
274 
276  protected: unsigned int vertRayCount;
277 
279  protected: unsigned int horzRangeCount;
280 
282  protected: unsigned int vertRangeCount;
283 
285  protected: double rangeCountRatio;
286 
288  private: rendering::GpuLaserPtr laserCam;
289 
291  private: boost::mutex mutex;
292 
294  private: msgs::LaserScanStamped laserMsg;
295 
297  private: physics::EntityPtr parentEntity;
298 
300  private: transport::PublisherPtr scanPub;
301 
303  private: bool rendered;
304  };
306  }
307 }
308 #endif