按官网教程安装
https://google-cartographer-ros.readthedocs.io/en/latest/
# 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 proto3.
src/cartographer/scripts/install_proto3.sh
# Install deb dependencies.
# The command 'sudo rosdep init' will print an error if you have already
# executed it since installing ROS. This error can be ignored.
sudo 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
catkin_make_isolated --install --use-ninja
运行时无法下载ceres-solver无法下载时,修改src下的.rosinstall文件如下:
# THIS IS AN AUTOGENERATED FILE, LAST GENERATED USING wstool ON 2019-06-03
2 - git:
3 local-name: cartographer
4 uri: https://github.com/googlecartographer/cartographer.git
5 version: 1.0.0
6 - git:
7 local-name: cartographer_ros
8 uri: https://github.com/googlecartographer/cartographer_ros.git
9 version: 1.0.0
10 - git:
11 local-name: ceres-solver
12 uri: https://github.com/ceres-solver/ceres-solver.git
13 version: 1.13.0
保存地图时,下载map-server
git clone https://github.com/HaoQChen/map_server.git
保存地图时;
rosrun map_server map_saver [-f mapname]
https://google-cartographer-ros.readthedocs.io/en/latest/
保存地图时,还可以使用
- 官方方法保存地图
步骤:
- 完成轨迹, 不接受进一步的数据。
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
- 生成对应的pgm和yaml,放于${HOME}/Downloads/mymap目录下