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/function.hpp>
28 #include <boost/thread/mutex.hpp>
29 
30 #include <ignition/math/Angle.hh>
31 #include <ignition/math/Pose3.hh>
32 
33 #include "gazebo/math/Angle.hh"
34 #include "gazebo/math/Pose.hh"
36 #include "gazebo/sensors/Sensor.hh"
38 #include "gazebo/util/system.hh"
39 
40 namespace gazebo
41 {
44  namespace sensors
45  {
49 
56  {
58  public: GpuRaySensor();
59 
61  public: virtual ~GpuRaySensor();
62 
66  public: virtual void Load(const std::string &_worldName,
67  sdf::ElementPtr _sdf);
68 
71  public: virtual void Load(const std::string &_worldName);
72 
74  public: virtual void Init();
75 
76  // Documentation inherited
77  protected: virtual bool UpdateImpl(bool _force);
78 
80  protected: virtual void Fini();
81 
82  // Documentation inherited
83  public: virtual std::string GetTopic() const;
84 
88  {return this->laserCam;}
89 
94  public: math::Angle GetAngleMin() const GAZEBO_DEPRECATED(6.0);
95 
98  public: ignition::math::Angle AngleMin() const;
99 
102  public: void SetAngleMin(double _angle);
103 
108  public: math::Angle GetAngleMax() const GAZEBO_DEPRECATED(6.0);
109 
112  public: ignition::math::Angle AngleMax() const;
113 
116  public: void SetAngleMax(double _angle);
117 
119  public: double GetAngleResolution() const;
120 
123  public: double GetRangeMin() const;
124 
127  public: double GetRangeMax() const;
128 
136  public: double GetRangeResolution() const;
137 
140  public: int GetRayCount() const;
141 
144  public: int GetRangeCount() const;
145 
148  public: int GetVerticalRayCount() const;
149 
152  public: int GetVerticalRangeCount() const;
153 
158  public: math::Angle GetVerticalAngleMin() const GAZEBO_DEPRECATED(6.0);
159 
162  public: ignition::math::Angle VerticalAngleMin() const;
163 
166  public: void SetVerticalAngleMin(double _angle);
167 
172  public: math::Angle GetVerticalAngleMax() const GAZEBO_DEPRECATED(6.0);
173 
176  public: ignition::math::Angle VerticalAngleMax() const;
177 
180  public: void SetVerticalAngleMax(double _angle);
181 
184  public: double GetVerticalAngleResolution() const;
185 
195  public: double GetRange(int _index);
196 
199  public: void GetRanges(std::vector<double> &_ranges);
200 
210  public: double GetRetro(int _index) const;
211 
221  public: int GetFiducial(int _index) const;
222 
225  public: unsigned int GetCameraCount() const;
226 
229  public: bool IsHorizontal() const;
230 
237  public: double GetRayCountRatio() const;
238 
245  public: double GetRangeCountRatio() const;
246 
249  public: double GetHorzFOV() const;
250 
253  public: double GetCosHorzFOV() const;
254 
256  public: double GetVertFOV() const;
257 
260  public: double GetCosVertFOV() const;
261 
264  public: double GetHorzHalfAngle() const;
265 
268  public: double GetVertHalfAngle() const;
269 
272  public: event::ConnectionPtr ConnectNewLaserFrame(
273  boost::function<void(const float *, unsigned int, unsigned int,
274  unsigned int, const std::string &)> _subscriber);
275 
278  public: void DisconnectNewLaserFrame(event::ConnectionPtr &_conn);
279 
280  // Documentation inherited
281  public: virtual bool IsActive();
282 
284  private: void Render();
285 
287  protected: sdf::ElementPtr scanElem;
288 
290  protected: sdf::ElementPtr horzElem;
291 
293  protected: sdf::ElementPtr vertElem;
294 
296  protected: sdf::ElementPtr rangeElem;
297 
299  protected: sdf::ElementPtr cameraElem;
300 
302  protected: unsigned int horzRayCount;
303 
305  protected: unsigned int vertRayCount;
306 
308  protected: unsigned int horzRangeCount;
309 
311  protected: unsigned int vertRangeCount;
312 
314  protected: double rangeCountRatio;
315 
317  private: rendering::GpuLaserPtr laserCam;
318 
320  private: boost::mutex mutex;
321 
323  private: msgs::LaserScanStamped laserMsg;
324 
326  private: physics::EntityPtr parentEntity;
327 
329  private: transport::PublisherPtr scanPub;
330 
332  private: bool rendered;
333  };
335  }
336 }
337 #endif
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:147
GPU based laser sensor.
Definition: GpuRaySensor.hh:55
Definition: JointMaker.hh:41
Forward declarations for the common classes.
Definition: Animation.hh:33
Forward declarations for transport.
STL namespace.
#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:87
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An angle and related functions.
Definition: Angle.hh:53
Definition: Animation.hh:24
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