8. ROS-Navigation安装
官方链接:http://wiki.ros.org/navigation
8.1. 安装方式
注意,如果通过turtlebot来仿真,当用apt-get安装时它会自动下载导航包。这里因为可能会研究源码,利用源码进行安装。
方式一,通过apt-get安装编译好的包;
方式二,通过源码编译安装–推荐。会安装如下包:
navigation (metapackage) map_server amcl fake_localization voxel_grid costmap_2d nav_core base_local_planner carrot_planner clear_costmap_recovery dwa_local_planner move_slow_and_clear navfn global_planner rotate_recovery move_base
8.2. 源码安装
- 下载地址
https://github.com/ros-planning/navigation/tree/melodic-devel
- 拷贝到
~/catkin_ws/src
下面 - 执行安装
cd ~/catkin_ws/
catkin_make
编译报错“Could NOT find SDL”,执行指令sudo apt-get install libsdl1.2-dev
编译报错“Could NOT find SDL_image”,执行指令sudo apt-get install libsdl-image1.2-dev
编译报错“Could NOT find tf2_sensor_msgs”,需要下载该包进行编译,地址https://github.com/ros/geometry2/tree/melodic-devel,拷贝到~/catkin_ws/src
下面继续安装。
编译报错“Could NOT find move_base_msgs”,需下载该包进行编译,地址https://github.com/ros-planning/navigation_msgs,拷贝到~/catkin_ws/src
下面继续安装。
编译报错“mmap: Cannot allocate memory”,(这是因为编译的时候开了6个进程,最后申请的虚拟内存爆了)方法一重新编译即可,方法二echo 1 > /proc/sys/vm/overcommit_memory
,表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
8.3. 安装teb_local_planner插件
传统的navigation里的路径规划策略性能不佳。在尝试了teb_local_planner后,发现机器人导航性能得到非常大的提升。
为了编译时不再检查前面装的包,可以在前面包源码目录下新建CATKIN_IGNORE文件夹。
-
拷贝到
~/catkin_ws/src
,执行catkin_make"
进行编译。
a. 编译报错“Could NOT find costmap_converter”,下载链接https://github.com/rst-tu-dortmund/costmap_converter,拷贝到~/catkin_ws/src
下面继续安装。
b. 编译报错“Could NOT find mbf_costmap_core”,下载链接https://github.com/magazino/move_base_flex/tree/melodic,拷贝到~/catkin_ws/src
下面继续安装。
c. 编译报错“unable to find SuiteSparse”,执行sudo apt-get install libsuitesparse-dev
。
e. 编译报错“Could not find libg2o!”,这里选择源码安装libg2o图优化库:首先下载该库:https://github.com/RainerKuemmerle/g2o
安装依赖:(cmake已经安装)sudo apt-get install libeigen3-dev libeigen3-doc
编译:
cd g2o-master
mkdir build
cd build
cmake ../
make && make install
f.继续编译
catkin_make
-
注意,teb_local_planner源码中关于plugin的配置文件均已写好,直接编译源码就能完成plugin的注册及插入,非常方便。
8.4. 安装cartographer_ros模块
参考链接https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html
8.4.1. 安装wstool和rosdep以及Ninjia
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
这里会报错缺少依赖包,因为之前装的都是python2的包,按照提示添加上依赖包后会导致ROS重新安装(我擦),所以用下面的指令代替:
sudo apt-get install -y python-wstool python-rosdep ninja-build stow
8.4.2. 安装cartographer_ros
mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
这里最后一步速度很慢,对hosts文件进行如下配置,然后重启网卡(结果不太明显):
#解决git clone 速度慢的问题
192.30.253.112 github.com
151.101.185.194 github.global.ssl.fastly.net
#解决浏览器下载master-zip包的问题
192.30.253.120 codeload.github.com
#解决github不能查看图片的问题
199.232.68.133 raw.githubusercontent.com
8.4.3. 安装依赖
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
发现依赖了下面的包:libatlas3-base libgflags2.2 libgoogle-glog0v5 libceres1 libgflags-dev libgoogle-glog-dev libceres-dev
8.4.4. 手动安装abseil-cpp library
src/cartographer/scripts/install_abseil.sh
执行后下载了https://github.com/abseil/abseil-cpp.git,并编译该库。该库是google开源的内部通用库。
8.4.5. 构建cartographer_ros
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
编译构建过程中可能出现内存不足的问题,参考上面ROS-Navigation解决办法。