发布时间:2023-04-20 文章分类:电脑百科 投稿人:王小丽 字号: 默认 | | 超大 打印

工程复现 – grid map和elevation map

参考
1. ROS grid map
2. ROS elevation_mapping
3. ROS高程地图–elevation_mapping使用记录(一)
4. ROS高程地图–elevation_mapping使用记录(二)

一.下载和编译安装工程

注意: 安装和编译过程中如果出现疑问,请参考第三部分的答疑内容。

1.1 下载两个工程

git clone https://github.com/anybotics/grid_map
git clone https://github.com/ANYbotics/elevation_mapping

1.2 安装依赖库

sudo apt-get install ros-$ROS_DISTRO-grid-map
sudo apt-get install libeigen3-dev
git clone https://github.com/ANYbotics/point_cloud_io.git
cd .. && catkin_make
source devel/setup.bash

1.3 安装两个工程

catkin_make -DCMAKE_BUILD_TYPE=Release
source devel/setup.bash

注意将两个工程放在一个工作空间下,本空间内还需要其他依赖包,完整目录如下:

cui@cui-pc:~/catkin_map/src $ tree -f -L 1
.
├── ./CMakeLists.txt -> /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
├── ./elevation_mapping
├── ./grid_map
├── ./kindr_ros
├── ./message_logger
└── ./point_cloud_io

二. 运行demo

2.1 grid_map

1. 跳动的地毯

工程复现 -- grid map和elevation map

roslaunch grid_map_demos simple_demo.launch
roslaunch grid_map_demos tutorial_demo.launch   ## 完整版本

2.2 elevation_mapping

1. TurtleBot3 Waffle Simulation 仿真机器人

工程复现 -- grid map和elevation map

## 安装turtlebot3 仿真
sudo apt install ros-melodic-turtlebot3*
## 启动demo
roslaunch elevation_mapping_demos turtlesim3_waffle_demo.launch
## 控制仿真机器人
export TURTLEBOT3_MODEL=waffle
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

2. Ground Truth Demo

工程复现 -- grid map和elevation map

roslaunch elevation_mapping_demos simple_demo.launch
## 前提需要安装point_cloud_io
roslaunch elevation_mapping_demos ground_truth_demo.launch

三. 遇到问题及解决

3.1 grid map工程可能遇到的问题

Q1: catkin_make,编译过程中,CMake Error at grid_map/grid_map_octomap/CMakeLists.txt:13 (find_package):
A1

sudo apt-get install ros-$ROS_DISTRO-grid-map

Q2: catkin_make编译过程中, CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package)
A2

sudo apt install ros-melodic-costmap-2d -y

Q3: catkin_make编译过程中,CMake Error at grid_map/grid_map_filters/CMakeLists.txt:35 (find_package), TBBConfig.cmake
A3
参考:
1. csdn 编译需要TBBConfig.cmake,但TBB 2020及older版本不生成.cmake文件”的问题
2. 源码编译TBB
采用源码编译的方式。

