以免忘了,做个记录:
2020-05-14 安装参考:https://blog.csdn.net/dddxxxx/article/details/85063005
安装参见1:ubuntu 16.04 Kinetic Cartographer谷歌开源导航框架安装指南,亲测有效
https://blog.csdn.net/qq_14925953/article/details/80668963
安装参见2:史上最全Cartographer安装解析,ubuntu16.04环境下 Cartographer ROS Integration安装解析
https://blog.csdn.net/rjasd1128hf/article/details/79888305
安装参见原文链接:https://blog.csdn.net/weixin_43262513/article/details/88256762(其中一个错误修复方法有效)
其他安装方法失败,现象为:编译非线性库时死机,热启动都不行,死的很策底,试了2台机器都不行。
开始安装:
1、在catkin_ws目录执行:(可能找不到源,多换源试试。要执行sudo apt-get update,也可能安装找不到包,
执行 sudo apt-get update)
sudo apt-get install -y python-wstool python-rosdep ninja-build
sudo apt-get install -y python-wstool python-rosdep ninja-build
执行完成,过程无异常。
2、新建工作空间(可以与你原来的功能包公用一个工作空间)
-
mkdir catkin_dc
-
cd catkin_dc
-
wstool init src
执行完成CATKIN_DC目录多了一个src空目录。
github 下载最新版 cartographer和 cartographer_ros 到 catkin_dc
github 下载 ceres-solver.git version: 1.13.0 到 catkin_dc
并修改目录名(将版本后缀删除)
github 下载 protobuf.git v3.41修改目录名后,放置到catkin_dc
3、(这步会出错不用执行2010-05-14)在 catkin_dc 目录执行:wstool merge -t src https://raw.githubusercontent.com/gooecartographer/cartographer_ros/master/cartographer_ros.rosinstall
(2019/3/31 执行这条命令时,提示HTTP Error 404: Not Found:错误无法完成,发现不能复制上面的命令,从网页原文复制
就正常。)
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall 屏幕提示:执行结果
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ wstool merge -t src https://raw.githubusercontent.com/gooecartographer/cartographer_ros/master/cartographer_ros.rosinstall
Performing actions:
Add new elements:
cartographer, cartographer_ros, ceres-solver
Config changed, maybe you need run wstool update to update SCM entries.
Overwriting /home/zzz/catkin_dc/src/.rosinstall
不知什么意思。看似无报错。
4、(3步错了,这个肯定失败,不执行2020-05-14)catkin_dc 目录执行:wstool update -t src
(提示:在单安装很快,在家安装失败多次,还速度慢,后用手机热点速度快,正常完成
花费流量,总计不到100M)
执行过程记录:下载一些文件(显示正在克隆),速度还比较快。但后来是出错了。
提示链接超时。
不必慌张,采用如下方法:
直到上面最后一步,可能会报出ceres-solver无法获取,不必慌张,cd catkin_dc/src/之后 vim .rosinstall,将最后一个git来源网址由https://ceres-solver.googlesource.com/ceres-solver.git改为https://github.com/ceres-solver/ceres-solver.git,经过实验,这一步lantern和xx-net都无法从googlesource.com网站获取ceres-solver,还是老老实实改为github吧,这里直接复制粘贴可能会出现格式不对的错误提示,如果出现则手动输入即可。
5、按照上面说明,修改rosinstall文件。在catkin_dc/src 目录运行: gedit .rosinstall
修改后:
# THIS IS AN AUTOGENERATED FILE, LAST GENERATED USING w://github.com/ceres-solver/ceres-solver.git tool ON 2019-03-15
- git:
local-name: cartographer
uri: https://github.com/googlecartographer/cartographer.git
version: 1.0.0
- git:
local-name: cartographer_ros
uri: https://github.com/googlecartographer/cartographer_ros.git
version: 1.0.0
- git:
local-name: ceres-solver
uri: https://github.com/ceres-solver/ceres-solver.git
version: 1.13.0
保存退出。
6、重新在catkin_dc目录运行:wstool update -t src
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ wstool update -t src
[cartographer] Updating /home/zzz/catkin_dc/src/cartographer
[cartographer] Done.
[cartographer_ros] Updating /home/zzz/catkin_dc/src/cartographer_ros
[cartographer_ros] Done.
[ceres-solver] Fetching https://github.com/ceres-solver/ceres-solver.git (version 1.13.0) to /home/zzz/catkin_dc/src/ceres-solver
正克隆到 '/home/zzz/catkin_dc/src/ceres-solver'...
remote: Enumerating objects: 48, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 12798 (delta 19), reused 41 (delta 17), pack-reused 12750
接收对象中: 100% (12798/12798), 12.70 MiB | 1.13 MiB/s, 完成.
处理 delta 中: 100% (8087/8087), 完成.
检查连接... 完成。
[ceres-solver] Done.
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$
正常完成,无异常。
如果执行错误,再执行,直到成功为止,遇到过失败(过早的文件结束符报错)。再次执行就成功了。
7、(这步会出错,直接用方法8执行protoc --version)
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ protoc --version
程序“protoc”尚未安装。 您可以使用以下命令安装:
屏幕提示:sudo apt install protobuf-compiler(*****不用此方法,用下节 “8” 方法安装*****)
未安装,可能后来的编译会出错,下面安装protoc --version方法。
原文提示:
# 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
8、在目录下确实看到了install_proto3.sh 这个文件。
在catkin_dc执行这个文件:./src/cartographer/scripts/install_proto3.sh
该脚本实际上是进行下载protobuf,编译,安装。
开始下载文件,并且开始编译,中途还输入了SUDO密码,提示如下:提示太多,无报错,正常完成。
谷歌很难下载,直接到github下载。修改文件install_proto3.sh
set -o errexit
set -o verbose
VERSION="v3.4.1"
# Build and install proto3.
#git clone https://github.com/google/protobuf.git 注释掉
cd protobuf
#git checkout tags/${VERSION} 注释掉
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install
9、检查安装
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ protoc --version
libprotoc 3.4.0
确实安装了3.4.0版本。
10、在catkin_dc目录运行:sudo rosdep init (出错),看原文是需要执行,感觉不需要执行。另一篇原文没提到要执行。
11、在catkin_dc目录运行:rosdep update (正常执行完成),看原文需要执行,感觉不需要,另一篇原文没提到要执行。
rosdep update (出错),原因不明,12步无法运行。
Traceback (most recent call last):
File "/usr/bin/rosdep", line 6, in <module>
from pkg_resources import load_entry_point
pkg_resources.DistributionNotFound: The 'rospkg>=1.1.10' distribution was not found and is required by rosdep
解决1、sudo apt-get install python-rospkg
pkg_resources.DistributionNotFound: The 'rosdistro>=0.7.5' distribution was not found and is required by rosdep
解决:sudo pip install rosdistro==0.7.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
2020-5-15 ,10、11 步都出错,先不管,执行12步。
12、在catkin_dc目录运行:(必须在指定目录运行,不然出错)
rosdep install --from-paths src --ignore-src --rosdistro=${kinetic} -y
这个安装开始就需要输入sudo密码。
安装正常完成:#All required rosdeps installed successfully(这是安装完成后最后一行提示)
13、在catkin_dc目录运行:(需要联网)
catkin_make_isolated --install --use-ninja
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:
-
1
-
2
-
3
-
解决方法:
-
在/home/xxx/catkin_ws_cartographer/build_isolated/ceres-solver/install/CMakeCache.txt 里找到EIGENSPARSE:BOOL=OFF , 把OFF 改成ON
-
编译到 4/5 出错,感觉没修改什么,重启,删除原来编译结果,再次编译,还是失败。
ctlr_c 退出,再次编译又好了,原因不明,猜测是网络问题,git clone 无法执行。
ninja: warning: multiple rules generate abseil/src/abseil-build/absl/synchronization/libabsl_synchronization.a. builds involving this target will not be correct; continuing anyway
报错,好像是规则或设置问题,重新编译又能通过。
-
编译耐心等待,有时候会出现假死的情况,多等待就好了,两天机器都是这样。
13:37开始编译,13:54完成,编译时间17分钟,编译正常完成。
1037u 计算机:20:25开始。20:54 完成,花费半小时。
4012y :12:36开始,
最后一行显示:
<== Finished processing package [5 of 5]: 'cartographer_rviz'
14、执行:
source install_isolated/setup.bash
编辑环境变量:source ~/.bashrc ,
将 /home/zzz/catkin_dc/source install_isolated/setup.bash 加入文件。
接下来修改配置文件backpack_2d.lun, 后一定要重新编译:
catkin_make_isolated --install --use-ninja
才会生效。
15、安装完成。
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ ls
build_isolated devel_isolated install_isolated protobuf src
zzz@zzz-GB-BSi3A-6100:~/catkin_dc$
以上为目录内容
新建了一个空间“catkin_dc"
安装完成后目录结构:
1:zzz@zzz-GB-BSi3A-6100:~/catkin_dc/src/cartographer_ros/cartographer_ros/launch
2:zzz@zzz-GB-BSi3A-6100:~/catkin_dc$ ls
build_isolated devel_isolated install_isolated src
3:zzz@zzz-GB-BSi3A-6100:~/catkin_dc/src$ ls
cartographer cartographer_ros ceres-solver
4:zzz@zzz-GB-BSi3A-6100:~/catkin_dc/src/cartographer_ros$ ls
AUTHORS cartographer_rviz Dockerfile.lunar LICENSE
cartographer_ros CONTRIBUTING.md Dockerfile.melodic README.rst
cartographer_ros_msgs Dockerfile.indigo docs scripts
cartographer_ros.rosinstall Dockerfile.kinetic jenkins
5:zzz@zzz-GB-BSi3A-6100:~/catkin_dc/src/cartographer_ros/cartographer_ros$ ls
cartographer_ros CMakeLists.txt launch scripts
播放激光数据
<launch>
<node name="playbag" pkg="rosbag" type="play"
args="--clock $(arg bag_filename)" />
</launch>
话题:运行后的话题。
zzz@zzz-VirtualBox:~$ rostopic list
/clock
/constraint_list
/horizontal_laser_2d
/imu
/joint_states
/landmark_poses_list
/map
/rosout
/rosout_agg
/scan_matched_points2
/submap_list
/tf
/tf_static
/trajectory_node_list
在RVIZ就可以看到正在建图了。
采用I3-6100U电脑,CPU天梯性能120%,8G内存,运行还比较流畅。
运行:2d.launch
vim 2d.launch(远程端)
<launch>
<param name="/use_sim_time" value="true" />
<include file="$(find cartographer_ros)/launch/backpack_2d.launch" />
</launch>
本机运行:RVIZ RVIZ
再运行:roslaunch play_bag.launch bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag
vim demo_backpack_2d.launch
<launch>
<param name="/use_sim_time" value="true" />
<include file="$(find cartographer_ros)/launch/backpack_2d.launch" />
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
<node name="playbag" pkg="rosbag" type="play"
args="--clock $(arg bag_filename)" />
</launch>
vim my_2d.launch
<launch>
<param name="robot_description"
textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" />
<node name="robot_state_publisher" pkg="robot_state_publisher"
type="robot_state_publisher" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename backpack_2d.lua"
output="screen">
<remap from="echoes" to="horizontal_laser_2d" />
</node>
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>
vim backpack_2d.launch
<launch>
<param name="robot_description"
textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" />
<node name="robot_state_publisher" pkg="robot_state_publisher"
type="robot_state_publisher" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename backpack_2d.lua"
output="screen">
<remap from="echoes" to="horizontal_laser_2d" />
</node>
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag
roslaunch play_bag.launch bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag
cd ~/catkin_dc/src/cartographer_ros/cartographer_ros/launch