c++ “operator=”特征3 ros2代码不匹配[已关闭]

63lcw9qa  于 2023-02-01  发布在  其他
关注(0)|答案(1)|浏览(173)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
我在github上看到了这个repo,用于ROS2 Humble上的激光扫描抓地力Map。我使用eigen3.4.0和Ubuntu 22.04
https://github.com/hiwad-aziz/ros2_occupancy_grid
当我试图编译时,我得到错误

src/occupancy_grid/src/occupancy_grid.cpp:60:139: error: no match for ‘operator=’ (operand types are ‘Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double> >::type’ {aka ‘Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double>’} and ‘Eigen::DenseCoeffsBase<Eigen::Matrix<int, -1, -1>, 1>::Scalar’ {aka ‘int’})
   60 |         temp_map(floor(new_indices(0)), floor(new_indices(1))) = (Eigen::DenseCoeffsBase<Eigen::Matrix<int, -1, -1>, 1>::Scalar) map_(x, y);

“occupancy_grid. cpp”中编译器错误中提到的函数:

void OccupancyGrid::update(double delta_x, double delta_y, double delta_yaw)
{
  Eigen::MatrixXd temp_map(num_cells_, num_cells_);
  temp_map.setConstant(0.5);
  // Convert position delta to cell delta
  double delta_x_grid = delta_x / cell_size_;
  double delta_y_grid = delta_y / cell_size_;
  double cos_dyaw = cos(delta_yaw);
  double sin_dyaw = sin(delta_yaw);
  Eigen::MatrixXd transformation_matrix(3, 3);
  transformation_matrix << cos_dyaw, -sin_dyaw, delta_x_grid, sin_dyaw, cos_dyaw, delta_y_grid, 0.0,
      0.0, 1.0;
  for (int x = 0; x < num_cells_; ++x) {
    for (int y = 0; y < num_cells_; ++y) {
      Eigen::VectorXd old_indices(3);
      // Translate (x, y) to origin
      old_indices << x - grid_center_.x, y - grid_center_.y, 1.0;
      // Transform according to robot movement
      Eigen::VectorXd new_indices = transformation_matrix * old_indices;
      // Translate back to map indices
      new_indices(0) += grid_center_.x;
      new_indices(1) += grid_center_.y;
      if (isInGridBounds(floor(new_indices(0)), floor(new_indices(1)))) {
        temp_map(floor(new_indices(0)), floor(new_indices(1))) =  map_(x, y);
      }
    }
  }
  map_ = temp_map;
}

我试过将变量类型更改为int或类类型等,但无法成功。

3mpgtkmj

3mpgtkmj1#

我通过降级到eigen3.3.7-2解决了这个问题,这是ubuntu focal的默认安装

相关问题