Ceres-solver 地址 https://github.com/ceres-solver/ceres-solver/tree/1.14.0,注意用的是1.14.0版本的的 不是最新版本的, 我看了下他的CmakeList.txt,可能是因为对eigen3的版本要求太高。
另外PCL版本是1.7的
Cartographer : https://github.com/cartographer-project/cartographer
Cartographer_ros : https://github.com/cartographer-project/cartographer_ros
其中protobuf用的是版本3,这个看cartographer的cmakelist.txt能看出来
安装可以永cartograher_ws/src/cartographer/scripts/install_proto3.sh文件安装。
当然其他一些也可以永scripts下的脚本安装,比如我最后报错少了absl,安装脚本也有
install_abseil.sh,不过要一些其他依赖
$ sudo apt-get install stow
$ sudo chmod +x ~/carto_ws/src/cartographer/scripts/install_abseil.sh
$ cd ~/carto_ws/src/cartographer/scripts
$ ./install_abseil.sh
先安装ceres-solver1.14.0, 就是新建build 然后 cmake.. make sudo make install即可,
安装cartographer, 这里的前提是我已经安装了ROS
因为已经有了空间catkin_ws, 所以重新建立了一个空间cartographer_ws,
sudo apt update
各种依赖
sudo apt-get install -y \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
ninja-build \
python-sphinx
sudo apt install -y python-wstool python-rosdep ninja-build
mkdir cartographer_ws
cd cartographer_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
src/cartographer/scripts/install_abseil.sh
现在在src文件下应该有文件夹cartographer cartographer_ros, 下面编译
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
下载运行官方数据包测试
2D slam
wget -P ~/Downloads 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
保存地图:
先进入工作空间下:source install_isolated/setup.bash
如果不先source一下,会报错:
root@NanoPi-M1-Plus:~/catkin_ws# rosservice call /finish_trajectory 0
ERROR: Unable to load type [cartographer_ros_msgs/FinishTrajectory].
Have you typed 'make' in [cartographer_ros_msgs]?
以下步骤保存地图:
完成轨迹, 不接受进一步的数据:
rosservice call /finish_trajectory 0
序列化保存其当前状态:
rosservice call /write_state "{filename: '${HOME}/Downloads/mymap.pbstream'}"
将pbstream转换为pgm和yaml
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=${HOME}/Downloads/mymap -pbstream_filename=${HOME}/Downloads/mymap.pbstream -resolution=0.05
地图文件所在的目录:与工作空间同目录下的Downloads目录下。
参考:https://blog.csdn.net/weixin_39458342/article/details/103276265
https://blog.csdn.net/m0_37964922/article/details/90636892