GpuRaySensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 #ifndef _GAZEBO_SENSORS_GPURAYSENSOR_HH_
18 #define _GAZEBO_SENSORS_GPURAYSENSOR_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/math/Angle.hh>
25 #include <ignition/math/Pose3.hh>
26 
28 #include "gazebo/sensors/Sensor.hh"
30 #include "gazebo/util/system.hh"
31 
32 namespace gazebo
33 {
36  namespace sensors
37  {
38  // Forward declare private data pointer.
39  class GpuRaySensorPrivate;
40 
44 
50  class GZ_SENSORS_VISIBLE GpuRaySensor: public Sensor
51  {
53  public: GpuRaySensor();
54 
56  public: virtual ~GpuRaySensor();
57 
61  public: virtual void Load(const std::string &_worldName,
62  sdf::ElementPtr _sdf) override;
63 
66  public: virtual void Load(const std::string &_worldName) override;
67 
69  public: virtual void Init() override;
70 
72  protected: void ResetLastUpdateTime() override;
73 
76  protected: bool NeedsUpdate() override;
77 
80  public: void Update(bool _force) override;
81 
84  public: double NextRequiredTimestamp() const override;
85 
86  // Documentation inherited
87  protected: virtual bool UpdateImpl(const bool _force) override;
88 
90  protected: virtual void Fini() override;
91 
92  // Documentation inherited
93  public: virtual std::string Topic() const override;
94 
97  public: void SetActive(bool _value) override;
98 
102 
105  public: ignition::math::Angle AngleMin() const;
106 
109  public: void SetAngleMin(const double _angle);
110 
113  public: ignition::math::Angle AngleMax() const;
114 
117  public: void SetAngleMax(const double _angle);
118 
121  public: double AngleResolution() const;
122 
125  public: double RangeMin() const;
126 
129  public: double RangeMax() const;
130 
138  public: double RangeResolution() const;
139 
142  public: int RayCount() const;
143 
146  public: int RangeCount() const;
147 
150  public: int VerticalRayCount() const;
151 
154  public: int VerticalRangeCount() const;
155 
158  public: ignition::math::Angle VerticalAngleMin() const;
159 
162  public: void SetVerticalAngleMin(const double _angle);
163 
166  public: ignition::math::Angle VerticalAngleMax() const;
167 
170  public: void SetVerticalAngleMax(const double _angle);
171 
174  public: double VerticalAngleResolution() const;
175 
185  public: double Range(const int _index) const;
186 
189  public: void Ranges(std::vector<double> &_ranges) const;
190 
200  public: double Retro(const int _index) const;
201 
211  public: int Fiducial(const unsigned int _index) const;
212 
215  public: unsigned int CameraCount() const;
216 
219  public: bool IsHorizontal() const;
220 
227  public: double RayCountRatio() const;
228 
235  public: double RangeCountRatio() const;
236 
239  public: double HorzFOV() const;
240 
243  public: double CosHorzFOV() const;
244 
247  public: double VertFOV() const;
248 
251  public: double CosVertFOV() const;
252 
255  public: double HorzHalfAngle() const;
256 
259  public: double VertHalfAngle() const;
260 
264  std::function<void(const float *, unsigned int, unsigned int,
265  unsigned int, const std::string &)> _subscriber);
266 
267  // Documentation inherited
268  public: virtual bool IsActive() const override;
269 
271  private: void Render();
272 
274  private: void PrerenderEnded();
275 
278  private: std::unique_ptr<GpuRaySensorPrivate> dataPtr;
279  };
281  }
282 }
283 #endif
virtual bool IsActive() const override
Returns true if sensor generation is active.
int RayCount() const
Get the ray count.
virtual ~GpuRaySensor()
Destructor.
double RangeMin() const
Get the minimum range.
double Retro(const int _index) const
Get detected retro (intensity) value for a ray.
event::ConnectionPtr ConnectNewLaserFrame(std::function< void(const float *, unsigned int, unsigned int, unsigned int, const std::string &)> _subscriber)
Connect to the new laser frame event.
double HorzHalfAngle() const
Get (horizontal_max_angle + horizontal_min_angle) * 0.5.
Forward declarations for the common classes.
Definition: Animation.hh:27
void Update(bool _force) override
Update the sensor.
boost::shared_ptr< GpuLaser > GpuLaserPtr
Definition: RenderTypes.hh:106
double VertFOV() const
Get the vertical field-of-view.
sensors
Definition: SensorManager.hh:37
int VerticalRangeCount() const
Get the vertical scan line count.
void ResetLastUpdateTime() override
reset timing related members
Forward declarations for transport.
void SetActive(bool _value) override
Set whether the sensor is active or not.
double HorzFOV() const
Get the horizontal field of view of the laser sensor.
void SetVerticalAngleMin(const double _angle)
Set the vertical scan bottom angle.
double NextRequiredTimestamp() const override
Return the next timestamp going to be used by the sensor.
virtual bool UpdateImpl(const bool _force) override
This gets overwritten by derived sensor types.
virtual void Init() override
Initialize the ray.
double CosHorzFOV() const
Get Cos Horz field-of-view.
ignition::math::Angle VerticalAngleMax() const
Get the vertical scan line top angle.
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf) override
Load the sensor with SDF parameters.
double Range(const int _index) const
Get detected range for a ray.
int Fiducial(const unsigned int _index) const
Get detected fiducial value for a ray.
ignition::math::Angle VerticalAngleMin() const
Get the vertical scan bottom angle.
double RangeResolution() const
Get the range resolution If RangeResolution is 1, the number of simulated rays is equal to the number...
GPU based laser sensor.
Definition: GpuRaySensor.hh:51
virtual void Fini() override
Finalize the ray.
ignition::math::Angle AngleMax() const
Get the maximum angle.
int VerticalRayCount() const
Get the vertical scan line count.
virtual std::string Topic() const override
Returns the topic name as set in SDF.
bool IsHorizontal() const
Gets if sensor is horizontal.
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
double CosVertFOV() const
Get Cos Vert field-of-view.
double VertHalfAngle() const
Get (vertical_max_angle + vertical_min_angle) * 0.5.
rendering::GpuLaserPtr LaserCamera() const
Returns a pointer to the internally kept rendering::GpuLaser.
void SetAngleMin(const double _angle)
Set the scan minimum angle.
void SetVerticalAngleMax(const double _angle)
Set the vertical scan line top angle.
GpuRaySensor()
Constructor.
Base class for sensors.
Definition: Sensor.hh:53
double VerticalAngleResolution() const
Get the vertical angle in radians between each range.
void SetAngleMax(const double _angle)
Set the scan maximum angle.
double RayCountRatio() const
Return the ratio of horizontal ray count to vertical ray count.
virtual void Load(const std::string &_worldName) override
Load the sensor with default parameters.
double AngleResolution() const
Get radians between each range.
double RangeCountRatio() const
Return the ratio of horizontal range count to vertical range count.
int RangeCount() const
Get the range count.
double RangeMax() const
Get the maximum range.
void Ranges(std::vector< double > &_ranges) const
Get all the ranges.
unsigned int CameraCount() const
Gets the camera count.
ignition::math::Angle AngleMin() const
Get the minimum angle.
bool NeedsUpdate() override
Return true if the sensor needs to be updated.