25 #include <pcl/impl/point_types.hpp>
26 #include <pcl/point_types.h>
27 #include <pcl/common/transforms.h>
43 defineOptionalProperty<int>(
"ProviderWaitMs", 100,
44 "Time to wait for each point cloud provider [ms].");
51 defs->optional(params.pointSizeInPixels,
"viz.pointSizeInPixels",
"The point size in pixels.");
52 defs->optional(params.checkFinite,
"viz.checkFinite",
53 "Enable to check points for being finite. "
54 "\nEnable this option if the drawn point cloud causes the screen to become purely white.");
55 defs->optional(params.labeled,
"viz.labeled",
56 "If true and point cloud is labeled, draw colors according to labels.");
58 defs->optional(params.robotName,
"robotName",
"");
59 defs->optional(params.pointCloudNodeName,
"pointCloudNodeName",
" If the point cloud header does not provide a frame id, this info is used.");
72 return "PointCloudToArViz";
78 params.providerWaitTime = IceUtil::Time::milliSeconds(getProperty<int>(
"ProviderWaitMs").getValue());
108 if (
waitForPointClouds(providerName,
static_cast<int>(params.providerWaitTime.toMilliSeconds())))
110 auto it = cache.find(providerName);
111 if (it == cache.end())
119 std::scoped_lock lock(paramMutex);
120 params = this->params;
129 pcl::PointCloud<pcl::PointXYZRGBL>::Ptr inputCloud(
new pcl::PointCloud<pcl::PointXYZRGBL>);
131 applyCustomTransform(*inputCloud);
132 vizCloud.
pointCloud(*inputCloud, params.labeled);
136 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr inputCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>);
138 applyCustomTransform(*inputCloud);
148 ARMARX_VERBOSE <<
"Timeout waiting for point cloud provider " << providerName <<
".";
155 std::scoped_lock lock(paramMutex);
156 params.pointSizeInPixels = pointSizeInPixels;
171 template<
class Po
intT>
172 void PointCloudToArViz::applyCustomTransform(pcl::PointCloud<PointT>& pointCloud)
184 const auto pointCloudNodeName = [&]() -> std::string {
187 if(not pointCloud.header.frame_id.empty())
189 return pointCloud.header.frame_id;
194 <<
"The point cloud header does not provide a frame_id. Using property instead";
197 <<
"The `pointCloudNodeName` property must be provided as the point cloud header frame id is not set!";
199 return params.pointCloudNodeName;
209 const auto node = robot->getRobotNode(pointCloudNodeName);
212 const auto globalSensorPose = node->getGlobalPose();
214 pcl::transformPointCloud(pointCloud, pointCloud, globalSensorPose);
226 tab.checkFinite.
setName(
"Check Finite");
227 tab.checkFinite.setValue(params.checkFinite);
229 tab.pointSizeInPixels.setName(
"Point Size [pixels]");
230 tab.pointSizeInPixels.setDecimals(2);
231 tab.pointSizeInPixels.setRange(0, 100);
232 tab.pointSizeInPixels.setSteps(100);
233 tab.pointSizeInPixels.setValue(params.pointSizeInPixels);
235 tab.labeled.setName(
"Color by Labels");
236 tab.labeled.setValue(params.labeled);
238 grid.
add(
Label(tab.checkFinite.getName()), {row, 0}).
add(tab.checkFinite, {row, 1});
240 grid.
add(
Label(tab.pointSizeInPixels.getName()), {row, 0}).
add(tab.pointSizeInPixels, {row, 1});
242 grid.
add(
Label(tab.labeled.getName()), {row, 0}).
add(tab.labeled, {row, 1});
251 std::scoped_lock lock(paramMutex);
252 if (tab.checkFinite.hasValueChanged())
254 params.checkFinite = tab.checkFinite.getValue();
256 if (tab.pointSizeInPixels.hasValueChanged())
258 params.pointSizeInPixels = tab.pointSizeInPixels.getValue();
260 if (tab.labeled.hasValueChanged())
262 params.labeled = tab.labeled.getValue();