6#define _USE_MATH_DEFINES
18#define DEG2RAD M_PI/180.0
25 std::lock_guard<std::mutex> guard(m_mutex);
31bool Lidar2DDeviceBase::getDistanceRange(
double& min,
double& max)
33 std::lock_guard<std::mutex> guard(
m_mutex);
41 std::lock_guard<std::mutex> guard(
m_mutex);
48 std::lock_guard<std::mutex> guard(
m_mutex);
55 std::lock_guard<std::mutex> guard(
m_mutex);
57 if (timestamp !=
nullptr)
66 std::lock_guard<std::mutex> guard(
m_mutex);
73 std::lock_guard<std::mutex> guard(
m_mutex);
80 std::lock_guard<std::mutex> guard(
m_mutex);
88 for (
size_t i = 0; i < size; i++)
93 if (timestamp!=
nullptr)
107 m_max_distance(30.0),
109 m_clip_max_enable(false),
110 m_clip_min_enable(false),
111 m_do_not_clip_and_allow_infinity_enable(true)
118 bool br = config.
check(
"SENSOR");
140 bool bs = config.
check(
"SKIP");
146 size_t s_mins = mins.
size();
147 size_t s_maxs = mins.
size();
148 if (s_mins == s_maxs && s_maxs > 1)
150 for (
size_t s = 1; s < s_maxs; s++)
155 if (range.
max >= 0 && range.
max <= 360 &&
156 range.
min >= 0 && range.
min <= 360 &&
218bool Lidar2DDeviceBase::checkSkipAngle(
const double& angle,
double& distance)
222 if (angle > it_skip.min&& angle < it_skip.max)
224 distance = std::nan(
"");
238 if (std::isnan(distance)) {
241 if (checkSkipAngle(angle, distance)) {
249 distance = std::numeric_limits<double>::infinity();
261 distance = std::numeric_limits<double>::infinity();
const yarp::os::LogComponent & LASER_BASE()
A generic interface for planar laser range finders.
The Lidar2DDeviceBase class.
bool getDeviceStatus(Device_status &status) override
get the device status
yarp::os::Stamp m_timestamp
bool getScanRate(double &rate) override
get the scan rate (scans per seconds)
bool getRawData(yarp::sig::Vector &data, double *timestamp=nullptr) override
Get the device measurements.
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.
bool getDeviceInfo(std::string &device_info) override
get the device hardware characteristics
std::vector< Range_t > m_range_skip_vector
bool m_do_not_clip_and_allow_infinity_enable
yarp::dev::IRangefinder2D::Device_status m_device_status
virtual bool updateTimestamp()
By default, it automatically updates the internal timestamp with the yarp time.
bool getHorizontalResolution(double &step) override
get the angular step between two measurements.
bool parseConfiguration(yarp::os::Searchable &config)
yarp::sig::Vector m_laser_data
bool getLaserMeasurement(std::vector< LaserMeasurementData > &data, double *timestamp=nullptr) override
Get the device measurements.
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 bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
double getTime() const
Get the time stamp.
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,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.