Gazebo Sensors

API Reference

8.2.1
GpuLidarSensor.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 GZ_SENSORS_GPULIDARSENSOR_HH_
18 #define GZ_SENSORS_GPULIDARSENSOR_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <sdf/sdf.hh>
24 
25 #include <gz/utils/SuppressWarning.hh>
26 
27 // TODO(louise) Remove these pragmas once gz-rendering is disabling the
28 // warnings
29 #ifdef _WIN32
30 #pragma warning(push)
31 #pragma warning(disable: 4251)
32 #endif
33 #include <gz/rendering/GpuRays.hh>
34 #ifdef _WIN32
35 #pragma warning(pop)
36 #endif
37 
38 #include "gz/sensors/gpu_lidar/Export.hh"
40 #include "gz/sensors/Lidar.hh"
41 
42 namespace gz
43 {
44  namespace sensors
45  {
46  // Inline bracket to help doxygen filtering.
47  inline namespace GZ_SENSORS_VERSION_NAMESPACE {
48  //
50  class GpuLidarSensorPrivate;
51 
61  class GZ_SENSORS_GPU_LIDAR_VISIBLE GpuLidarSensor : public Lidar
62  {
64  public: GpuLidarSensor();
65 
67  public: virtual ~GpuLidarSensor();
68 
72  public: virtual bool Update(
73  const std::chrono::steady_clock::duration &_now) override;
74 
77  public: virtual bool Init() override;
78 
82  public: virtual bool Load(const sdf::Sensor &_sdf) override;
83 
87  public: virtual bool Load(sdf::ElementPtr _sdf) override;
88 
90  public: virtual bool CreateLidar() override;
91 
94  public: bool IsHorizontal() const;
95 
98  public: void SetScene(gz::rendering::ScenePtr _scene) override;
99 
102  public: void RemoveGpuRays(gz::rendering::ScenePtr _scene);
103 
106  public: gz::rendering::GpuRaysPtr GpuRays() const;
107 
114  public: double RayCountRatio() const;
115 
118  public: gz::math::Angle HFOV() const;
119 
122  public: gz::math::Angle VFOV() const;
123 
126  public: virtual bool HasConnections() const override;
127 
130  public: virtual gz::common::ConnectionPtr ConnectNewLidarFrame(
131  std::function<void(const float *_scan, unsigned int _width,
132  unsigned int _heighti, unsigned int _channels,
133  const std::string &/*_format*/)> _subscriber) override;
134 
137  private: void OnNewLidarFrame(const float *_scan, unsigned int _width,
138  unsigned int _heighti, unsigned int _channels,
139  const std::string &_format);
140 
141  GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
145  GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
146  };
147  }
148  }
149 }
150 
151 #endif