Skip to content

Add RGBD sensor interfaces and YARP network wrappers - #92

Closed
isorrentino wants to merge 4 commits into
mainfrom
feature/rgbd-sensor-nws-nwc
Closed

isorrentino wants to merge 4 commits into
mainfrom
feature/rgbd-sensor-nws-nwc

Conversation

@isorrentino

Copy link
Copy Markdown

PR description

This PR adds RGB-D camera support to dinrail. It adds two native interfaces, dinrail::IRGBDSensor and dinrail::ICameraControls, with getters that never block. It adds a YARP server and client pair that speak the same protocol as YARP's rgbdSensor_nws_yarp, a fake RGB-D device for tests, and a generic dr_device_yarp host. That host lets any dinrail device, such as the new RealSense device, be used with YARP network wrappers.

Add RGBD sensor interfaces, network wrappers and generic YARP device host

What this PR does

Core interfaces (src/core)

  • dinrail::IRGBDSensor
    • Gives synchronized color and depth images, intrinsics, the depth-to-RGB extrinsics, clip planes and the sensor status.
    • The image getters never block. They return the latest images, and getImagesStamp() lets a caller check for new images without copying them.
    • Sensors that stream only depth are supported: the color methods return FailedPrecondition.
  • dinrail::ICameraControls: camera feature controls.
  • IRGBDSensorSimulation: lets fake devices set the images and the status.
  • CameraTypes: Image, DepthImage, CameraIntrinsics, CameraExtrinsics.

Devices

  • dr_rgbd_fake: a fake RGB-D sensor.
    • Image size, focal length, depth value and framerate can be configured.
    • Color can be turned off to get a depth-only sensor.
    • Has unit tests.

YARP network wrappers (src/yarp-devices)

  • dr_rgbd_nws_yarp (server)
    • Publishes <name>/rgbImage:o and <name>/depthImage:o, and serves <name>/rpc:i.
    • Uses the protocol of YARP's rgbdSensor_nws_yarp, so RGBDSensorClient and yarpview keep working.
    • Its thread polls getImagesStamp() and publishes only when there are new images. It only publishes on ports that have at least one connection.
    • The period parameter only limits the delay the wrapper adds; it does not need to match the camera framerate.
  • dr_rgbd_nwc_yarp (client)
    • Exposes dinrail::IRGBDSensor on the client side.
    • Port callbacks receive the images, so the getters never block.
    • Intrinsics, extrinsics and clip planes are read once over RPC when the device opens.
    • The color stream is optional, and a frame_timeout sets the Timeout status when depth images stop arriving.
  • dr_device_yarp (generic YARP host for any dinrail device)
    • Opens a dinrail device given by the subdevice parameter.
    • Exposes the wrapped device through dinrail::IWrappedDinrailDevice. Wrappers that know about dinrail then use its native interfaces directly, without converting to YARP types.
    • Exposes the device's inertial sensors to multipleanalogsensorsserver.
  • Shared framegrabber protocol: forwarder and responder classes for RgbVisualParams, DepthVisualParams and FrameGrabberControls, plus the camera vocabs.

YARP interop (src/yarp)

  • YARP adapters for the new interfaces (YarpRGBDSensorAdapters), registered in YarpInteropPlugin.
  • IWrappedDinrailDevice.

Block diagram

 ┌──────────────────────── Robot (yarprobotinterface) ────────────────────────┐
 │                                                                            │
 │  ┌───────────────────────────┐                                             │
 │  │ dr_device_yarp            │  subdevice = realsense                      │
 │  │  ┌─────────────────────┐  │  (gb-dinrail-device-realsense2)             │
 │  │  │ dinrail "realsense" │  │                                             │
 │  │  │  IRGBDSensor        │  │                                             │
 │  │  │  ICameraControls    │  │                                             │
 │  │  │  IMU (gyro/acc)     │  │                                             │
 │  │  └─────────────────────┘  │                                             │
 │  └─────┬───────────────┬─────┘                                             │
 │ attach │ (native, via  │ attach (YARP MAS interfaces)                      │
 │        │ IWrappedDinrailDevice)                                            │
 │        ▼               ▼                                                   │
 │  ┌──────────────────┐ ┌──────────────────────────────┐                     │
 │  │ dr_rgbd_nws_yarp │ │ multipleanalogsensorsserver  │                     │
 │  │ /depthCamera     │ │ /depthCamera/inertials       │                     │
 │  └───┬──────────────┘ └──────────────┬───────────────┘                     │
 └──────┼───────────────────────────────┼─────────────────────────────────────┘
        │ /depthCamera/rgbImage:o       │ IMU ports
        │ /depthCamera/depthImage:o     │
        │ /depthCamera/rpc:i            │
        ▼                               ▼
 ┌─────────────────────────┐  ┌─────────────────────────┐  ┌──────────────┐
 │ dr_rgbd_nwc_yarp        │  │ RGBDSensorClient (YARP) │  │ yarpview     │
 │ -> dinrail::IRGBDSensor │  │ (same protocol)         │  │              │
 │ (dinrail::Device::open) │  └─────────────────────────┘  └──────────────┘
 └─────────────────────────┘

Alternative without the IMU: dr_rgbd_nws_yarp with <param name="subdevice"> realsense </param> opens the dinrail device directly. Example XML configurations are in the READMEs of dr_device_yarp and dr_rgbd_nws_yarp.

Motivation and testing on the robot

The goal is to stop using the YARP realsense2 device and use the new native dinrail device gbionics/gb-dinrail-device-realsense2 instead.

This PR was tested on the robot with that device. The setup was dr_device_yarp with subdevice = realsense, attached to:

  • dr_rgbd_nws_yarp, which published the color and depth images;
  • multipleanalogsensorsserver, which published the camera IMU.

On the client side, the images were received with both dr_rgbd_nwc_yarp and the standard YARP tools (RGBDSensorClient, yarpview). This confirms that existing YARP consumers still work after the switch.

…host

Add dinrail::IRGBDSensor and dinrail::ICameraControls with non-blocking
getters, including getImagesStamp() to detect new images without copying
them, and support for sensors that stream only depth images.

Add the dr_rgbd_nws_yarp and dr_rgbd_nwc_yarp network wrappers, which use
the protocol of the YARP rgbdSensor_nws_yarp so that the standard YARP
clients (RGBDSensorClient, yarpview) are still compatible, the
dr_rgbd_fake device and the YARP adapters of the new interfaces.

Add the dr_device_yarp YARP device, which opens any dinrail device so that
network wrappers can be attached to it: dinrail-aware wrappers use the
native interfaces through dinrail::IWrappedDinrailDevice, and the inertial
sensors are exposed to multipleanalogsensorsserver.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
isorrentino and others added 3 commits November 27, 2026 15:07
The files were kept with the formatting of YARP, which fails the
format-check task of the CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The YARP_DATA_DIRS of the tests used ':' as separator, which does not work
on Windows. As the other tests of the YARP devices, the plugins are now
found in the installation prefix, and the dinrail devices next to the
dinrail library.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PolyDriver::close() destroys the device, so reading its gyroscopes after
closing it was a use after free, which crashed the test on macOS and
Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@traversaro

Copy link
Copy Markdown
Contributor

fyi @S-Dafarra @RiccardoGrieco

@isorrentino

isorrentino commented Nov 30, 2026 •

Copy link
Copy Markdown
Author

After a face-to-face discussion with @S-Dafarra, Stefano requested not to proceed with the merge, in order not to introduce new interfaces to read the RealSense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants