Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using tf::twistKDLToEigen leads to compilation errors #228

Open
karthikeyaparunandi opened this issue Jun 17, 2021 · 0 comments
Open

Using tf::twistKDLToEigen leads to compilation errors #228

karthikeyaparunandi opened this issue Jun 17, 2021 · 0 comments

Comments

@karthikeyaparunandi
Copy link

karthikeyaparunandi commented Jun 17, 2021

tf::twistKDLToEigen has a signature void twistKDLToEigen(const KDL::Twist &k, Eigen::Matrix<double, 6, 1> &e).

So, I have two variables that I passed into this function in my code: one the input (twist) and the other one the output (eigen_matrix) that is passed by reference as follows:

// I already have the object `twist` of type `KDL::Twist` with some value assigned to it
Eigen::Matrix<double, 6, 1> eigen_matrix;
tf::twistKDLToEigen(twist, eigen_matrix);

I'm seeing the following error at this place during compilation:

error: cannot bind non-const lvalue reference of type ‘Eigen::Matrix<double, 6, 1>&’ to an rvalue of type ‘Eigen::Matrix<double, 6, 1>’
     tf::twistKDLToEigen(twist, eigen_matrix)
                                                   ^
/usr/include/eigen3/Eigen/src/Core/Matrix.h:378:25: note:   after user-defined conversion: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 6>; _Scalar = double; int _Rows = 6; int _Cols = 1; int _Options = 0; int _MaxRows = 6; int _MaxCols = 1]
     EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)
                         ^~~~~~

In order to narrow down the issue, I wrote a test function with just the Eigen::Matrix<double, 6, 1> &e as an argument and saw the same error:

void test_twistKDLToEigen(Eigen::Matrix<double, 6, 1> &e){
     // do nothing
    return;
}

int main(){
Eigen::Matrix<double, 6, 1> test_eigen_matrix;
test_twistKDLToEigen(test_eigen_matrix);
}

Apparently, this error disappears as soon as the argument is Eigen::Matrix<double, 6, 1> e i.e, pass by value or const Eigen::Matrix<double, 6, 1> &e. Is there something I'm missing or is it a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant