VisionX: Implementing PointCloudProcessors

PointCloud processors in VisionX allow to retrieve pointclouds from an PointCloudProvider and process them. The visionx::PointCloudProcessor ManagedIceObject is the basic superclass for pointcloud processors. The superclass provides the following features

  • pointcloud transport via ethernet or shared memory: whether shared memory is used or not is determined automatically by comparing the IP adresses of provider and processor
  • usage of multiple pointcloud providers as input

Creating a pointcloudprocessor

Integrating a new pointcloud processor is achieved by subclassing the visionx::PointCloudProcessor in the following way:

namespace visionx
{
class ExamplePointCloudProcessor :
{
public:
virtual void onInitPointCloudProcessor();
virtual void onConnectPointCloudProcessor() { }
virtual void onDisconnectPointCloudProcessor() { }
virtual void onExitPointCloudProcessor() { }
virtual std::string getDefaultName() const
{
return "ExamplePointCloudProcessor";
}
virtual void process() = 0;
};
}

The methods that need to be implemented are derived from the armarx::ManagedIceObject:

As for every ManagedIceObject, the default name of the object needs to be provided using the getDefaultName() method.

The process method should be used to implement the processing of input pointclouds. It is started in a separate thread once the PointCloudProcessor is fully connected.

Setting up an pointcloudprocessor

The setup of the pointcloud providers needs to be performed in the onInitPointCloudProvider method:

void ExamplePointCloudProcessor::onInitPointCloudProcessor()
{
// specify dependency to pointcloud provider
usingPointCloudProvider("DummyPointCloudProvider");
}

Multiple providers can be used by issuing multiple usingPointCloudProvider() commands.

Enable result pointclouds

To enable a result point cloud processer call enableResultPointCloud<PointT>() with the point cloud type as an template argument. The name of the point cloud provider will be set to ExamplePointCloudProviderResult. Capacity for the shared memory segment is determined by using the template parameter and the width and height of the first point cloud provider dependency.

void ExamplePointCloudProvider::onConnectPointCloudProvider()
{
enableResultPointCloud<pcl::PointXYZ>();
}

If you want to specify the capacity manually call enableResultPointCloud(yourCapacity); with your size paramater and without an template type. Multiple result point clouds can be enabled via:

void ExamplePointCloudProvider::onConnectPointCloudProvider()
{
enableResultPointCloud<pcl::PointXYZ>("firstResult");
enableResultPointCloud<pcl::PointXYZRGBA>("secondResult");
}

Retrieving pointclouds

In order to process the pointclouds, the pure virtual process method can be implemented and several utility methods can be used to retrieve the pointclouds. The process method is called repeatedly, exit checking is done outside the process method. Consequently, the implementation of the process method should not block or loop but only trigger one processing step.

There are essentially two types of accessing the pointclouds: polling and waiting.

Retrieving pointclouds by polling

For retrieving pointclouds by polling, the visionx::PointCloudProcessor::getPointClouds can be used in the following way:

void ExamplePointCloudProcessor::process()
{
getPointClouds("DummyPointCloudProvider", pointcloudPtr);
// process point cloud
}

The getPointClouds method will return the most recent pointclouds available provided by the PointCloudProvider. This polling method is useful, if the pointcloud processing usually takes much longer then the framerate of input pointclouds.

Retrieving pointclouds by waiting

For retrieving pointclouds by waiting, the visionx::PointCloudProcessor::waitForPointClouds() method can be used

void ExamplePointCloudProcessor::process()
{
if (!waitForPointClouds("DummyPointCloudProvider"))
{
ARMARX_WARNING << "Timeout or error in wait for pointclouds";
}
else
{
// retrieve pointclouds
}
}

The waitForPointClouds method waits until new pointclouds are available from the provider. This guarantees that a subsequent call to getPointClouds will succeed in reading the pointclouds.

visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:186
PointCloudProcessor.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186