GpuRaySensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 <ignition/math/Angle.hh>
30 #include <ignition/math/Pose3.hh>
31 
32 #include "gazebo/math/Angle.hh"
33 #include "gazebo/math/Pose.hh"
35 #include "gazebo/sensors/Sensor.hh"
37 #include "gazebo/util/system.hh"
38 
39 namespace gazebo
40 {
43  namespace sensors
44  {
48 
55  {
57  public: GpuRaySensor();
58 
60  public: virtual ~GpuRaySensor();
61 
65  public: virtual void Load(const std::string &_worldName,
66  sdf::ElementPtr _sdf);
67 
70  public: virtual void Load(const std::string &_worldName);
71 
73  public: virtual void Init();
74 
75  // Documentation inherited
76  protected: virtual bool UpdateImpl(bool _force);
77 
79  protected: virtual void Fini();
80 
81  // Documentation inherited
82  public: virtual std::string GetTopic() const;
83 
87  {return this->laserCam;}
88 
93  public: math::Angle GetAngleMin() const GAZEBO_DEPRECATED(6.0);
94 
97  public: ignition::math::Angle AngleMin() const;
98 
101  public: void SetAngleMin(double _angle);
102 
107  public: math::Angle GetAngleMax() const GAZEBO_DEPRECATED(6.0);
108 
111  public: ignition::math::Angle AngleMax() const;
112 
115  public: void SetAngleMax(double _angle);
116 
118  public: double GetAngleResolution() const;
119 
122  public: double GetRangeMin() const;
123 
126  public: double GetRangeMax() const;
127 
135  public: double GetRangeResolution() const;
136 
139  public: int GetRayCount() const;
140 
143  public: int GetRangeCount() const;
144 
147  public: int GetVerticalRayCount() const;
148 
151  public: int GetVerticalRangeCount() const;
152 
157  public: math::Angle GetVerticalAngleMin() const GAZEBO_DEPRECATED(6.0);
158 
161  public: ignition::math::Angle VerticalAngleMin() const;
162 
165  public: void SetVerticalAngleMin(double _angle);
166 
171  public: math::Angle GetVerticalAngleMax() const GAZEBO_DEPRECATED(6.0);
172 
175  public: ignition::math::Angle VerticalAngleMax() const;
176 
179  public: void SetVerticalAngleMax(double _angle);
180 
183  public: double GetVerticalAngleResolution() const;
184 
194  public: double GetRange(int _index);
195 
198  public: void GetRanges(std::vector<double> &_ranges);
199 
209  public: double GetRetro(int _index) const;
210 
220  public: int GetFiducial(int _index) const;
221 
224  public: unsigned int GetCameraCount() const;
225 
228  public: bool IsHorizontal() const;
229 
236  public: double GetRayCountRatio() const;
237 
244  public: double GetRangeCountRatio() const;
245 
248  public: double GetHorzFOV() const;
249 
252  public: double GetCosHorzFOV() const;
253 
255  public: double GetVertFOV() const;
256 
259  public: double GetCosVertFOV() const;
260 
263  public: double GetHorzHalfAngle() const;
264 
267  public: double GetVertHalfAngle() const;
268 
271  public: event::ConnectionPtr ConnectNewLaserFrame(
272  boost::function<void(const float *, unsigned int, unsigned int,
273  unsigned int, const std::string &)> _subscriber);
274 
277  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
278 
279  // Documentation inherited
280  public: virtual bool IsActive();
281 
283  private: void Render();
284 
286  protected: sdf::ElementPtr scanElem;
287 
289  protected: sdf::ElementPtr horzElem;
290 
292  protected: sdf::ElementPtr vertElem;
293 
295  protected: sdf::ElementPtr rangeElem;
296 
298  protected: sdf::ElementPtr cameraElem;
299 
301  protected: unsigned int horzRayCount;
302 
304  protected: unsigned int vertRayCount;
305 
307  protected: unsigned int horzRangeCount;
308 
310  protected: unsigned int vertRangeCount;
311 
313  protected: double rangeCountRatio;
314 
316  private: rendering::GpuLaserPtr laserCam;
317 
319  private: boost::mutex mutex;
320 
322  private: msgs::LaserScanStamped laserMsg;
323 
325  private: physics::EntityPtr parentEntity;
326 
328  private: transport::PublisherPtr scanPub;
329 
331  private: bool rendered;
332  };
334  }
335 }
336 #endif
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:147
GPU based laser sensor.
Definition: GpuRaySensor.hh:54
Forward declarations for transport.
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:47
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:76
boost::shared_ptr< GpuLaser > GpuLaserPtr
Definition: RenderTypes.hh:99
rendering::GpuLaserPtr GetLaserCamera() const
Returns a pointer to the internally kept rendering::GpuLaser.
Definition: GpuRaySensor.hh:86
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An angle and related functions.
Definition: Angle.hh:53
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Base class for sensors.
Definition: Sensor.hh:69
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66