Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
icp.cpp
Go to the documentation of this file.
1#include "icp/icp.hpp"
2
3
4ICP::ICP(std::string target_file, double max_correspondence_distance, long max_iteration,
5 double transformation_epsilon, double euclidean_fitness_epsilon){
6
7 pcl::PointCloud<pcl::PointXYZI>::Ptr target_cloud(new pcl::PointCloud<pcl::PointXYZI>);
8
9 if (pcl::io::loadPCDFile<pcl::PointXYZI>(target_file, *target_cloud) < 0) {
10 PCL_ERROR("Couldn't read file\n");
11 }
12
13 _icp_.setInputTarget(target_cloud);
14
15 _icp_.setMaxCorrespondenceDistance(max_correspondence_distance);
16
17 _icp_.setMaximumIterations(max_iteration);
18
19 _icp_.setTransformationEpsilon(transformation_epsilon);
20
21 _icp_.setEuclideanFitnessEpsilon(euclidean_fitness_epsilon);
22}
23
24double ICP::executeICP(pcl::PointCloud<pcl::PointXYZI>::Ptr source_cloud, pcl::PointCloud<pcl::PointXYZI>::Ptr final_cloud){
25
26 _icp_.setInputSource(source_cloud);
27
28 // Align the clouds
29 pcl::PointCloud<pcl::PointXYZI>::Ptr aligned_cloud(new pcl::PointCloud<pcl::PointXYZI>);
30 _icp_.align(*aligned_cloud);
31
32 if (_icp_.hasConverged()) {
33 *final_cloud = *aligned_cloud;
34 return _icp_.getFitnessScore();
35 } else {
36 return -1;
37 }
38}
pcl::IterativeClosestPoint< pcl::PointXYZI, pcl::PointXYZI > _icp_
ICP object.
Definition icp.hpp:14
ICP(std::string target_file, double max_correspondence_distance, long max_iteration, double transformation_epsilon, double euclidean_fitness_epsilon)
Constructor for the ICP class.
Definition icp.cpp:4
double executeICP(pcl::PointCloud< pcl::PointXYZI >::Ptr source, pcl::PointCloud< pcl::PointXYZI >::Ptr final_cloud)
Execute the ICP registration.
Definition icp.cpp:24