9 #define _USE_MATH_DEFINES
22 #define DEG2RAD M_PI/180.0
29 std::lock_guard<std::mutex> guard(m_mutex);
35 bool Lidar2DDeviceBase::getDistanceRange(
double& min,
double& max)
37 std::lock_guard<std::mutex> guard(m_mutex);
43 bool Lidar2DDeviceBase::getHorizontalResolution(
double& step)
45 std::lock_guard<std::mutex> guard(m_mutex);
52 std::lock_guard<std::mutex> guard(m_mutex);
53 status = m_device_status;
59 std::lock_guard<std::mutex> guard(m_mutex);
64 bool Lidar2DDeviceBase::getScanRate(
double& rate)
66 std::lock_guard<std::mutex> guard(m_mutex);
71 bool Lidar2DDeviceBase::getDeviceInfo(std::string& device_info)
73 std::lock_guard<std::mutex> guard(m_mutex);
78 bool Lidar2DDeviceBase::getLaserMeasurement(std::vector<LaserMeasurementData>& data)
80 std::lock_guard<std::mutex> guard(m_mutex);
84 size_t size = m_laser_data.size();
86 if (m_max_angle < m_min_angle) {
yCError(
LASER_BASE) <<
"getLaserMeasurement failed";
return false; }
87 double laser_angle_of_view = m_max_angle - m_min_angle;
88 for (
size_t i = 0; i < size; i++)
90 double angle = (i / double(size) * laser_angle_of_view + m_min_angle) *
DEG2RAD;
91 data[i].set_polar(m_laser_data[i], angle);
96 Lidar2DDeviceBase::Lidar2DDeviceBase() :
103 m_max_distance(30.0),
105 m_clip_max_enable(false),
106 m_clip_min_enable(false),
107 m_do_not_clip_and_allow_infinity_enable(true)
114 bool br = config.
check(
"SENSOR");
136 bool bs = config.
check(
"SKIP");
142 size_t s_mins = mins.
size();
143 size_t s_maxs = mins.
size();
144 if (s_mins == s_maxs && s_maxs > 1)
146 for (
size_t s = 1; s < s_maxs; s++)
151 if (range.
max >= 0 && range.
max <= 360 &&
152 range.
min >= 0 && range.
min <= 360 &&
213 bool Lidar2DDeviceBase::checkSkipAngle(
const double& angle,
double& distance)
217 if (angle > it_skip.min&& angle < it_skip.max)
219 distance = std::nan(
"");
233 if (std::isnan(distance))
continue;
234 if (checkSkipAngle(angle, distance))
continue;
240 distance = std::numeric_limits<double>::infinity();
252 distance = std::numeric_limits<double>::infinity();