31PointCloudUtility::fusePointclouds(std::string file1, std::string file2, std::string out)
33 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc1 = loadPointCloud(file1);
34 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc2 = loadPointCloud(file2);
35 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc1Aligned =
36 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr(
new pcl::PointCloud<pcl::PointXYZRGBA>);
37 pcl::ApproximateVoxelGrid<pcl::PointXYZRGBA> filter;
39 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr temp1 =
40 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr(
new pcl::PointCloud<pcl::PointXYZRGBA>);
41 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr temp2 =
42 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr(
new pcl::PointCloud<pcl::PointXYZRGBA>);
51 pcl::IterativeClosestPoint<pcl::PointXYZRGBA, pcl::PointXYZRGBA> aligner;
52 aligner.setEuclideanFitnessEpsilon(1e-20);
53 aligner.setTransformationEpsilon(1e-20);
54 aligner.setMaximumIterations(10000000);
55 aligner.setUseReciprocalCorrespondences(
true);
56 aligner.setInputSource(pc1);
57 aligner.setInputTarget(pc2);
58 aligner.align(*pc1Aligned);
59 pcl::PointCloud<pcl::PointXYZRGBA> pcout = *pc2 + *pc1Aligned;
61 pcl::io::savePCDFileASCII(out, pcout);
65PointCloudUtility::moveOrigin(std::string file, std::string out, Eigen::Vector3f translation)
67 Eigen::Matrix4f
transform = Eigen::Matrix4f::Identity();
68 transform.block<3, 1>(0, 3) = translation;
69 this->transformPointcloud(file, out,
transform);
73PointCloudUtility::rotatePointCloud(std::string file, std::string out, Eigen::Matrix3f rotation)
75 Eigen::Matrix4f
transform = Eigen::Matrix4f::Identity();
77 this->transformPointcloud(file, out,
transform);
81PointCloudUtility::transformPointcloud(std::string file, std::string out, Eigen::Matrix4f pose)
83 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc = loadPointCloud(file);
84 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr transformed_cloud(
85 new pcl::PointCloud<pcl::PointXYZRGBA>());
86 pcl::transformPointCloud<pcl::PointXYZRGBA>(*pc, *transformed_cloud, pose);
88 pcl::io::savePCDFileASCII(out, *transformed_cloud);
92PointCloudUtility::showResult(std::string file)
94 pcl::visualization::PCLVisualizer viewer;
95 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc = loadPointCloud(file);
96 viewer.addPointCloud(pc);
97 viewer.addCoordinateSystem(1.0);
99 while (!viewer.wasStopped())
105PointCloudUtility::process()
113 std::string temp =
"temp.pcd";
118 fusePointclouds(file1, file2, temp);
123 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc = loadPointCloud(file1);
124 pcl::io::savePCDFileASCII(temp, *pc);
128 Eigen::Vector3f tVector;
135 VirtualRobot::MathTools::posrpy2eigen4f(tVector, rot,
transpose);
136 transformPointcloud(temp, out,
transpose);
141 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pc = loadPointCloud(temp);
142 pcl::io::savePCDFileASCII(out, *pc);
165pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
166PointCloudUtility::loadPointCloud(std::string filename)
169 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr model(
new pcl::PointCloud<pcl::PointXYZRGBA>());
172 ARMARX_ERROR <<
"Could not find point cloud file in ArmarXDataPath: " << filename;
175 else if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(filename.c_str(), *model) == -1)
177 ARMARX_WARNING <<
"unable to load point cloud from file " << filename;
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
void onInitComponent() override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
void onExitComponent() override
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
SceneBounds merge(const std::vector< SceneBounds > &sceneBounds)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T > > &src, Thrower thrower)
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.