YARP
Yet Another Robot Platform
RGBDSensorFromRosTopic Class Reference

RGBDSensorFromRosTopic is a driver for a virtual RGBD device: the data is not originated from a physical sensor but from a ROS topic. More...

#include <RGBDSensorFromRosTopic/RGBDSensorFromRosTopic.h>

+ Inheritance diagram for RGBDSensorFromRosTopic:

Public Member Functions

 ~RGBDSensorFromRosTopic () override=default
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool close () override
 Close the DeviceDriver. More...
 
int getRgbHeight () override
 Return the height of each frame. More...
 
int getRgbWidth () override
 Return the width of each frame. More...
 
bool getRgbSupportedConfigurations (yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
 Get the possible configurations of the camera. More...
 
bool getRgbResolution (int &width, int &height) override
 Get the resolution of the rgb image from the camera. More...
 
bool setRgbResolution (int width, int height) override
 Set the resolution of the rgb image from the camera. More...
 
bool getRgbFOV (double &horizontalFov, double &verticalFov) override
 Get the field of view (FOV) of the rgb camera. More...
 
bool setRgbFOV (double horizontalFov, double verticalFov) override
 Set the field of view (FOV) of the rgb camera. More...
 
bool getRgbMirroring (bool &mirror) override
 Get the mirroring setting of the sensor. More...
 
bool setRgbMirroring (bool mirror) override
 Set the mirroring setting of the sensor. More...
 
bool getRgbIntrinsicParam (Property &intrinsic) override
 Get the intrinsic parameters of the rgb camera. More...
 
int getDepthHeight () override
 Return the height of each frame. More...
 
int getDepthWidth () override
 Return the height of each frame. More...
 
bool setDepthResolution (int width, int height) override
 Set the resolution of the depth image from the camera. More...
 
bool getDepthFOV (double &horizontalFov, double &verticalFov) override
 Get the field of view (FOV) of the depth camera. More...
 
bool setDepthFOV (double horizontalFov, double verticalFov) override
 Set the field of view (FOV) of the depth camera. More...
 
bool getDepthIntrinsicParam (Property &intrinsic) override
 Get the intrinsic parameters of the depth camera. More...
 
double getDepthAccuracy () override
 Get the minimum detectable variation in distance [meter]. More...
 
bool setDepthAccuracy (double accuracy) override
 Set the minimum detectable variation in distance [meter] when possible. More...
 
bool getDepthClipPlanes (double &nearPlane, double &farPlane) override
 Get the clipping planes of the sensor. More...
 
bool setDepthClipPlanes (double nearPlane, double farPlane) override
 Set the clipping planes of the sensor. More...
 
bool getDepthMirroring (bool &mirror) override
 Get the mirroring setting of the sensor. More...
 
bool setDepthMirroring (bool mirror) override
 Set the mirroring setting of the sensor. More...
 
bool getExtrinsicParam (yarp::sig::Matrix &extrinsic) override
 Get the extrinsic parameters from the device. More...
 
bool getRgbImage (FlexImage &rgbImage, Stamp *timeStamp=nullptr) override
 Get the rgb frame from the device. More...
 
bool getDepthImage (depthImage &depthImage, Stamp *timeStamp=nullptr) override
 
bool getImages (FlexImage &colorFrame, depthImage &depthFrame, Stamp *colorStamp=nullptr, Stamp *depthStamp=nullptr) override
 
RGBDSensor_status getSensorStatus () override
 Get the surrent status of the sensor, using enum type. More...
 
std::string getLastErrorMsg (Stamp *timeStamp=nullptr) override
 Return an error message in case of error. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 ~DeviceDriver () override=default
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 
- Public Member Functions inherited from yarp::dev::IRGBDSensor
virtual ~IRGBDSensor ()
 
virtual bool getDepthImage (yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *timeStamp=nullptr)=0
 Get the depth frame from the device. More...
 
virtual bool getImages (yarp::sig::FlexImage &colorFrame, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthFrame, yarp::os::Stamp *colorStamp=nullptr, yarp::os::Stamp *depthStamp=nullptr)=0
 Get the both the color and depth frame in a single call. More...
 
- Public Member Functions inherited from yarp::dev::IRgbVisualParams
virtual ~IRgbVisualParams ()
 
- Public Member Functions inherited from yarp::dev::IDepthVisualParams
virtual ~IDepthVisualParams ()
 

Public Attributes

std::mutex m_mutex
 
yarp::os::Nodem_ros_node = nullptr
 
yarp::dev::RGBDRosConversionUtils::commonImageProcessorm_rgb_input_processor = nullptr
 
yarp::dev::RGBDRosConversionUtils::commonImageProcessorm_depth_input_processor = nullptr
 
std::string m_lastError
 

Additional Inherited Members

- Public Types inherited from yarp::dev::IRGBDSensor
enum  RGBDSensor_status {
  RGBD_SENSOR_NOT_READY = 0 ,
  RGBD_SENSOR_OK_STANBY = 1 ,
  RGBD_SENSOR_OK_IN_USE = 2 ,
  RGB_SENSOR_ERROR = 3 ,
  DEPTH_SENSOR_ERROR = 4 ,
  RGBD_SENSOR_GENERIC_ERROR = 5 ,
  RGBD_SENSOR_TIMEOUT = 6
}
 

Detailed Description

RGBDSensorFromRosTopic is a driver for a virtual RGBD device: the data is not originated from a physical sensor but from a ROS topic.

This device driver exposes the IRGBDSensor interface to read the images published by a ROS node. See the documentation for more details about each interface.

This device can be used in two different ways:

  • as a client, directly opened by your application
  • as a device, wrapped by a RGBDSensorWrapper

When used as a client, the RGBDSensorFromRosTopic device directly connects to the ROS publisher via tcp_ros carrier. This mode does not use a RGBDSensorWrapper and thus minimize latency. It is thus recommended when the application consists of a single client. However, if multiple clients are involved, as shown in the diagram below, this architecture might be inefficient, due to the multiple tcp_ros connections.

dot_inline_dotgraph_10.png

The second mode, instead, is useful if the application consists of several modules, and each of them employ a client connected to the same server (RGBDSensorWrapper). In this case, if all the modules run on the same machine, the unix_stream can be employed to share data between them, minimizing data transfer operations and greatly boosting the performance. See the digram below.

dot_inline_dotgraph_11.png
YARP device name
RGBDSensorFromRosTopic

Parameters used by this device are:

Parameter name SubParameter Type Units Default Value Required Description Notes
color_topic_name - string - - Yes The device connects to this ROS topic to get RGB data (there must be also camera_info with the last subtopic)

| depth_topic_name | - | string | - | - | Yes | The device connects to this ROS topic to get Depth data (there must be also camera_info with the last subtopic) | | * | node_name | - | string | - | - | Yes | the name of the ros node | | | node_name | - | string | - | - | Yes | the name of the ros node | | * | node_name | - | string | - | - | Yes | the name of the ros node | |

Example of configuration file (using .ini format) when the device is wrapped by RGBDSensorWrapper.

device RGBDSensorWrapper
subdevice RGBDSensorFromRosTopic
color_topic_name /camera/color/image_raw
depth_topic_name /camera/depth/image_raw
node_name RGBDSensorFromRosTopic

Definition at line 187 of file RGBDSensorFromRosTopic.h.

Constructor & Destructor Documentation

◆ ~RGBDSensorFromRosTopic()

RGBDSensorFromRosTopic::~RGBDSensorFromRosTopic ( )
overridedefault

Member Function Documentation

◆ close()

bool RGBDSensorFromRosTopic::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 70 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthAccuracy()

double RGBDSensorFromRosTopic::getDepthAccuracy ( )
overridevirtual

Get the minimum detectable variation in distance [meter].

Returns
the sensor resolution in meters.

Implements yarp::dev::IRGBDSensor.

Definition at line 242 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthClipPlanes()

bool RGBDSensorFromRosTopic::getDepthClipPlanes ( double &  nearPlane,
double &  farPlane 
)
overridevirtual

Get the clipping planes of the sensor.

Parameters
nearPlaneminimum distance at which the sensor start measuring. Object closer than this distance will not be detected.
farPlanemaximum distance beyond which the sensor stop measuring. Object farther than this distance will not be detected.
Returns
true if success

Implements yarp::dev::IRGBDSensor.

Definition at line 248 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthFOV()

bool RGBDSensorFromRosTopic::getDepthFOV ( double &  horizontalFov,
double &  verticalFov 
)
overridevirtual

Get the field of view (FOV) of the depth camera.

Parameters
horizontalFovwill return the value of the horizontal fov in degrees
verticalFovwill return the value of the vertical fov in degrees
Returns
true if success

Implements yarp::dev::IRGBDSensor.

Definition at line 221 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthHeight()

int RGBDSensorFromRosTopic::getDepthHeight ( )
overridevirtual

Return the height of each frame.

Returns
depth image height

Implements yarp::dev::IRGBDSensor.

Definition at line 203 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthImage()

bool RGBDSensorFromRosTopic::getDepthImage ( depthImage depthImage,
Stamp timeStamp = nullptr 
)
override

Definition at line 294 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthIntrinsicParam()

bool RGBDSensorFromRosTopic::getDepthIntrinsicParam ( Property intrinsic)
overridevirtual

Get the intrinsic parameters of the depth camera.

Parameters
intrinsicreturn a Property containing intrinsic parameters of the optical model of the camera.
Returns
true if success

The yarp::os::Property describing the intrinsic parameters is expected to be in the form:

Parameter name SubParameter Type Units Default Value Required Description Notes
physFocalLength - double m - Yes Physical focal length of the lens in meters
focalLengthX - double pixel - Yes Horizontal component of the focal length as a multiple of pixel width
focalLengthY - double pixel - Yes Vertical component of the focal length as a multiple of pixel height
principalPointX - double pixel - Yes X coordinate of the principal point
principalPointY - double pixel - Yes Y coordinate of the principal point
rectificationMatrix - 4x4 double matrix - - Yes Matrix that describes the lens' distortion
distortionModel - string - - Yes Reference to group of parameters describing the distortion model of the camera, example 'cameraDistortionModelGroup' This is another group's name to be searched for in the config file
cameraDistortionModelGroup
name string - - Yes Name of the distortion model, see notes right now only 'plumb_bob' is supported
k1 double - - Yes Radial distortion coefficient of the lens
k2 double - - Yes Radial distortion coefficient of the lens
k3 double - - Yes Radial distortion coefficient of the lens
t1 double - - Yes Tangential distortion of the lens
t2 double - - Yes Tangential distortion of the lens

Implements yarp::dev::IRGBDSensor.

Definition at line 232 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthMirroring()

bool RGBDSensorFromRosTopic::getDepthMirroring ( bool &  mirror)
overridevirtual

Get the mirroring setting of the sensor.

Parameters
mirrortrue if image is mirrored, false otherwise
Returns
true if success

Implements yarp::dev::IDepthVisualParams.

Definition at line 264 of file RGBDSensorFromRosTopic.cpp.

◆ getDepthWidth()

int RGBDSensorFromRosTopic::getDepthWidth ( )
overridevirtual

Return the height of each frame.

Returns
depth image height

Implements yarp::dev::IRGBDSensor.

Definition at line 212 of file RGBDSensorFromRosTopic.cpp.

◆ getExtrinsicParam()

bool RGBDSensorFromRosTopic::getExtrinsicParam ( yarp::sig::Matrix extrinsic)
overridevirtual

Get the extrinsic parameters from the device.

Parameters
extrinsicreturn a rototranslation matrix describing the position of the depth optical frame with respect to the rgb frame
Returns
true if success

Implements yarp::dev::IRGBDSensor.

Definition at line 278 of file RGBDSensorFromRosTopic.cpp.

◆ getImages()

bool RGBDSensorFromRosTopic::getImages ( FlexImage colorFrame,
depthImage depthFrame,
Stamp colorStamp = nullptr,
Stamp depthStamp = nullptr 
)
override

Definition at line 303 of file RGBDSensorFromRosTopic.cpp.

◆ getLastErrorMsg()

std::string RGBDSensorFromRosTopic::getLastErrorMsg ( Stamp timeStamp = nullptr)
overridevirtual

Return an error message in case of error.

For debugging purpose and user notification. Error message will be reset after any successful command

Returns
A string explaining the last error occurred.

Implements yarp::dev::IRGBDSensor.

Definition at line 320 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbFOV()

bool RGBDSensorFromRosTopic::getRgbFOV ( double &  horizontalFov,
double &  verticalFov 
)
overridevirtual

Get the field of view (FOV) of the rgb camera.

Parameters
horizontalFovwill return the value of the horizontal fov in degrees
verticalFovwill return the value of the vertical fov in degrees
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 168 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbHeight()

int RGBDSensorFromRosTopic::getRgbHeight ( )
overridevirtual

Return the height of each frame.

Returns
rgb image height

Implements yarp::dev::IRGBDSensor.

Definition at line 90 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbImage()

bool RGBDSensorFromRosTopic::getRgbImage ( FlexImage rgbImage,
Stamp timeStamp = nullptr 
)
overridevirtual

Get the rgb frame from the device.

The pixel type of the source image will usually be set as a VOCAB_PIXEL_RGB, but the user can call the function with the pixel type of his/her choice. The conversion if possible, will be done automatically on client side (TO BO VERIFIED). Note: this will consume CPU power because it will not use GPU optimization. Use VOCAB_PIXEL_RGB for best performances.

Parameters
rgbImagethe image to be filled.
timeStamptime in which the image was acquired. Optional, ignored if nullptr.
Returns
True on success

Implements yarp::dev::IRGBDSensor.

Definition at line 285 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbIntrinsicParam()

bool RGBDSensorFromRosTopic::getRgbIntrinsicParam ( Property intrinsic)
overridevirtual

Get the intrinsic parameters of the rgb camera.

Parameters
intrinsicreturn a Property containing intrinsic parameters of the optical model of the camera.
Returns
true if success

The yarp::os::Property describing the intrinsic parameters is expected to be in the form:

Parameter name SubParameter Type Units Default Value Required Description Notes
physFocalLength - double m - Yes Physical focal length of the lens in meters
focalLengthX - double pixel - Yes Horizontal component of the focal length as a multiple of pixel width
focalLengthY - double pixel - Yes Vertical component of the focal length as a multiple of pixel height
principalPointX - double pixel - Yes X coordinate of the principal point
principalPointY - double pixel - Yes Y coordinate of the principal point
rectificationMatrix - 4x4 double matrix - - Yes Matrix that describes the lens' distortion
distortionModel - string - - Yes Reference to group of parameters describing the distortion model of the camera, example 'cameraDistortionModelGroup' This is another group's name to be searched for in the config file
cameraDistortionModelGroup
name string - - Yes Name of the distortion model, see notes right now only 'plumb_bob' is supported
k1 double - - Yes Radial distortion coefficient of the lens
k2 double - - Yes Radial distortion coefficient of the lens
k3 double - - Yes Radial distortion coefficient of the lens
t1 double - - Yes Tangential distortion of the lens
t2 double - - Yes Tangential distortion of the lens

Implements yarp::dev::IRGBDSensor.

Definition at line 193 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbMirroring()

bool RGBDSensorFromRosTopic::getRgbMirroring ( bool &  mirror)
overridevirtual

Get the mirroring setting of the sensor.

Parameters
mirrortrue if image is mirrored, false otherwise
Returns
true if success

Implements yarp::dev::IRgbVisualParams.

Definition at line 179 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbResolution()

bool RGBDSensorFromRosTopic::getRgbResolution ( int &  width,
int &  height 
)
overridevirtual

Get the resolution of the rgb image from the camera.

Parameters
widthimage width
heightimage height
Returns
true on success

Reimplemented from yarp::dev::IRGBDSensor.

Definition at line 115 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbSupportedConfigurations()

bool RGBDSensorFromRosTopic::getRgbSupportedConfigurations ( yarp::sig::VectorOf< yarp::dev::CameraConfig > &  configurations)
overridevirtual

Get the possible configurations of the camera.

Parameters
configurationslist of camera supported configurations as CameraConfig type
Returns
true on success

Reimplemented from yarp::dev::IRGBDSensor.

Definition at line 108 of file RGBDSensorFromRosTopic.cpp.

◆ getRgbWidth()

int RGBDSensorFromRosTopic::getRgbWidth ( )
overridevirtual

Return the width of each frame.

Returns
rgb image width

Implements yarp::dev::IRGBDSensor.

Definition at line 99 of file RGBDSensorFromRosTopic.cpp.

◆ getSensorStatus()

RGBDSensorFromRosTopic::RGBDSensor_status RGBDSensorFromRosTopic::getSensorStatus ( )
overridevirtual

Get the surrent status of the sensor, using enum type.

Returns
an enum representing the status of the robot or an error code if any error is present

Implements yarp::dev::IRGBDSensor.

Definition at line 315 of file RGBDSensorFromRosTopic.cpp.

◆ open()

bool RGBDSensorFromRosTopic::open ( yarp::os::Searchable config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. See device invocation examples. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

@<-OK

@<-OK

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 25 of file RGBDSensorFromRosTopic.cpp.

◆ setDepthAccuracy()

bool RGBDSensorFromRosTopic::setDepthAccuracy ( double  accuracy)
overridevirtual

Set the minimum detectable variation in distance [meter] when possible.

Parameters
thedesired resolution in meters.
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 161 of file RGBDSensorFromRosTopic.cpp.

◆ setDepthClipPlanes()

bool RGBDSensorFromRosTopic::setDepthClipPlanes ( double  nearPlane,
double  farPlane 
)
overridevirtual

Set the clipping planes of the sensor.

Parameters
nearPlaneminimum distance at which the sensor start measuring. Object closer than this distance will not be detected.
farPlanemaximum distance beyond which the sensor stop measuring. Object farther than this distance will not be detected.
Returns
true if success

Implements yarp::dev::IRGBDSensor.

Definition at line 256 of file RGBDSensorFromRosTopic.cpp.

◆ setDepthFOV()

bool RGBDSensorFromRosTopic::setDepthFOV ( double  horizontalFov,
double  verticalFov 
)
overridevirtual

Set the field of view (FOV) of the depth camera.

Parameters
horizontalFovwill set the value of the horizontal fov in degrees
verticalFovwill set the value of the vertical fov in degrees
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 153 of file RGBDSensorFromRosTopic.cpp.

◆ setDepthMirroring()

bool RGBDSensorFromRosTopic::setDepthMirroring ( bool  mirror)
overridevirtual

Set the mirroring setting of the sensor.

Parameters
mirrortrue if image should be mirrored, false otherwise
Returns
true if success

Implements yarp::dev::IDepthVisualParams.

Definition at line 271 of file RGBDSensorFromRosTopic.cpp.

◆ setDepthResolution()

bool RGBDSensorFromRosTopic::setDepthResolution ( int  width,
int  height 
)
overridevirtual

Set the resolution of the depth image from the camera.

Parameters
widthimage width
heightimage height
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 128 of file RGBDSensorFromRosTopic.cpp.

◆ setRgbFOV()

bool RGBDSensorFromRosTopic::setRgbFOV ( double  horizontalFov,
double  verticalFov 
)
overridevirtual

Set the field of view (FOV) of the rgb camera.

Parameters
horizontalFovwill set the value of the horizontal fov in degrees
verticalFovwill set the value of the vertical fov in degrees
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 145 of file RGBDSensorFromRosTopic.cpp.

◆ setRgbMirroring()

bool RGBDSensorFromRosTopic::setRgbMirroring ( bool  mirror)
overridevirtual

Set the mirroring setting of the sensor.

Parameters
mirrortrue if image should be mirrored, false otherwise
Returns
true if success

Implements yarp::dev::IRgbVisualParams.

Definition at line 186 of file RGBDSensorFromRosTopic.cpp.

◆ setRgbResolution()

bool RGBDSensorFromRosTopic::setRgbResolution ( int  width,
int  height 
)
overridevirtual

Set the resolution of the rgb image from the camera.

Parameters
widthimage width
heightimage height
Returns
true on success

Implements yarp::dev::IRGBDSensor.

Definition at line 136 of file RGBDSensorFromRosTopic.cpp.

Member Data Documentation

◆ m_depth_input_processor

yarp::dev::RGBDRosConversionUtils::commonImageProcessor* RGBDSensorFromRosTopic::m_depth_input_processor = nullptr

Definition at line 259 of file RGBDSensorFromRosTopic.h.

◆ m_lastError

std::string RGBDSensorFromRosTopic::m_lastError

Definition at line 261 of file RGBDSensorFromRosTopic.h.

◆ m_mutex

std::mutex RGBDSensorFromRosTopic::m_mutex
mutable

Definition at line 256 of file RGBDSensorFromRosTopic.h.

◆ m_rgb_input_processor

yarp::dev::RGBDRosConversionUtils::commonImageProcessor* RGBDSensorFromRosTopic::m_rgb_input_processor = nullptr

Definition at line 258 of file RGBDSensorFromRosTopic.h.

◆ m_ros_node

yarp::os::Node* RGBDSensorFromRosTopic::m_ros_node = nullptr

Definition at line 257 of file RGBDSensorFromRosTopic.h.


The documentation for this class was generated from the following files: