Thursday, February 27, 2014

accessing points in Point clouds with iteration over locations

source: taken from PCL answers

It is very similar to what you would do for an image or a matrix, and it 
is explained all over the tutorials.

Say you have a cloud pcl::Cloud m_cloud; that has been 
populated.
then you can access your points through m_cloud[i] where i is the linera 
index m_cloud.width * row + col or m_cloud (row, col).

So basically pcl::PointXYZ p = cloud[0] works and p = cloud (0,0) works 
as well.

Please read the tutorials or the API documentation, we put many efforts 
on them.
--
Nizar

Wednesday, February 26, 2014

Kdtree headers in PCL

Error

  /usr/bin/ld: skipping incompatible /usr/lib/Lib/libOpenNI.so when searching for -lOpenNI
  CMakeFiles/plane_extraction.dir/src/plane_extraction.o:(.rodata._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[vtable for pcl::KdTreeFLANN >]+0x18): undefined reference to `pcl::KdTreeFLANN >::nearestKSearch(pcl::PointXYZ const&, int, std::vector >&, std::vector >&)'
  CMakeFiles/plane_extraction.dir/src/plane_extraction.o:(.rodata._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[vtable for pcl::KdTreeFLANN >]+0x24): undefined reference to `pcl::KdTreeFLANN >::radiusSearch(pcl::PointXYZ const&, double, std::vector >&, std::vector >&, int) const'
  collect2: ld returned 1 exit status


Solution

Make sure you added these header files

Tuesday, February 18, 2014

convert Matrix4f to Affine transformation in Eigen

source http://answers.ros.org/question/37609/counterpart-to-pcl_rostransformasmatrix/



Counterpart to pcl_ros::transformAsMatrix ?

asked Jul 2 '12
this post is marked as community wiki
This post is a wiki. Anyone with karma >75 is welcome to improve it.
jodafo gravatar image
Hi,
I understand pcl_ros::transformAsMatrix(const tf::Transform& bt, Eigen::Matrix4f &out_mat) can be used to convert a tf::transform to a 4x4 matrix describing the same transformation.
I am now looking for a method that does the same thing backwards, converting a 4x4 matrix to a tf::transform.
Is such a method already implemented somewhere?
Thanks
EDIT: Solution that works for me, thanks to Eric:
  Eigen::Matrix4f mf; //The matrix I want to convert
  Eigen::Matrix4d md(mf.cast());
  Eigen::Affine3d affine(md);
  tf::Transform transform;
  tf::TransformEigenToTF(affine, transform);
retag flag offensive close delete

Comments

1
A small info which might be helpful for others. For ROS hydro, tf::transformEigenToTF must be used.
balakumar-s (Dec 1 '13)

1 answer


2
answered Jul 2 '12
Eric Perko gravatar image
You should look at the tf_conversions package, specifically thetf::TransformEigenToTF function.
You would have to make an Eigen::Affine3d from your Eigen::Matrix4f. See the Eigen Geometry Module Tutorial (and linked docs for each class) for information on how to go about that. I expect it involves a conversion from Matrix4f to Matrix4d and then passing that to the Affine3d constructor, but I don't know the exact function calls and syntax required off the top of my head.
flag offensive delete link

Comments

Works, thank you.
jodafo (Jul 2 '12)

Thursday, February 13, 2014

Tuesday, February 11, 2014

Errors


the errors that I get while compiling GTSAM 2.3.1 on the ubuntu 12.04

/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp: In function ‘void runPerturb()’:
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:487:3: error: ‘mt19937’ is not a member of ‘boost::random’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:487:3: note: suggested alternative:
/usr/include/boost/random/mersenne_twister.hpp:361:47: note:   ‘boost::mt19937’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:487:26: error: expected ‘;’ before ‘rng’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:488:3: error: ‘normal_distribution’ is not a member of ‘boost::random’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:488:3: note: suggested alternative:
/usr/include/boost/random/normal_distribution.hpp:37:7: note:   ‘boost::normal_distribution’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:488:38: error: expected primary-expression before ‘double’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:488:38: error: expected ‘;’ before ‘double’
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:497:26: error: ‘rng’ was not declared in this scope
/home/sai/workspace/gtsam-2.3.1/examples/SolverComparer.cpp:497:29: error: ‘normal’ was not declared in this scope
make[2]: *** [examples/CMakeFiles/SolverComparer.dir/SolverComparer.cpp.o] Error 1
make[1]: *** [examples/CMakeFiles/SolverComparer.dir/all] Error 2
make: *** [all] Error 2


Solution


The error is solved by changing the lines 487 and 488 from examples/SolverComparer.cpp

  boost::random::mt19937 rng;
  boost::random::normal_distribution normal(0.0, perturbationNoise);

to

  boost::mt19937 rng;
  boost::normal_distribution normal(0.0, perturbationNoise);

Thanks.

adding / Linking GTSAM with ROS

After downloading the gtsam from their website and successfully compiling it.

I downloaded gtsam-2.3.1 to /home/sai/workspace/

Then add these lines in the CMakeLists.txt

include_directories(/home/sai/workspace/gtsam-2.3.1)
include_directories(/home/sai/workspace/gtsam-2.3.1/build)
include_directories(/home/sai/workspace/gtsam-2.3.1/build/gtsam)
link_directories(/home/sai/workspace/gtsam-2.3.1/build)
link_directories(/home/sai/workspace/gtsam-2.3.1/build/gtsam)


rosbuild_add_executable(OdometryExample src/OdometryExample.cpp)
target_link_libraries(OdometryExample gtsam)


This shows an example that runs as ros node


Cya

Friday, February 7, 2014

linking external c++ library to ROS

Hello,
I have an external .cpp library that requires both the following libraries: atlas,llpack and lblas
Now if for example, I compile using terminal (on the same machine) I can use the following:
g++ main.cpp hmm.cpp -I /usr/include/atlas -L /usr/lib64/atlas/ -llapack -lblas
This will work. I don't know how to include these libraries into the CMake list in ROS. I have, currently, the following:
rosbuild_add_executable(build1 src/hmm.c)
What would I have to add into my CMake list to make this work?
Thanks
retag flag offensive close delete

1 answer

1
answered 7 hours ago
Wolf gravatar image
link_directories( /usr/lib64/atlas )
equivalent to -L /usr/lib64/atlas of gcc/g++
And after :
rosbuild_add_executable(build1 src/hmm.c)
you put
target_link_libraries( build1 lapack blas )
equivalent to -llapack -lblas
Note: First arg of target_link_libraries is the previously defined target to link.
Note: no prepended -l in target_link_libraries, i e. if your external lib is named libmy_lib.so you just add my_lib to target_link_libraries
flag offensive delete link

Your Answer