Ignition Sensors

API Reference

3.1.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/Event.hh>
25 
26 #include "ignition/sensors/lidar/Export.hh"
28 
29 namespace ignition
30 {
31  namespace sensors
32  {
33  // Inline bracket to help doxygen filtering.
34  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
35  //
37  class LidarPrivate;
38 
48  class IGNITION_SENSORS_LIDAR_VISIBLE Lidar : public RenderingSensor
49  {
51  public: Lidar();
52 
54  public: virtual ~Lidar();
55 
59  public: virtual bool Update(const common::Time &_now) override;
60 
64  public: virtual bool PublishLidarScan(const common::Time &_now);
65 
69  public: virtual bool Load(const sdf::Sensor &_sdf) override;
70 
74  public: virtual bool Load(sdf::ElementPtr _sdf) override;
75 
78  public: virtual bool Init() override;
79 
82  public: void SetParent(const std::string &_parent) override;
83 
85  public: virtual bool CreateLidar();
86 
88  protected: virtual void Fini();
89 
92  public: ignition::math::Angle AngleMin() const;
93 
96  public: void SetAngleMin(const double _angle);
97 
100  public: ignition::math::Angle AngleMax() const;
101 
104  public: void SetAngleMax(const double _angle);
105 
108  public: double AngleResolution() const;
109 
112  public: double RangeMin() const;
113 
116  public: double RangeMax() const;
117 
125  public: double RangeResolution() const;
126 
129  public: unsigned int RayCount() const;
130 
133  public: unsigned int RangeCount() const;
134 
137  public: unsigned int VerticalRayCount() const;
138 
141  public: unsigned int VerticalRangeCount() const;
142 
145  public: ignition::math::Angle VerticalAngleMin() const;
146 
149  public: void SetVerticalAngleMin(const double _angle);
150 
153  public: ignition::math::Angle VerticalAngleMax() const;
154 
157  public: void SetVerticalAngleMax(const double _angle);
158 
161  public: double VerticalAngleResolution() const;
162 
172  public: double Range(const int _index) const;
173 
176  public: void Ranges(std::vector<double> &_ranges) const;
177 
187  public: double Retro(const int _index) const;
188 
198  public: int Fiducial(const unsigned int _index) const;
199 
202  public: bool IsHorizontal() const;
203 
210  public: double RayCountRatio() const;
211 
218  public: double RangeCountRatio() const;
219 
222  public: double HorzFOV() const;
223 
226  public: double VertFOV() const;
227 
228  // Documentation inherited
229  public: virtual bool IsActive() const;
230 
232  public: mutable std::mutex lidarMutex;
233 
235  public: float *laserBuffer = nullptr;
236 
238  public: bool initialized = false;
239 
247  public: virtual ignition::common::ConnectionPtr ConnectNewLidarFrame(
248  std::function<void(const float *_scan, unsigned int _width,
249  unsigned int _heighti, unsigned int _channels,
250  const std::string &/*_format*/)> _subscriber);
251 
254  private: std::unique_ptr<LidarPrivate> dataPtr;
255  };
256  }
257  }
258 }
259 
260 #endif
a rendering sensor class
Definition: RenderingSensor.hh:42
Lidar Sensor Class.
Definition: Lidar.hh:48
STL class.
std::mutex lidarMutex
Just a mutex for thread safety.
Definition: Lidar.hh:232
STL class.
Definition: AirPressureSensor.hh:31