robotology / yarp-device-realsense2

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

Cannot run the Realsense device at 60 fps #31

Open LZC-68 opened 2 years ago

LZC-68 commented 2 years ago

We want to run Realsense(D435) at 60 fps. But the actual fps we got is 33.3.

image

Configurations are set as:

depthResolution (640 480) rgbResolution (640 480) framerate 60 enableEmitter true needAlignment true alignmentFrame RGB

Moreover, we tried to set different framerate, the Realsense can be connected when set framerate as 15, 30 and 60 fps.

Nicogene commented 2 years ago

Hi @LZC-68 !

Are they included in the [SETTINGS] group?

LZC-68 commented 2 years ago

Hi @Nicogene

Yes, they are included in the [SETTINGS] group.

I post contents in the config.ini here.

device RGBDSensorWrapper subdevice realsense2 name /depthCamera

[SETTINGS] depthResolution (640 480) #Other possible values (424 240) or (640 480) rgbResolution (640 480) #Other possible values (424 240) or (640 480) framerate 60 enableEmitter true needAlignment true alignmentFrame RGB

[HW_DESCRIPTION] clipPlanes (0.2 10.0)

Nicogene commented 2 years ago

When you run the device do you get this warning?

https://github.com/robotology/yarp-device-realsense2/blob/887d846abd98a6622f017ffde82c4a56a8f63c19/src/devices/realsense2/realsense2Driver.cpp#L674

It would be interesting to see if through rpc port it is possible to set the framerate.

@xEnVrE do you remember the rpc protocol? Otherwise we have to reverse-engineer it

LZC-68 commented 2 years ago

Hi @Nicogene

No, we don't have that warning. Instead we had this one:

[INFO] |yarp.devices.RGBDSensorWrapper| RGBDSensorWrapper: using default 'period' parameter of  0.03 s

So, we realized that it is not enough to change the SETTINGS::framerate parameter (which is propagated to the Intel SDK at initialization time) but also to specify the period to the RGBDSensorWrapper as well.

In the end, with this configuration file:

device       RGBDSensorWrapper
subdevice    realsense2
name         /depthCamera
period       0.016

[SETTINGS]
depthResolution (640 480)    #Other possible values (424 240) or (640 480)
rgbResolution   (640 480)    #Other possible values (424 240) or (640 480)
framerate       60
enableEmitter   true
needAlignment   true
alignmentFrame  RGB

[HW_DESCRIPTION]
clipPlanes (0.2 10.0)

we were able to get the camera working at the desired fps.

Maybe it would be good adding this piece of information in the README.md. Also, do you think it is possible to maybe change the code such that the user has to specify only the framerate?

Thanks

Nicogene commented 2 years ago

@LZC-68 this kind of error came out because the parameter name used by the wrapper/nws (RGBDSensorWrapper) is different by the one used by the underlying sensor, period vs SETTINGS::framerate.

Usually, they match and it is not needed to specify it twice. Moreover in this case framerate != period also semantically, We could take the period specified for the wrapper and do 1/period for the device but the realsense SDK requires specific values, for example if you have a period of 0.033 -> framerate = 30.3030, and since the SDK will accept integer number like 30 60 etc. it will fail the open of the streams. We could ceil the number and/or check if the period and SETTINGS::framerate are consistent, or we just document it properly