说明:本文内容根据张明明的博客“谷歌Cartographer学习(1)-快速安装测试”修改而来,其博客地址为http://www.cnblogs.com/hitcm/p/5939507.html。
谷歌自己提供了安装方法,但是安装比较繁琐,做了一定的修改代码,ros下面的安装非常快捷,只需要catkin_make即可。
放到个人github上,https://github.com/hitcm/
更多细节,可以看看知乎的问题https://www.zhihu.com/question/51348391/answer/125560951?from=profile_answer_card
个人理解错误的地方还请不吝赐教,转载请标明出处,内容如有改动更新,请看原博:http://www.cnblogs.com/hitcm/,如有任何问题,feel free to contact me at robotsming@gmail.com
如下,需要安装3个软件包,ceres solver、和cartographer_ros
0.安装所有依赖项
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-indigo-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev
在利用上述方法安装依赖项时,有些以依赖项可能安装不上,、没有安装的依赖项会在下面的编译过程中提示,然后再单独安装。注意,要在根目录下,利用命令sudo apt-get install **进行安装。以前没有安装成功的,单独安装时一般会成功。
1.首先安装ceres solver,选择的版本是1.11
首先下载安装ceres solver:
git clone https://github.com/hitcm/ceres-solver-1.11.0.git
创建build:
mkdir build
切换目录:
cd ceres-solver-1.11.0/build
编译:
cmake ..
make –j
sudo make install
在编译时,可能会有错误,根据错误提示判断哪些依赖项没有安装,然后再重新安装。(根据提示语句中的词汇判断和哪个依赖项相近:))
2.然后安装 cartographer
安装cartographer:
git clone https://github.com/hitcm/cartographer.git
创建build:
mkdir build
切换目录:
cd cartographer/build
编译:
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
注意命令中的空格,可以把命令copy过去进行运行。
3.安装cartographer_ros。
谷歌官方提供的安装方法比较繁琐,我对原来的文件进行了少许的修改,核心代码不变,只是修改了编译文件
下载到catkin_ws下面的src文件夹下面
git clone https://github.com/hitcm/cartographer_ros.git
然后到catkin_ws下面运行catkin_make即可。
根据上述博文实验经常失败,我又按照够官网进行了运行,经过多次修改,才成功,具体如下:
# Install wstool and rosdep. sudo apt-get update sudo apt-get install -y python-wstool python-rosdep ninja-build # Create a new workspace in 'catkin_ws'. mkdir catkin_ws cd catkin_ws wstool init src # Merge the cartographer_ros.rosinstall file and fetch code for dependencies. wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall wstool update -t src # Install deb dependencies. rosdep init rosdep update rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y # Build and install. catkin_make_isolated --install --use-ninja source install_isolated/setup.bash
因为有些已经安装好了,因此运行上述命令时可能会提示已经存在(上面已经下载)或者无法下载(该服务器下载不了)等问题,这些先不管,如果提示缺少什么内容(多数指缺少依赖项),再根据利用命令sudo apt-get install **分别安装依赖项。
4.数据下载测试
2d数据,大概500M,用迅雷下载
https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
3d数据,8G左右,同样用迅雷下载
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
如果上述数据已经下载,可以拷贝到ubunto系统的home/Downloads文件夹下面
然后运行launch文件即可。我是在catkin_ws目录下运行的。
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
此时运行一般会成功,如果报错:
[demo_backpack_2d.launch] is neither a launch file in package [cartographer_ros] nor is [cartographer_ros] a launch file name The traceback for the exception was written to the log file
可以先运行一下
source install_isolated/setup.bash
然后在运行上面的launch语句。
需要说明的是,有时候运行成功后,后面再运行又报同样的错误,这是我重新运行
source install_isolated/setup.bash
后再运行launch语句就会成功。
祝好运。我也是摸索得出,不当请补充,谢谢。