Ignition Sensors

API Reference

6.0.1
Lidar.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 IGNITION_SENSORS_LIDAR_HH_
18 #define IGNITION_SENSORS_LIDAR_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/common/SuppressWarning.hh>
25 #include <ignition/common/Event.hh>
26 
27 #include "ignition/sensors/lidar/Export.hh"
29 
30 namespace ignition
31 {
32  namespace sensors
33  {
34  // Inline bracket to help doxygen filtering.
35  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
36  //
38  class LidarPrivate;
39 
49  class IGNITION_SENSORS_LIDAR_VISIBLE Lidar : public RenderingSensor
50  {
52  public: Lidar();
53 
55  public: virtual ~Lidar();
56 
60  public: virtual bool Update(
61  const std::chrono::steady_clock::duration &_now) override;
62 
66  public: void ApplyNoise();
67 
71  public: virtual bool PublishLidarScan(
72  const std::chrono::steady_clock::duration &_now);
73 
77  public: virtual bool Load(const sdf::Sensor &_sdf) override;
78 
82  public: virtual bool Load(sdf::ElementPtr _sdf) override;
83 
86  public: virtual bool Init() override;
87 
90  public: void SetParent(const std::string &_parent) override;
91 
93  public: virtual bool CreateLidar();
94 
96  protected: virtual void Fini();
97 
100  public: ignition::math::Angle AngleMin() const;
101 
104  public: void SetAngleMin(const double _angle);
105 
108  public: ignition::math::Angle AngleMax() const;
109 
112  public: void SetAngleMax(const double _angle);
113 
116  public: double AngleResolution() const;
117 
120  public: double RangeMin() const;
121 
124  public: double RangeMax() const;
125 
133  public: double RangeResolution() const;
134 
137  public: unsigned int RayCount() const;
138 
141  public: unsigned int RangeCount() const;
142 
145  public: unsigned int VerticalRayCount() const;
146 
149  public: unsigned int VerticalRangeCount() const;
150 
153  public: ignition::math::Angle VerticalAngleMin() const;
154 
157  public: void SetVerticalAngleMin(const double _angle);
158 
161  public: ignition::math::Angle VerticalAngleMax() const;
162 
165  public: void SetVerticalAngleMax(const double _angle);
166 
169  public: double VerticalAngleResolution() const;
170 
180  public: double Range(const int _index) const;
181 
184  public: void Ranges(std::vector<double> &_ranges) const;
185 
195  public: double Retro(const int _index) const;
196 
206  public: int Fiducial(const unsigned int _index) const;
207 
210  public: bool IsHorizontal() const;
211 
218  public: double RayCountRatio() const;
219 
226  public: double RangeCountRatio() const;
227 
230  public: double HorzFOV() const;
231 
234  public: double VertFOV() const;
235 
236  // Documentation inherited
237  public: virtual bool IsActive() const;
238 
239  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
241  public: mutable std::mutex lidarMutex;
242  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
243 
245  public: float *laserBuffer = nullptr;
246 
248  public: bool initialized = false;
249 
257  public: virtual ignition::common::ConnectionPtr ConnectNewLidarFrame(
258  std::function<void(const float *_scan, unsigned int _width,
259  unsigned int _heighti, unsigned int _channels,
260  const std::string &/*_format*/)> _subscriber);
261 
262  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
265  private: std::unique_ptr<LidarPrivate> dataPtr;
266  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
267  };
268  }
269  }
270 }
271 
272 #endif
a rendering sensor class
Definition: RenderingSensor.hh:52
Lidar Sensor Class.
Definition: Lidar.hh:49
STL class.
std::mutex lidarMutex
Just a mutex for thread safety.
Definition: Lidar.hh:241
STL class.
Definition: AirPressureSensor.hh:31