grid_map编译错误:error: static assertion failed: OUT_OF_RANGE_ACCESS

问题:编译grid_map_navigation包时eigen报错:OUT_OF_RANGE_ACCESS。

  1. 问题陈述:

In file included from /usr/include/eigen3/Eigen/Core:347:0,
                 from /opt/ros/melodic/include/grid_map_core/TypeDefs.hpp:10,
                 from /opt/ros/melodic/include/grid_map_core/grid_map_core.hpp:11,
                 from /opt/ros/melodic/include/grid_map_ros/grid_map_ros.hpp:11,
                 from /home/shen/grismap/gridmap/src/grid_map_proc-master/include/grid_map_proc/grid_map_polygon_tools.h:4,
                 from /home/shen/grismap/gridmap/src/grid_map_proc-master/src/grid_map_polygon_tools.cpp:1:
/usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h: In instantiation of ‘Eigen::DenseCoeffsBase<Derived, 1>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::z() [with Derived = Eigen::Matrix<double, 2, 1>; Eigen::DenseCoeffsBase<Derived, 1>::Scalar = double]’:
/home/shen/grismap/gridmap/src/grid_map_proc-master/src/grid_map_polygon_tools.cpp:162:51:   required from here
/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32:40: error: static assertion failed: OUT_OF_RANGE_ACCESS
     #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);

错误提示:

error: static assertion failed: OUT_OF_RANGE_ACCESS
     #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
  1. 解决方法:

错误提示是超出访问范围,查找程序报错位置,代码如下:

grid_map::Position position;
grid_map.getPosition(index, position);
obstacle_pose.position.x = position.x();
obstacle_pose.position.y = position.y();
obstacle_pose.position.z = position.z() + found_obstacle_height_offset;

pose使用了z轴位置,而grid_map::Position函数结构说明为:

  typedef Eigen::Vector2d Position;

grid_map::getPosition函数结构说明为:

const Position & grid_map::GridMap::getPosition( ) const
Get the 2d position of the grid map in the grid map frame.
Returns:
position of the grid map in the grid map frame.

grid_map::Position跟getPosition只有x和y轴的位置,不包括w轴位置,所以会提示超出访问范围,可以使用grid_map::Position3getPosition3,定义如下:

typedef Eigen::Vector3d Position3;
bool grid_map::GridMap::getPosition3    (    const std::string &     layer,
const Index &     index,
Position3 &     position 
)        const
Gets the 3d position of a data point (x, y of cell position & cell value as z) in the grid map frame. This is useful for data layers such as elevation.

Parameters
layer    the name of the layer to be accessed.
index    the index of the requested cell.
position    the position of the data point in the parent frame.
Returns
true if successful, false if no valid data available.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值