Gazebo Sensors

API Reference

10.1.1
CpuLidarSensor.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 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_CPULIDARSENSOR_HH_
18#define GZ_SENSORS_CPULIDARSENSOR_HH_
19
20#include <utility>
21#include <vector>
22
23#include <sdf/Element.hh>
24#include <sdf/Sensor.hh>
25
26#include <gz/math/Angle.hh>
27#include <gz/math/Vector3.hh>
28#include <gz/utils/ImplPtr.hh>
29
30#include <gz/sensors/config.hh>
31#include <gz/sensors/cpu_lidar/Export.hh>
32
33#include "gz/sensors/Sensor.hh"
34
35namespace gz
36{
37 namespace sensors
38 {
39 inline namespace GZ_SENSORS_VERSION_NAMESPACE {
40
43 class GZ_SENSORS_CPU_LIDAR_VISIBLE CpuLidarSensor : public Sensor
44 {
46 public: struct RayResult
47 {
49 gz::math::Vector3d point;
50
54 double fraction;
55
57 gz::math::Vector3d normal;
58
60 double intensity = 0.0;
61 };
63 public: CpuLidarSensor();
64
66 public: virtual ~CpuLidarSensor();
67
71 public: virtual bool Load(const sdf::Sensor &_sdf) override;
72
76 public: virtual bool Load(sdf::ElementPtr _sdf) override;
77
78 using Sensor::Update;
79
83 public: virtual bool Update(
84 const std::chrono::steady_clock::duration &_now) override;
85
88 public: virtual bool HasConnections() const override;
89
91 public: gz::math::Angle AngleMin() const;
92
94 public: gz::math::Angle AngleMax() const;
95
97 public: gz::math::Angle VerticalAngleMin() const;
98
100 public: gz::math::Angle VerticalAngleMax() const;
101
103 public: double RangeMin() const;
104
106 public: double RangeMax() const;
107
109 public: unsigned int RayCount() const;
110
112 public: unsigned int VerticalRayCount() const;
113
118
121 public: void SetRaycastResults(
122 const std::vector<RayResult> &_results);
123
126 public: void Ranges(std::vector<double> &_ranges) const;
127
128 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
129 };
130 }
131 }
132}
133
134#endif