Using Armadillo C++ library with ROS
Hello all!
So I am trying to use the armadillo library for my project with ROS. I installed armadillo on my computer (Ubuntu 12.04) using the commands
sudo apt-get install libarmadillo2
sudo apt-get install libarmadillo-dev
More about the armadillo library and related downloads can be found here:
http://arma.sourceforge.net/docs.html#svd
I then downloaded the armadillo package, and navigated to the "examples" folder. There, I typed "make" in the commandline to build the executables from the example files. I then ran an example which required LAPACK and BLAS (which I have installed a long time ago) to complete. This example ran perfectly. (Actually, the example calculated the inverse and determinant of a sample matrix A, which require LAPACK and BLAS to be installed). So far, so good.
Now I have a ROS package, which requires armadillo. I copied the file called "armadillo" and the folder called "armadillo bits" into the "include" folder of my ROS package. I then went into /include/armadillo_bits/config.hpp and configured LAPACK and BLAS by doing
#define ARMAUSELAPACK
#define ARMAUSEBLAS
I then went back into the main package folder, and did "rosmake". Everything compiled fine. I then did
rosrun mypackage mypackage
and I get the following error:
error: svd(): use of LAPACK needs to be enabled
terminate called after throwing an instance of 'std::logic_error'
what():
Aborted (core dumped)
Apparently, the svd() function (which also needs LAPACK and BLAS like the inverse and determinant functions) cannot detect LAPACK. This is weird, because it worked with the example file in the armadillo "examples" folder.
I have a feeling that I am not linking to the right libraries, and there is something fishy going on. How do I get Armadillo to work inside a ROS package, the same way I got it to work inside the "examples" folder in the armadillo folder?
All help is greatly appreciated.
Thanks!
Nishant
Asked by Nishant on 2012-11-27 13:06:23 UTC
Answers
Oh, I got it. There are 2(very similar) ways to do this:
1) In your header file which includes all the libraries, instead of
#include <armadillo>
put
#include </usr/include/armadillo>
2) You can also use the library that you copied into the "include" folder of your package, by doing
#include <../include/armadillo>
Both seem to work. Can anyone else suggest any other method? It would be nice to know these things.
Thanks!
Nishant
Asked by Nishant on 2012-11-27 13:28:41 UTC
Comments