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

Eigen3.3.7 Quaternion type not Scalar #2058

Closed
rancheng opened this issue Jan 5, 2020 · 3 comments
Closed

Eigen3.3.7 Quaternion type not Scalar #2058

rancheng opened this issue Jan 5, 2020 · 3 comments

Comments

@rancheng
Copy link

rancheng commented Jan 5, 2020

Issue description

When I am building g2opy against Eigen 3.3.7, I'm having the issue like this I noticed that Eigen 3.3.4 above they modified the Quaternion coefficient return type from Scalar& to NonConstReturnType could you please help me to find a way to cast into Scalar&?

Reproducible example code

(The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.)

  1. Install eigen 3.3.7

  2. compile g2opy:

git clone https://github.com/uoip/g2opy.git
cd g2opy
mkdir build
cd build
cmake ..
make -j8
cd ..
python setup.py install

will pop out the following error:

/g2opy/python/core/eigen_types.h:188:82: error: no matches converting function 'w' to type 'double (class Eigen::Quaternion<double>::*)() const'
         .def("w", (double (Eigen::Quaterniond::*) () const) &Eigen::Quaterniond::w)
@wjakob
Copy link
Member

wjakob commented Jan 5, 2020

Not a pybind11 issue, you'll have to talk to the g2opy authors..

@star0w
Copy link

star0w commented Jul 22, 2020

Have u solved it? I have met the same problem.

@district10
Copy link

Return type of Eigen::Quaterniond::x() const is const double &, and return type of Eigen::Quaterniond::x() is double &. So you can change the return type of these functions like this:

.def("x", (const double &(Eigen::Quaterniond::*)() const) & Eigen::Quaterniond::x)
.def("y", (const double &(Eigen::Quaterniond::*)() const) & Eigen::Quaterniond::y)
.def("z", (const double &(Eigen::Quaterniond::*)() const) & Eigen::Quaterniond::z)
.def("w", (const double &(Eigen::Quaterniond::*)() const) & Eigen::Quaterniond::w)

or

.def("x", (double &(Eigen::Quaterniond::*)()) & Eigen::Quaterniond::x)
.def("y", (double &(Eigen::Quaterniond::*)()) & Eigen::Quaterniond::y)
.def("z", (double &(Eigen::Quaterniond::*)()) & Eigen::Quaterniond::z)
.def("w", (double &(Eigen::Quaterniond::*)()) & Eigen::Quaterniond::w)

Reference here means nothing here (specify return_value_policy or not). It just makes the binding compiles.

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

4 participants