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();
const yarp::os::LogComponent & LASER_BASE()
A generic interface for planar laser range finders.
The DLidarDeviceTemplate class.
std::vector< Range_t > m_range_skip_vector
bool m_do_not_clip_and_allow_infinity_enable
bool parseConfiguration(yarp::os::Searchable &config)
void applyLimitsOnLaserData()
yarp::sig::Vector m_laser_data
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
void resize(size_t size) override
Resize the vector.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.