6 #define _USE_MATH_DEFINES
18 #define DEG2RAD M_PI/180.0
25 std::lock_guard<std::mutex> guard(m_mutex);
31 bool Lidar2DDeviceBase::getDistanceRange(
double& min,
double& max)
33 std::lock_guard<std::mutex> guard(m_mutex);
39 bool Lidar2DDeviceBase::getHorizontalResolution(
double& step)
41 std::lock_guard<std::mutex> guard(m_mutex);
48 std::lock_guard<std::mutex> guard(m_mutex);
49 status = m_device_status;
55 std::lock_guard<std::mutex> guard(m_mutex);
60 bool Lidar2DDeviceBase::getScanRate(
double& rate)
62 std::lock_guard<std::mutex> guard(m_mutex);
67 bool Lidar2DDeviceBase::getDeviceInfo(std::string& device_info)
69 std::lock_guard<std::mutex> guard(m_mutex);
74 bool Lidar2DDeviceBase::getLaserMeasurement(std::vector<LaserMeasurementData>& data)
76 std::lock_guard<std::mutex> guard(m_mutex);
80 size_t size = m_laser_data.size();
82 if (m_max_angle < m_min_angle) {
yCError(
LASER_BASE) <<
"getLaserMeasurement failed";
return false; }
83 double laser_angle_of_view = m_max_angle - m_min_angle;
84 for (
size_t i = 0; i < size; i++)
86 double angle = (i / double(size) * laser_angle_of_view + m_min_angle) *
DEG2RAD;
87 data[i].set_polar(m_laser_data[i], angle);
92 Lidar2DDeviceBase::Lidar2DDeviceBase() :
101 m_clip_max_enable(false),
102 m_clip_min_enable(false),
103 m_do_not_clip_and_allow_infinity_enable(true)
110 bool br = config.
check(
"SENSOR");
132 bool bs = config.
check(
"SKIP");
138 size_t s_mins = mins.
size();
139 size_t s_maxs = mins.
size();
140 if (s_mins == s_maxs && s_maxs > 1)
142 for (
size_t s = 1; s < s_maxs; s++)
147 if (range.
max >= 0 && range.
max <= 360 &&
148 range.
min >= 0 && range.
min <= 360 &&
210 bool Lidar2DDeviceBase::checkSkipAngle(
const double& angle,
double& distance)
214 if (angle > it_skip.min&& angle < it_skip.max)
216 distance = std::nan(
"");
230 if (std::isnan(distance)) {
233 if (checkSkipAngle(angle, distance)) {
241 distance = std::numeric_limits<double>::infinity();
253 distance = std::numeric_limits<double>::infinity();
267 std::lock_guard<std::mutex> guard(
m_mutex);
const yarp::os::LogComponent & LASER_BASE()
A generic interface for planar laser range finders.
The Lidar2DDeviceBase class.
virtual yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
yarp::os::Stamp m_timestamp
virtual bool updateLidarData()
This utility method calls in sequence: grabDataFromHW(), updateTimestamp and applyLimitsOnLaserData()...
virtual bool acquireDataFromHW()=0
This method should be implemented by the user, and contain the logic to grab data from the hardware.
virtual bool applyLimitsOnLaserData()
Apply the limits on the internally stored lidar measurements.
std::vector< Range_t > m_range_skip_vector
bool m_do_not_clip_and_allow_infinity_enable
virtual bool updateTimestamp()
By default, it automatically updates the internal timestamp with the yarp time.
bool parseConfiguration(yarp::os::Searchable &config)
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.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
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.