git clone https://github.com/oneapi-src/oneTBB
# 查看tag,找到2020.1版本
git checkout v2020.1
## 在cmake文件夹下生成TBBConfig.cmake
cmake -DTBB_ROOT=/home/cui/workspace/tools/oneTBB  -DTBB_OS=Linux -P cmake/tbb_config_generator.cmake
## 安装TBB需要的库文件
cd build
sudo chmod +x *.sh
sh generate_tbbvars.sh
sh tbbvars.sh
## 编译TBB,拷贝相关包含目录库目标到系统环境中
cd oneTBB
make
cd build/linux_intel64_gcc_cc7.5.0_libc2.27_kernel5.4.0_release/
sudo cp *.so /usr/local/lib #或者/usr/lib
sudo cp *.so.2 /usr/local/lib #或者/usr/lib
sudo /sbin/ldconfig
cd ../../include/ && sudo cp -rf ./* /usr/local/include
cd ../cmake && sudo mkdir /usr/local/lib/cmake/TBB
sudo cp TBBConfig.cmake  TBBConfigVersion.cmake /usr/local/lib/cmake/TBB/.
## 设置TBB_FOUND为TRUE
sudo gedit /usr/local/lib/cmake/TBB/TBBConfig.cmake
修改#set(TBB_FOUND FALSE) 为 set(TBB_FOUND TRUE)

Q4:catkin_make编译过程中,home/cui/catkin_others/src/grid_map/grid_map_cv/include/grid_map_cv/InpaintFilter.hpp:11:10: fatal error: filters/filter_base.hpp: No such file or directory #include <filters/filter_base.hpp>
A4
参考:
grid_map(二):ubuntu16.04安装测试grid_map 1.6.0-1.6.2

## grid_map_ws/src/grid_map/grid_map_cv/include/grid_map_cv/InpaintFilter.hpp 的第十行
#include <filters/filter_base.hpp> 为 #include <filters/filter_base.h>
##  文件夹grid_map_ws/src/grid_map/grid_map_filters/include/grid_map_filters下几乎所有文件全部替换
#include <filters/filter_base.hpp>  或  #include <filters/filter_base.h>

Q5:home/cui/catkin_others/src/grid_map/grid_map_demos/include/grid_map_demos/FiltersDemo.hpp:17:10: fatal error: filters/filter_chain.hpp: No such file or directory
A5:解法同Q4

3.2 elevation_mapping 工程可能遇到问题

Q1:catkin_make编译过程中,CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83,kindrConfig.cmake
A1

git clone https://github.com/ANYbotics/kindr.git
cd kindr
mkdir build && cd build
cmake .. -DUSE_CMAKE=true
sudo make install
## 拷贝kindConfig.cmake(可以不加)
sudo mkdir /usr/local/lib/cmake/kindr
sudo cp kindrConfig.cmake /usr/local/lib/cmake/kindr/
## 进入elevation_mapping工作空间
git clone https://github.com/ANYbotics/kindr_ros.git
cd ../ && catkin_make

Q2: catkin_make编译过程中,CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 ,message_loggerConfig.cmake
A2
参考:message_logger安装

## 先进入elevation_mapping工作空间
git clone https://github.com/ANYbotics/message_logger.git

Q3:error: ‘PCL_MAKE_ALIGNED_OPERATOR_NEW’ does not name a type; did you mean
A3

修改elevation_mapping/elevation_mapping/include/elevation_mapping/PointXYZRGBConfidenceRatio.hpp:32  为 EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Q4:home/cui/catkin_others/src/grid_map/grid_map_demos/include/grid_map_demos/FiltersDemo.hpp:17:10: fatal error: filters/filter_chain.hpp: No such file or directory
A4:同第一部分Q5

Q5: 运行ground_truth_demo过程中,出现ERROR: cannot launch node of type [point_cloud_io/read]: point_cloud_io
A5: 需要安装point_cloud_io package, 详细过程参考第一部分1.2 安装过程。

Q6: 编译point_cloud_io工程过程中,BUG: point_cloud_io/src/Read.cpp:11:10: fatal error: filesystem: No such file or directory
A6
参考:
fatal error: filesystem: No such file or directory,fatal error: filesystem: 没有那个文件或目录
undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()
原因在于g++版本问题,g++8以上才支持。

#include <filesystem> 替换为 #include <experimental/filesystem>
std::filesystem 替换为 std::experimental::filesystem
## cmakelist中添加-lstdc++fs
target_link_libraries(read
  ${catkin_LIBRARIES}
  -lstdc++fs
)

Q7: 试跑 roslaunch elevation_mapping_demos simple_demo.launch看不到任何画面
A7: 问题在于point_cloud_io pkg未能发布点云。重启电脑之后问题解决,猜测可能Rviz卡住或者内存不足。
注意: ground_truth_demo.launch 确实看不到画面,但是地图topic还在不断发送。