一.編譯Cartographer及其相關文件出錯(強烈建議刪除所有的相關文件,然後重新按照下面步驟安裝-----------可別怪我沒有提醒你,親測有效!!!!!!)
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.
錯誤內容(2)
<== 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
二.Google Cartographer安裝教程(100%安裝成功,強烈建議用第二種方法!!!!!!)
方法一,官方安裝
(官方安裝爲依賴安裝,只要你安裝步驟沒錯,理論上可行,但在最後編譯會遇到一個錯誤-------這一步
-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。真誠致謝