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();