|
23 | 23 |
|
24 | 24 | using namespace std::chrono_literals;
|
25 | 25 | using namespace std::placeholders;
|
| 26 | +using namespace yarp::dev; |
26 | 27 |
|
27 | 28 | YARP_LOG_COMPONENT(RGBDSENSOR_NWC_ROS2, "yarp.ros2.RgbdSensor_nwc_ros2", yarp::os::Log::TraceType);
|
28 | 29 |
|
@@ -168,172 +169,185 @@ int RgbdSensor_nwc_ros2::getRgbWidth()
|
168 | 169 | return m_current_rgb_image.width();
|
169 | 170 | }
|
170 | 171 |
|
171 |
| -bool RgbdSensor_nwc_ros2::getRgbSupportedConfigurations(yarp::sig::VectorOf<yarp::dev::CameraConfig> &configurations) |
| 172 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbSupportedConfigurations(std::vector<yarp::dev::CameraConfig> &configurations) |
172 | 173 | {
|
173 | 174 | yCWarning(RGBDSENSOR_NWC_ROS2) << "getRgbSupportedConfigurations not implemented yet";
|
174 |
| - return false; |
| 175 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
175 | 176 | }
|
176 | 177 |
|
177 |
| -bool RgbdSensor_nwc_ros2::getRgbResolution(int &width, int &height) |
| 178 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbResolution(int &width, int &height) |
178 | 179 | {
|
179 | 180 | if (!m_rgb_image_valid)
|
180 | 181 | {
|
181 | 182 | width=0;
|
182 | 183 | height=0;
|
183 |
| - return false; |
| 184 | + return ReturnValue::return_code::return_value_error_not_ready; |
184 | 185 | }
|
185 | 186 | width = m_current_rgb_image.width();
|
186 | 187 | height = m_current_rgb_image.height();
|
187 |
| - return true; |
| 188 | + return ReturnValue_ok; |
| 189 | +} |
| 190 | + |
| 191 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthResolution(int &width, int &height) |
| 192 | +{ |
| 193 | + if (!m_rgb_image_valid) |
| 194 | + { |
| 195 | + width=0; |
| 196 | + height=0; |
| 197 | + return ReturnValue::return_code::return_value_error_not_ready; |
| 198 | + } |
| 199 | + width = m_current_depth_image.width(); |
| 200 | + height = m_current_depth_image.height(); |
| 201 | + return ReturnValue_ok; |
188 | 202 | }
|
189 | 203 |
|
190 |
| -bool RgbdSensor_nwc_ros2::setDepthResolution(int width, int height) |
| 204 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setDepthResolution(int width, int height) |
191 | 205 | {
|
192 | 206 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setDepthResolution not supported";
|
193 |
| - return false; |
| 207 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
194 | 208 | }
|
195 | 209 |
|
196 |
| -bool RgbdSensor_nwc_ros2::setRgbResolution(int width, int height) |
| 210 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setRgbResolution(int width, int height) |
197 | 211 | {
|
198 | 212 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setRgbResolution not supported";
|
199 |
| - return false; |
| 213 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
200 | 214 | }
|
201 | 215 |
|
202 |
| -bool RgbdSensor_nwc_ros2::setRgbFOV(double horizontalFov, double verticalFov) |
| 216 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setRgbFOV(double horizontalFov, double verticalFov) |
203 | 217 | {
|
204 | 218 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setRgbFOV not supported";
|
205 |
| - return false; |
| 219 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
206 | 220 | }
|
207 | 221 |
|
208 |
| -bool RgbdSensor_nwc_ros2::setDepthFOV(double horizontalFov, double verticalFov) |
| 222 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setDepthFOV(double horizontalFov, double verticalFov) |
209 | 223 | {
|
210 | 224 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setDepthFOV not supported";
|
211 |
| - return false; |
| 225 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
212 | 226 | }
|
213 | 227 |
|
214 |
| -bool RgbdSensor_nwc_ros2::setDepthAccuracy(double accuracy) |
| 228 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setDepthAccuracy(double accuracy) |
215 | 229 | {
|
216 | 230 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setDepthAccuracy not supported";
|
217 |
| - return false; |
| 231 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
218 | 232 | }
|
219 | 233 |
|
220 | 234 | // not sure that it is correct, maybe I should save the full image dimension
|
221 |
| -bool RgbdSensor_nwc_ros2::getRgbFOV(double &horizontalFov, double &verticalFov) |
| 235 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbFOV(double &horizontalFov, double &verticalFov) |
222 | 236 | {
|
223 | 237 | if (!m_rgb_image_valid && ! m_rgb_stamp_valid)
|
224 | 238 | {
|
225 | 239 | horizontalFov=0;
|
226 | 240 | verticalFov=0;
|
227 |
| - return false; |
| 241 | + return ReturnValue::return_code::return_value_error_not_ready; |
228 | 242 | yCError(RGBDSENSOR_NWC_ROS2) << "get rgb IntrinsicParam missing information";
|
229 | 243 | }
|
230 | 244 | horizontalFov = 2 * atan(m_max_rgb_width / (2 * m_rgb_params.focalLengthX)) * 180.0 / M_PI;
|
231 | 245 | verticalFov = 2 * atan(m_max_rgb_height / (2 * m_rgb_params.focalLengthY)) * 180.0 / M_PI;
|
232 |
| - return true; |
| 246 | + return ReturnValue_ok; |
233 | 247 | }
|
234 | 248 |
|
235 | 249 |
|
236 |
| -bool RgbdSensor_nwc_ros2::getRgbMirroring(bool& mirror) |
| 250 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbMirroring(bool& mirror) |
237 | 251 | {
|
238 | 252 | yCWarning(RGBDSENSOR_NWC_ROS2) << "Mirroring not supported";
|
239 |
| - return false; |
| 253 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
240 | 254 | }
|
241 | 255 |
|
242 |
| -bool RgbdSensor_nwc_ros2::setRgbMirroring(bool mirror) |
| 256 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setRgbMirroring(bool mirror) |
243 | 257 | {
|
244 | 258 | yCWarning(RGBDSENSOR_NWC_ROS2) << "Mirroring not supported";
|
245 |
| - return false; |
| 259 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
246 | 260 | }
|
247 | 261 |
|
248 |
| -bool RgbdSensor_nwc_ros2::getRgbIntrinsicParam(yarp::os::Property& intrinsic) |
| 262 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbIntrinsicParam(yarp::os::Property& intrinsic) |
249 | 263 | {
|
250 | 264 | if (m_rgb_stamp_valid)
|
251 | 265 | {
|
252 | 266 | intrinsic.clear();
|
253 | 267 | m_rgb_params.toProperty(intrinsic);
|
254 |
| - return true; |
| 268 | + return ReturnValue_ok; |
255 | 269 | }
|
256 |
| - return false; |
| 270 | + return ReturnValue::return_code::return_value_error_not_ready; |
257 | 271 | }
|
258 | 272 |
|
259 |
| -int RgbdSensor_nwc_ros2::getDepthHeight() |
| 273 | +int RgbdSensor_nwc_ros2::getDepthHeight() |
260 | 274 | {
|
261 | 275 | if (!m_depth_image_valid) return 0;
|
262 | 276 | return m_current_depth_image.height();
|
263 | 277 | }
|
264 | 278 |
|
265 |
| -int RgbdSensor_nwc_ros2::getDepthWidth() |
| 279 | +int RgbdSensor_nwc_ros2::getDepthWidth() |
266 | 280 | {
|
267 | 281 | if (!m_depth_image_valid) return 0;
|
268 | 282 | return m_current_depth_image.width();
|
269 | 283 | }
|
270 | 284 |
|
271 |
| -bool RgbdSensor_nwc_ros2::getDepthFOV(double& horizontalFov, double& verticalFov) |
| 285 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthFOV(double& horizontalFov, double& verticalFov) |
272 | 286 | {
|
273 | 287 | if (!m_depth_image_valid && !m_depth_stamp_valid)
|
274 | 288 | {
|
275 | 289 | horizontalFov=0;
|
276 | 290 | verticalFov=0;
|
277 |
| - return false; |
| 291 | + return ReturnValue::return_code::return_value_error_not_ready; |
278 | 292 | yCError(RGBDSENSOR_NWC_ROS2) << "get depth IntrinsicParam missing information";
|
279 | 293 | }
|
280 | 294 | horizontalFov = 2 * atan(m_max_rgb_width / (2 * m_depth_params.focalLengthX)) * 180.0 / M_PI;
|
281 | 295 | verticalFov = 2 * atan(m_max_rgb_height / (2 * m_depth_params.focalLengthY)) * 180.0 / M_PI;
|
282 |
| - return true; |
| 296 | + return ReturnValue_ok; |
283 | 297 | }
|
284 | 298 |
|
285 |
| -bool RgbdSensor_nwc_ros2::getDepthIntrinsicParam(yarp::os::Property& intrinsic) |
| 299 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthIntrinsicParam(yarp::os::Property& intrinsic) |
286 | 300 | {
|
287 | 301 | if(m_depth_stamp_valid)
|
288 | 302 | {
|
289 | 303 | intrinsic.clear();
|
290 | 304 | m_depth_params.toProperty(intrinsic);
|
291 |
| - return true; |
| 305 | + return ReturnValue_ok; |
292 | 306 | }
|
293 |
| - return false; |
| 307 | + return ReturnValue::return_code::return_value_error_not_ready; |
294 | 308 | }
|
295 | 309 |
|
296 |
| -double RgbdSensor_nwc_ros2::getDepthAccuracy() |
| 310 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthAccuracy(double& accuracy) |
297 | 311 | {
|
298 | 312 | yCWarning(RGBDSENSOR_NWC_ROS2) << "getDepthAccuracy not supported";
|
299 |
| - return 0; |
| 313 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
300 | 314 | }
|
301 | 315 |
|
302 |
| -bool RgbdSensor_nwc_ros2::getDepthClipPlanes(double& nearPlane, double& farPlane) |
| 316 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthClipPlanes(double& nearPlane, double& farPlane) |
303 | 317 | {
|
304 | 318 | yCWarning(RGBDSENSOR_NWC_ROS2) << "getDepthClipPlanes not supported";
|
305 |
| - return false; |
| 319 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
306 | 320 | }
|
307 | 321 |
|
308 |
| -bool RgbdSensor_nwc_ros2::setDepthClipPlanes(double nearPlane, double farPlane) |
| 322 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setDepthClipPlanes(double nearPlane, double farPlane) |
309 | 323 | {
|
310 | 324 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setDepthClipPlanes not supported";
|
311 |
| - return false; |
| 325 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
312 | 326 | }
|
313 | 327 |
|
314 |
| -bool RgbdSensor_nwc_ros2::getDepthMirroring(bool& mirror) |
| 328 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthMirroring(bool& mirror) |
315 | 329 | {
|
316 | 330 | yCWarning(RGBDSENSOR_NWC_ROS2) << "getDepthMirroring not supported";
|
317 |
| - return false; |
| 331 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
318 | 332 | }
|
319 | 333 |
|
320 |
| -bool RgbdSensor_nwc_ros2::setDepthMirroring(bool mirror) |
| 334 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::setDepthMirroring(bool mirror) |
321 | 335 | {
|
322 | 336 | yCWarning(RGBDSENSOR_NWC_ROS2) << "setDepthMirroring not supported";
|
323 |
| - return false; |
| 337 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
324 | 338 | }
|
325 | 339 |
|
326 |
| -bool RgbdSensor_nwc_ros2::getExtrinsicParam(yarp::sig::Matrix& extrinsic) |
| 340 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getExtrinsicParam(yarp::sig::Matrix& extrinsic) |
327 | 341 | {
|
328 | 342 | yCWarning(RGBDSENSOR_NWC_ROS2) << "getExtrinsicParam not supported";
|
329 |
| - return false; |
| 343 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
330 | 344 | }
|
331 | 345 |
|
332 | 346 |
|
333 | 347 | /*
|
334 | 348 | * TODO FIXME to update with header instead of stamp
|
335 | 349 | */
|
336 |
| -bool RgbdSensor_nwc_ros2::getRgbImage(yarp::sig::FlexImage& rgb_image, yarp::os::Stamp* rgb_image_stamp) |
| 350 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getRgbImage(yarp::sig::FlexImage& rgb_image, yarp::os::Stamp* rgb_image_stamp) |
337 | 351 | {
|
338 | 352 | std::lock_guard<std::mutex> guard_rgb_image(m_rgb_image_mutex);
|
339 | 353 | std::lock_guard<std::mutex> guard_rgb_camera_info(m_rgb_camera_info_mutex);
|
@@ -361,13 +375,14 @@ bool RgbdSensor_nwc_ros2::getRgbImage(yarp::sig::FlexImage& rgb_image, yarp::os:
|
361 | 375 | {
|
362 | 376 | yCError(RGBDSENSOR_NWC_ROS2, "missing rgb image");
|
363 | 377 | }
|
364 |
| - return rgb_ok; |
| 378 | + if (rgb_ok) return ReturnValue_ok; |
| 379 | + return ReturnValue::return_code::return_value_error_not_ready; |
365 | 380 | }
|
366 | 381 |
|
367 | 382 | /*
|
368 | 383 | * TODO FIXME to update with header instead of stamp
|
369 | 384 | */
|
370 |
| -bool RgbdSensor_nwc_ros2::getDepthImage(depthImage& depth_image, yarp::os::Stamp* depth_image_stamp) |
| 385 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getDepthImage(depthImage& depth_image, yarp::os::Stamp* depth_image_stamp) |
371 | 386 | {
|
372 | 387 | std::lock_guard<std::mutex> guard_depth_image(m_depth_image_mutex);
|
373 | 388 | std::lock_guard<std::mutex> guard_depth_camera_info(m_depth_camera_info_mutex);
|
@@ -396,28 +411,34 @@ bool RgbdSensor_nwc_ros2::getDepthImage(depthImage& depth_image, yarp::os::Stamp
|
396 | 411 | {
|
397 | 412 | yCError(RGBDSENSOR_NWC_ROS2, "missing depth image");
|
398 | 413 | }
|
399 |
| - return depth_ok; |
| 414 | + |
| 415 | + if (depth_ok) return ReturnValue_ok; |
| 416 | + return ReturnValue::return_code::return_value_error_not_ready; |
400 | 417 | }
|
401 | 418 | /*
|
402 | 419 | * TODO FIXME to update with header instead of stamp
|
403 | 420 | */
|
404 |
| -bool RgbdSensor_nwc_ros2::getImages(yarp::sig::FlexImage& rgb_image, depthImage& depth_image, yarp::os::Stamp* rgb_image_stamp, yarp::os::Stamp* depth_image_stamp) |
| 421 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getImages(yarp::sig::FlexImage& rgb_image, depthImage& depth_image, yarp::os::Stamp* rgb_image_stamp, yarp::os::Stamp* depth_image_stamp) |
405 | 422 | {
|
406 | 423 | bool rgb_ok, depth_ok;
|
407 | 424 | rgb_ok = getRgbImage(rgb_image, rgb_image_stamp);
|
408 | 425 | depth_ok = getDepthImage(depth_image, depth_image_stamp);
|
409 |
| - return (rgb_ok && depth_ok); |
| 426 | + |
| 427 | + if (rgb_ok && depth_ok) return ReturnValue_ok; |
| 428 | + return ReturnValue::return_code::return_value_error_not_ready; |
410 | 429 | }
|
411 | 430 |
|
412 | 431 |
|
413 |
| -RgbdSensor_nwc_ros2::RGBDSensor_status RgbdSensor_nwc_ros2::getSensorStatus() |
| 432 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getSensorStatus(yarp::dev::IRGBDSensor::RGBDSensor_status& status) |
414 | 433 | {
|
415 |
| - return RGBD_SENSOR_OK_IN_USE; |
| 434 | + status=RGBD_SENSOR_OK_IN_USE; |
| 435 | + return ReturnValue_ok; |
416 | 436 | }
|
417 | 437 |
|
418 | 438 |
|
419 |
| -std::string RgbdSensor_nwc_ros2::getLastErrorMsg(yarp::os::Stamp* timeStamp) |
| 439 | +yarp::dev::ReturnValue RgbdSensor_nwc_ros2::getLastErrorMsg(std::string& message, yarp::os::Stamp* timeStamp) |
420 | 440 | {
|
421 | 441 | yCError(RGBDSENSOR_NWC_ROS2) << "get last error not yet implemented";
|
422 |
| - return "get last error not yet implemented"; |
| 442 | + message = "get last error not yet implemented"; |
| 443 | + return ReturnValue::return_code::return_value_error_not_implemented_by_device; |
423 | 444 | }
|
0 commit comments