1.出错内容(1):
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
<== Failed to process package 'cartographer':
Command '['cmake', '/home/shuaimou/google_ws/src/cartographer', '-DCMAKE_INSTALL_PREFIX=/home/shuaimou/google_ws/install_isolated', '-G', 'Ninja']' returned non-zero exit status 1
Reproduce this error by running:
==> cd /home/shuaimou/google_ws/build_isolated/cartographer && cmake /home/shuaimou/google_ws/src/cartographer -DCMAKE_INSTALL_PREFIX=/home/shuaimou/google_ws/install_isolated -G Ninja
Command failed, exiting.
<== Failed to process package 'cartographer':
Command '['cmake', '/home/shuaimou/google_ws/src/cartographer', '-DCMAKE_INSTALL_PREFIX=/home/shuaimou/google_ws/install_isolated', '-G', 'Ninja']' returned non-zero exit status 1
Reproduce this error by running:
==> cd /home/shuaimou/google_ws/build_isolated/cartographer && cmake /home/shuaimou/google_ws/src/cartographer -DCMAKE_INSTALL_PREFIX=/home/shuaimou/google_ws/install_isolated -G Ninja
Command failed, exiting.
原因:ninja-build未安装,cartographer为安装(cartographer是一个工作空间)
解决方法,安装相应的安装包(安装ninja-build,cartographer之后可能仍会出现错误,因为你可能还有其他依赖包没有安装,强烈建议删除所有的相关文件,然后重新按照下面步骤安装):
首先ninja-build 安装:
sudo apt-get update sudo apt-get install ninja-build
cartographer为安装:
git clone https://github.com/hitcm/cartographer.git #安装在根目录下面
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
方法一,官方安装
(官方安装为依赖安装,只要你安装步骤没错,理论上可行,但在最后编译会遇到一个错误-------这一步
-catkin_make_isolated --install --use-ninja
时遇到一个build error),安装步骤如下,按照顺序执行即可:
# 安装wstool 和 rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
# 创建工作空间.
mkdir catkin_ws
cd catkin_ws
wstool init src
#合并制图员cartographer_ros.rosinstall 文件并获取依赖项的代码
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src #会出现错误,见问题一
# 安装deb依赖项
# 命令'sudo rosdep init' 可能会报错
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
# 安装
catkin_make_isolated --install --use-ninja #见问题二
source install_isolated/setup.bash
问题一:
如果你挂了 VPN ,一般不会出错。
如果你没有,会出现无法下载 ceres-solver 的问题,我们可以修改其下载地址[3]:
1) 修改 google_carto_ws/src/.rosinstall 文件
2) 修改 google_carto_ws/src/cartographter_ros/cartographter_ros.rosinstall 文件
将两个文件中的 ceres-solver 路径改为从 github 下载
https://github.com/ceres-solver/ceres-solver.git
下面是我的 .rosinstall 文件的内容:
- git:
local-name: cartographer
uri: https://github.com/googlecartographer/cartographer.git
- git:
local-name: cartographer_ros
uri: https://github.com/googlecartographer/cartographer_ros.git
- git:
local-name: ceres-solver
uri: https://github.com/ceres-solver/ceres-solver.git
version: 1.12.0rc4
- git:
local-name: cartographer_turtlebot
uri: https://github.com/googlecartographer/cartographer_turtlebot.git
- git:
local-name: cartographer_fetch
uri: https://github.com/googlecartographer/cartographer_fetch.git
下面是我的 cartographter_ros.rosinstall 文件的内容:
- git: {local-name: cartographer, uri: 'https://github.com/googlecartographer/cartographer.git'}
- git: {local-name: cartographer_ros, uri: 'https://github.com/googlecartographer/cartographer_ros.git'}
- git: {local-name: ceres-solver, uri: 'https://ceres-solver.googlesource.com/ceres-solver.git', version: '1.12.0rc4'}
- git: {local-name: cartographer_turtlebot, uri: 'https://github.com/googlecartographer/cartographer_turtlebot.git'}
- git: {local-name: cartographer_fetch, uri: 'https://github.com/googlecartographer/cartographer_fetch.git'}
问题二:
在上面的
catkin_make_isolated --install --use-ninja
这一步时遇到一个build error,信息如下:
CMake Error at /home/xxx/catkin_ws/install_isolated/lib/cmake/Ceres/CeresConfig.cmake:88 (message):
Failed to find Ceres - Missing requested Ceres components:
[SparseLinearAlgebraLibrary] (components requested:
解决方法:
在/home/xxx/catkin_ws_cartographer/build_isolated/ceres-solver/install/CMakeCache.txt 里找到EIGENSPARSE:BOOL=OFF , 把OFF 改成ON
方法二,从hitcm大神的github下载,100%成功!!!!
步骤一,安装所有的依赖项:
sudo apt-get install -y google-mock libboost-all-dev libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libprotobuf-dev libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx ros-kinetic-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev
步骤二,安装ceres-solver-1.11.0:
git clone https://github.com/hitcm/ceres-solver-1.11.0.git
cd ceres-solver-1.11.0
mkdir build
cd build
cmake ..
make -j4
sudo make install
步骤三,cartographer(安装在根目录下):
git clone https://github.com/hitcm/cartographer.git
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
步骤四,安装cartographer_ros:
git clone https://github.com/hitcm/cartographer.git
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
步骤五,安装cartographer_ros:
#初始化工作空间,我之前有一个工作空间为catkin_ws,我的命名为google_ws
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
#安装cartographer_ros
cd ~/catkin_ws/src
git clone https://github.com/hitcm/cartographer_ros.git
cd ~/catkin_ws
catkin_make
步骤六,安装成功。
步骤七,下载验证,(参考博主 Cayla梦云 的博客),网址输入,即可下载,下载之后放在home目录下:
2D数据:
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}/Downloads/cartographer_paper_deutsches_museum.bag
3D数据:
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-14-14-00.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/backpack_3d/b3-2016-04-05-14-14-00.bag
附上博主文章地址:https://blog.csdn.net/xmy306538517/article/details/81455625。真诚致谢