ROS noetic 安装编译Cartographer踩坑记录
安装编译工具
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
首先来说,python-rosdep
已经被废弃了
那么只能换成推荐的
sudo apt-get install python3-rosdep
不过注意,noetic和python3-rosdep有冲突,所以,你在安装中有可能碰到把ros部分组建给卸掉的情况,这时你只能重装(挺快的)
sudo apt install ros-noetic-desktop-full
创建工作空间
mkdir -p ~/ROS_WS/cartographer
cd ~/ROS_WS/cartographer
用wstool拉源码
wstool init src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
编辑src目录下的.rosinstall
#鉴于github源码在国内访问较慢,可以使用国内码云仓库,在我的仓库中已经设置为公有
vim ./src/.rosinstall
将文件修改为如下内容:
- git:
local-name: cartographer
uri: https://gitee.com/moresweet/cartographer.git
version: master
- git:
local-name: cartographer_ros
uri: https://gitee.com/moresweet/cartographer_ros.git
version: master
- git:
local-name: ceress-solver
uri: https://gitee.com/moresweet/ceres-solver.git
成功后会拉下来三套源码
编译安装
rosdep update
rosdep install ——from-paths src ——ignore-src ——rosdistro=${ROS_DISTRO} -y
可能会出现问题
若rosdep update很慢报错,请参照
https://blog.csdn.net/leida_wt/article/details/115120940?spm=1001.2014.3001.5506
第二条可能会报错
ERROR: Rosdep cannot find all required resources to answer your query
Missing resource ——from-paths
ROS path [0]=/opt/ros/noetic/share/ros
ROS path [1]=/opt/ros/noetic/share
这明显是–from-path参数不认识,猜测是python3-rosdep2有了变动,操作不一样了,并且报错是环境变量中的路径找不到,那么直接catkin_make(不需要编译成功,目的是出现devel目录,将此目录环境导入PATH中,当然也可以选择直接更改环境变量的方式)
catkin_make #不管成功与否,只是为了生成devel目录
source devel/setup.bash #这样本功能包的目录就在终端环境中了
此时再执行rosdep install ——from-paths src ——ignore-src ——rosdistro=${ROS_DISTRO} -y
会发现
ERROR: Rosdep cannot find all required resources to answer your query
Missing resource ——from-paths
ROS path [0]=/opt/ros/noetic/share/ros
ROS path [1]=/home/moresweet/ROS_WS/cartograher/src
ROS path [2]=/opt/ros/noetic/share
多了一行
我们直接用rosdep在src中安装就可以了
cd src
rosdep install cartographer
一步一步的按y点回车就好了
安装cartographer的依赖(记住这个地方,后面编译出错,可以会来看看是不是确实的东西,这里有,有就装上)
cd cartographer/scripts/
vim install_proto3.sh
#修改github项目地址为https://gitee.com/shenyinsong_admin/protobuf.git
vim install_abseil.sh
#修改github项目地址为https://gitee.com/moresweet/abseil-cpp.git
./install_proto3.sh
./install_abseil.sh
然后回到工作空间,用ninja编译
cd ~/ROS_WS/cartographer
catkin_make_isolated ——install ——use-ninja
如果报错
- Found GMock: gmock_main;-lpthread
CMake Error at CMakeLists.txt:32 (find_package):
By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "absl", but
CMake did not find one.
Could not find a package configuration file provided by "absl" with any of
the following names:
abslConfig.cmake
absl-config.cmake
Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
"absl_DIR" to a directory containing one of the above files. If "absl"
provides a separate development package or SDK, be sure it has been
installed.
请确定安装cartographer的依赖那一步install_abseil.sh
是否成功安装。
测试运行
下载测试数据集
cd ~
wget https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag
至此,安装成功
个人学习记录博客,仅供学习交流,转载请注明出处!