ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Fuerte VS Hydro: 3D mapping algorithm runs very slow after Hydro migration?

asked 2013-10-10 18:09:27 -0500

updated 2014-01-28 17:18:12 -0500

ngrennan gravatar image

Hello,

I have recently installed ROS Hydro mainly due to PCL 1.7. I had a 3D registration algorithm that I developed on ROS Fuerte and ported it to ROS Hydro. I am using the same laptop and everything is identical. However, the algorithm runs extremely slow on ROS Hydro (less than a frame per second), while it was running at over 10 fps on ROS Fuerte. I haven't changed anything in the code except for the parts that are depreciated and needed to be updated to PCL 1.7. Is there any idea why this extreme slowing down might be caused by?

Update: I have observed that the following function runs much slower now on Hydro. Although it is identical and I did not change anything at all. This function is part of a transformation estimation algorithm Ransac style.

void Transformation::computeInliersAndError (
const std::vector<cv::DMatch>& matches,
const Eigen::Matrix4f& transformation,
const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& origins,
const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& earlier,
std::vector<cv::DMatch>& inliers, //output var
double& mean_error, std::vector<double>& errors)
{ //output var


inliers.clear ();
errors.clear ();

std::vector<std::pair<float, int> > dists;
std::vector<cv::DMatch> inliers_temp;

assert(matches.size() > 0);
mean_error = 0.0;
for (unsigned int j = 0; j < matches.size (); j++)
{ //compute new error and inliers

unsigned int this_id = matches[j].queryIdx;
unsigned int earlier_id = matches[j].trainIdx;

Eigen::Vector4f vec = (transformation * origins[this_id]) - earlier[earlier_id];

double error = vec.dot (vec);

error = sqrt (error);
dists.push_back (std::pair<float, int> (error, j));
inliers_temp.push_back (matches[j]); //include inlier

mean_error += error;
errors.push_back (error);
} 


}

I really appreciate your help.

Regards, Khalid

edit retag flag offensive close merge delete

Comments

Looks to me like it's only STL and Eigen, no ROS, no pcl. Is it maybe just compile flags or something like that?

dornhege gravatar image dornhege  ( 2013-10-13 03:52:46 -0500 )edit

Thanks for your comment, I do not have much knowledge with compiler flags etc. Is there something you recommend I should do/check? And why would it have this problem only on Hydro? I still have Fuerte installed on the same machine and the algorithm works very fast.

K_Yousif gravatar image K_Yousif  ( 2013-10-13 14:26:22 -0500 )edit

You were right, it had to do with the compiler flags. I found the answer here http://answers.ros.org/question/71965/catkin-compiled-code-runs-3x-slower/. I really appreciate your help!

K_Yousif gravatar image K_Yousif  ( 2013-10-13 14:49:02 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-10-13 14:50:13 -0500

I found the answer here http://answers.ros.org/question/71965/catkin-compiled-code-runs-3x-slower/

Simply run the following command:

catkin_make -DCMAKE_BUILD_TYPE=Release
edit flag offensive delete link more
0

answered 2013-10-10 21:12:18 -0500

tfoote gravatar image

I'd look at the changes you made to update your code. If it was done quickly it is quite possible that you are incurring one or multiple conversions of data types or other computationally expensive operations which are unneeded.

edit flag offensive delete link more

Comments

Thanks for your answer, There aren't any major changes that would cause this slowing, the changes I made where changing setInputCloud to setInputSource and changing TransformEigenToTF to transformEigenToTF (with the small t). Everything else is identical and did not require change.

K_Yousif gravatar image K_Yousif  ( 2013-10-12 15:57:57 -0500 )edit

I did not have to convert any sensors_msgs::PointCloud2 to pcl::PCLPointCloud2 since I was only using pcl::PointCloud<pcl::pointxyzrgb> in my callback and my code. I will update the question and post a functions where I have observed a major slow down. Please see the update, and thanks again.

K_Yousif gravatar image K_Yousif  ( 2013-10-12 16:02:14 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-10-10 18:09:27 -0500

Seen: 778 times

Last updated: Oct 13 '13