robotology / yarp-device-realsense2

realsense2 device for YARP (https://www.yarp.it/)
Other
7 stars 10 forks source link

multianalogsensorserver segsfault if subdevice is set to realsense2withIMU #35

Open GiulioRomualdi opened 1 year ago

GiulioRomualdi commented 1 year ago

I tried to run the realsense2withIMU by means of the multianalogsensorserver this should allow me to read the gyro and the accelerometer provided by the realsense D435i.

I have the following configuration file stored in sensors/RealSense_conf.ini

device       multipleanalogsensorsserver
subdevice    realsense2withIMU
name         /depthCamera
period       10

[SETTINGS]
depthResolution (640 480)
rgbResolution   (640 480)
framerate       30
enableEmitter   true
alignmentFrame  RGB

[HW_DESCRIPTION]
clipPlanes (0.2 10.0)

Then I run the device as

yarpdev --from sensors/RealSense_conf.ini

I got the following

arpdev --from sensors/RealSense_conf.ini
[DEBUG] |yarp.dev.PolyDriver|multipleanalogsensorsserver| Parameters are (HW_DESCRIPTION (clipPlanes (0.200000000000000011102 10.0))) (SETTINGS (depthResolution (640 480)) (rgbResolution (640 480)) (framerate 30) (enableEmitter true) (alignmentFrame RGB)) (device multipleanalogsensorsserver) (from "sensors/RealSense_conf.ini") (name "/depthCamera") (period 10) (single_threaded 1) (subdevice realsense2withIMU)
[DEBUG] |yarp.dev.PolyDriver|realsense2withIMU| Parameters are (HW_DESCRIPTION (clipPlanes (0.200000000000000011102 10.0))) (SETTINGS (depthResolution (640 480)) (rgbResolution (640 480)) (framerate 30) (enableEmitter true) (alignmentFrame RGB)) (device realsense2withIMU) (from "sensors/RealSense_conf.ini") (name "/depthCamera") (period 10) (single_threaded 1) (subdevice realsense2withIMU)
[WARNING] |yarp.device.realsense2withIMU| This software module is experimental.
[WARNING] |yarp.device.realsense2withIMU| It is provided with uncomplete documentation and it may be modified/renamed/removed without any notice.
[INFO] |yarp.device.realsense2| Sensor warm-up...
[INFO] |yarp.device.realsense2| Device ready!
[INFO] |yarp.device.realsense2| Device consists of 3 sensors. More infos using --verbose option
[INFO] |yarp.dev.PolyDriver|realsense2withIMU| Created device <realsense2withIMU>. See C++ class realsense2withIMUDriver for documentation.
[INFO] |yarp.os.Port|/depthCamera/measures:o| Port /depthCamera/measures:o active at tcp://10.240.9.195:10009/
[INFO] |yarp.os.Port|/depthCamera/rpc:o| Port /depthCamera/rpc:o active at tcp://10.240.9.195:10010/
[INFO] |yarp.device.multipleanalogsensorsserver| Subdevice "realsense2withIMU" successfully configured and attached.
[INFO] |yarp.dev.PolyDriver|multipleanalogsensorsserver| Created wrapper <multipleanalogsensorsserver>. See C++ class MultipleAnalogSensorsServer for documentation.
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| ===============================================================
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| == Options checked by device:
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| ==
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| device=multipleanalogsensorsserver
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| id [multipleanalogsensorsserver]
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver|     Id assigned to this device
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| ==
[DEBUG] |yarp.dev.Drivers|multipleanalogsensorsserver| ===============================================================
[INFO] |yarp.os.Port|/depthCamera/quit| Port /depthCamera/quit active at tcp://10.240.9.195:10008/
[INFO] |yarp.dev.Drivers|multipleanalogsensorsserver| device active in background...
Segmentation fault (core dumped)

I debug the code using gdb and I notice that the code crashes at this line

https://github.com/robotology/yarp-device-realsense2/blob/d4da73fa2336c40d7d479bb8ee87c317f2128c9b/src/devices/realsense2/realsense2withIMUDriver.cpp#L517

Indeed the pointer is not allocated

https://github.com/robotology/yarp-device-realsense2/blob/d4da73fa2336c40d7d479bb8ee87c317f2128c9b/src/devices/realsense2/realsense2withIMUDriver.cpp#L230-L234

I will provide a PR to fixes the issue cc @traversaro

GiulioRomualdi commented 1 year ago

https://github.com/robotology/yarp-device-realsense2/pull/36 fixes the issue