19 #define _USE_MATH_DEFINES
38 #define DEG2RAD M_PI/180.0
48 m_info =
"LaserFromDepth device";
49 m_device_status = DEVICE_OK_STANBY;
58 if (this->parseConfiguration(config) ==
false)
65 if(!config.check(
"RGBD_SENSOR_CLIENT"))
70 prop.
fromString(config.findGroup(
"RGBD_SENSOR_CLIENT").toString());
71 prop.
put(
"device",
"RGBDSensorClient");
74 if (!driver.isValid())
86 m_depth_width = iRGBD->getDepthWidth();
87 m_depth_height = iRGBD->getDepthHeight();
90 iRGBD->getDepthFOV(hfov, vfov);
91 m_sensorsNum = m_depth_width;
92 m_resolution = hfov / m_depth_width;
93 m_laser_data.resize(m_sensorsNum, 0.0);
94 m_max_angle = +hfov / 2;
95 m_min_angle = -hfov / 2;
96 PeriodicThread::start();
104 PeriodicThread::stop();
115 std::lock_guard<std::mutex> guard(m_mutex);
116 m_min_distance = min;
117 m_max_distance = max;
123 std::lock_guard<std::mutex> guard(m_mutex);
130 std::lock_guard<std::mutex> guard(m_mutex);
137 std::lock_guard<std::mutex> guard(m_mutex);
157 std::lock_guard<std::mutex> guard(m_mutex);
159 iRGBD->getDepthImage(m_depth_image);
160 if (m_depth_image.getRawImage()==
nullptr)
166 if (m_depth_image.width()!=m_depth_width ||
167 m_depth_image.height()!=m_depth_height)
174 auto* pointer = (
float*)m_depth_image.getPixelAddress(0, m_depth_height / 2);
175 double angle, distance, angleShift;
177 angleShift = m_sensorsNum * m_resolution / 2;
179 for (
size_t elem = 0; elem < m_sensorsNum; elem++)
181 angle = elem * m_resolution;
183 distance = *(pointer + elem);
184 distance /= cos((angle - angleShift) *
DEG2RAD);
185 m_laser_data[m_sensorsNum - 1 - elem] = distance;
187 applyLimitsOnLaserData();
void run() override
Loop function.
bool close() override
Close the DeviceDriver.
bool setScanLimits(double min, double max) override
set the scan angular range.
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
void threadRelease() override
Release method.
bool threadInit() override
Initialization method.
bool setDistanceRange(double min, double max) override
set the device detection range.
bool setHorizontalResolution(double step) override
get the angular step between two measurments (if available)
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
const yarp::os::LogComponent & LASER_FROM_DEPTH()
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
double now()
Return the current time in seconds, relative to an arbitrary starting point.
The main, catch-all namespace for YARP.