Ignition Sensors

API Reference

5.0.0
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 IGN_DEPRECATED(4) Update(
61  const ignition::common::Time &_now) override;
62 
66  public: virtual bool Update(
67  const std::chrono::steady_clock::duration &_now) override;
68 
72  public: virtual bool IGN_DEPRECATED(4) PublishLidarScan(
73  const ignition::common::Time &_now);
74 
78  public: void ApplyNoise();
79 
83  public: virtual bool PublishLidarScan(
84  const std::chrono::steady_clock::duration &_now);
85 
89  public: virtual bool Load(const sdf::Sensor &_sdf) override;
90 
94  public: virtual bool Load(sdf::ElementPtr _sdf) override;
95 
98  public: virtual bool Init() override;
99 
102  public: void SetParent(const std::string &_parent) override;
103 
105  public: virtual bool CreateLidar();
106 
108  protected: virtual void Fini();
109 
112  public: ignition::math::Angle AngleMin() const;
113 
116  public: void SetAngleMin(const double _angle);
117 
120  public: ignition::math::Angle AngleMax() const;
121 
124  public: void SetAngleMax(const double _angle);
125 
128  public: double AngleResolution() const;
129 
132  public: double RangeMin() const;
133 
136  public: double RangeMax() const;
137 
145  public: double RangeResolution() const;
146 
149  public: unsigned int RayCount() const;
150 
153  public: unsigned int RangeCount() const;
154 
157  public: unsigned int VerticalRayCount() const;
158 
161  public: unsigned int VerticalRangeCount() const;
162 
165  public: ignition::math::Angle VerticalAngleMin() const;
166 
169  public: void SetVerticalAngleMin(const double _angle);
170 
173  public: ignition::math::Angle VerticalAngleMax() const;
174 
177  public: void SetVerticalAngleMax(const double _angle);
178 
181  public: double VerticalAngleResolution() const;
182 
192  public: double Range(const int _index) const;
193 
196  public: void Ranges(std::vector<double> &_ranges) const;
197 
207  public: double Retro(const int _index) const;
208 
218  public: int Fiducial(const unsigned int _index) const;
219 
222  public: bool IsHorizontal() const;
223 
230  public: double RayCountRatio() const;
231 
238  public: double RangeCountRatio() const;
239 
242  public: double HorzFOV() const;
243 
246  public: double VertFOV() const;
247 
248  // Documentation inherited
249  public: virtual bool IsActive() const;
250 
251  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
253  public: mutable std::mutex lidarMutex;
254  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
255 
257  public: float *laserBuffer = nullptr;
258 
260  public: bool initialized = false;
261 
269  public: virtual ignition::common::ConnectionPtr ConnectNewLidarFrame(
270  std::function<void(const float *_scan, unsigned int _width,
271  unsigned int _heighti, unsigned int _channels,
272  const std::string &/*_format*/)> _subscriber);
273 
274  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
277  private: std::unique_ptr<LidarPrivate> dataPtr;
278  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
279  };
280  }
281  }
282 }
283 
284 #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:253
STL class.
Definition: AirPressureSensor.hh:32