Sophus
Sophus copied to clipboard
Failed auto type deduction in some cases with operator*()
Hi. Having updated from 18.04 (sophus=ef9551f) to 20.04 (sophus=master), I ran into some compilation issue with some existing code. I've created a minimal example:
#include "sophus/se2.hpp"
#include <iostream>
int main() {
const int N = 2;
Eigen::Matrix<double, 2, N> points1 = Eigen::Matrix<double, 2, N>::Random();
Eigen::MatrixXd points2(2, N);
points2 = points1;
Sophus::SE2d pose(0.5, Eigen::Vector2d({0.1, 0.2}));
Eigen::Vector2d point1 = pose * points1.col(0); // Compiles
// Eigen::Vector2d point2 = pose * points2.col(0); // [1] Does not compile
Eigen::Vector2d point3 = pose * Eigen::Vector2d(points2.col(0)); // Compiles
// Eigen::Matrix<double, 2, N> points4 = pose * points1; // [2] Does not compile
std::cout << point1 << std::endl;
// std::cout << point2 << std::endl;
std::cout << point3 << std::endl;
return 0;
}
The compiliation error for [1] is no match for ‘operator*’ (operand types are ‘Sophus::SE2d’ {aka ‘Sophus::SE2<double>’} and ‘Eigen::DenseBase<Eigen::Matrix<double, -1, -1> >::ColXpr’ {aka ‘Eigen::Block<Eigen::Matrix<double, -1, -1>, -1, 1, true>’})
Another operation [2] that fails to compile is operator*(Sophus::SE2<double>, const Eigen::Matrix<double, 2, -1>)
, which would previously transform all columns of 2d points according to SE2.
Ubuntu 20.04 Eigen 3.3.7 gcc 9.3.0
I meet the same question,what is the answer of this question?