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

Linear Algebra operations with ROS

asked 2014-02-15 10:20:59 -0500

Pedro_85 gravatar image

I'm trying to create some example nodes that execute linear algebra commands. I wanted to try the TooN library ( http://www.edwardrosten.com/cvd/toon.... ). I was trying to follow what the package tum_ardrone has done in regards to this.

1) I downloaded the folder containing the TooN library files and moved it to the the directory /thirdparty/TooN/include/.

2) I added the following to my CMakeLists.txt file:

# set required libs and headers
include_directories( ${PROJECT_SOURCE_DIR}/thirdparty/TooN/include )

Based on the file HelperFunctions.h located in /tum_ardrone/src I created a simple program to perform basic matrix operations. I will be using these functions later and since I'm not familiar with any library like this one I need to start from the basics. When I execute rosmake I get the following error:

 /home/pedro/fuerte_workspace/sandbox/controlador_ardrone/src/ejemploalgebralineal.cpp: In member function ‘void LinearAlgebra::InverseMatrix()’:
  /home/pedro/fuerte_workspace/sandbox/controlador_ardrone/src/ejemploalgebralineal.cpp:31:31: error: ‘struct TooN::Matrix<3>’ has no member named ‘inverse’

Here is the code I try to compile:

#include <ros/ros.h>
#include <std_msgs/Empty.h>
#include <geometry_msgs/Twist.h>
#include <math.h>
#include <TooN/TooN.h>
#include <TooN/so3.h>

  using namespace std;
  using namespace TooN;

  struct LinearAlgebra
  {
    ros::NodeHandle n;

    void InverseMatrix(){
        TooN::Matrix<3,3> mat;
        mat = Data(1,2,3,4,5,6,7,8,9);
        TooN::SO3<> res = mat.inverse();
        std::cout << "m3_4\n" << mat << "\nm3_5\n"<<res  << std::endl;
    }

    void Commands(){
        InverseMatrix();
    }
  };

////////////

int main(int argc, char **argv)
{
  ros::init(argc,argv,"Linear_Algebra_ROS");

  LinearAlgebra linearalgebra;
  ros::Duration wait_time = ros::Duration(3,0);

  while(linearalgebra.n.ok()) {
      wait_time.sleep();
      linearalgebra.Commands();
      ros::spinOnce();
  }
  return 0;

Does anybody have experience with this library and/or other libraries that I can use? Any help is appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

answered 2014-02-15 11:26:23 -0500

The most frequently used linear algebra library within the ROS ecosystem probably is Eigen. A usage example can be found in the Coding a realtime Cartesian controller with Eigen tutorial. An example of how the setup of package.xml and CMakeLists.txt has to look with catkin can be obtained from the laser_geometry package.

I haven´t tried the TooN library, so cannot comment on that one.

edit flag offensive delete link more

Comments

Thanks for your answer! I was reading about the Eigen library and seems to be doing the job. I'm still curious why the authors of tum_ardrone preferred the TooN libraries instead. I want to wait a couple of days before I accept this as an answer. I want to see if someone can help with TooN.

Pedro_85 gravatar image Pedro_85  ( 2014-02-15 12:22:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-02-15 10:20:59 -0500

Seen: 1,872 times

Last updated: Feb 15 '14