3

I know using #include <stlport.h> and #include <Eigen30.h> to make Eigen work with Arduino is a pretty old way to get working Eigen.

Hence I tried also #include <ArduinoSTL.h> with two Eigen Arduino libs that I found out there(#include <Eigen30.h> and #include <Eigen.h>). I´ll leave here the links to the GitHub repos of all the libraries.

#include <Eigen.h> : https://github.com/bolderflight/Eigen

#include <Eigen30.h>: https://github.com/vancegroup/EigenArduino/tree/Eigen30

#include <stlport.h>: https://github.com/vancegroup/stlport-avr/tree/STLport-5.2-arduino-installed

#include <ArduinoSTL.h> : https://github.com/mike-matera/ArduinoSTL


Only #include <stlport.h> and #include <Eigen30.h> actually compiled in Arduino's IDE. I'm Actually version 1.6.20 of the AVR Boards package that we can modify in Tools Board Board Manager.

When I started doing some basic operations to test Eigen, like adding matrices and Initializing matrices. Then I noticed that whenever I multiplied 2 matrices no matter the method I used (I tried every method that the documentation of Eigen suggested as best practices) the program got stuck in that specific instruction.

Here is an example:

#include <stlport.h>
#include <Eigen30.h>
#include <Eigen/Dense>

using namespace Eigen;

void setup()
{
   Serial.begin(9600);
   delay(2000);
   Serial.print("Hi");

Matrix3f m;
MatrixXf b(2,2);
MatrixXf M1(2,2); //EDIT: I missed this last time.
MatrixXf matA(2, 2);

 m << 1, 2, 3,
      4, 5, 6,
      7, 8, 9;

matA << 1, 2,
        1, 2;

b = matA;

 print_mtxf(b);  // Goes ok
 print_mtxf(matA);  // Goes ok

Serial.print("M1:\n");  // Goes ok
 M1.noalias() =  matA*b;  // Something wrong is going on here.
 print_mtxf(M1);  // Nerver gets to print this or the following
 Serial.print("M1:\n");
 Serial.print("M1:\n");

}

void loop()
{

}

void print_mtxf(const Eigen::MatrixXf &X)  
{
   int i, j, nrow, ncol;

   nrow = X.rows();
   ncol = X.cols();

   Serial.print("nrow: "); Serial.println(nrow);
   Serial.print("ncol: "); Serial.println(ncol);       
   Serial.println();

   for (i=0; i<nrow; i++)
   {
       for (j=0; j<ncol; j++)
       {
           Serial.print(X(i,j), 6);   // print 6 decimal places
           Serial.print(", ");
       }
       Serial.println();
   }
   Serial.println();
}



So now what are my options? I really want to get working Eigen because I'm going to use a basic c++ library that depends just in Eigen, it's pretty basic but Eigen hasn't worked properly. I think it gest to an infinite loop because the proceeding prints never get completed.

  • What is `M1`? Make sure to post the actual code you tried to compile. Also, how does it fail? Does it get stuck in an infinite loop? Does it crash/assert? – chtz Oct 29 '19 at 14:51
  • Also, first try to only `#include ` (which I guess is already included by `"Eigen30.h"`). If you manage to have that working, try out other modules and report issues you are getting to whoever maintains `Eigen30.h`. Alternatively, try an up-to-date Eigen release and report issues you are getting at any Eigen support channel. – chtz Oct 29 '19 at 14:58
  • Sorry M1 is another matrix, I missed pasting that part of the code. – Carlos Echeverria St Oct 29 '19 at 16:07
  • No idea what is happening. Did you try removing the `#include `? Does `Matrix2f` instead of `MatrixXf` work? What happens if you include an up-to-date `Eigen/Core` instead of `Eigen30.h` (with or without first including (`stlport.h`)? – chtz Oct 30 '19 at 16:45

0 Answers0