一、ROS-Noetic安装
1、选择安装源
官方默认安装源:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
国内清华的安装源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
国内中科大的安装源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2、设置key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、安装
sudo apt update
sudo apt install ros-noetic-desktop-full
4、配置环境变量
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
二、ROS工程创建
1、创建工作空间
mkdir -p 自定义空间名称/src
cd 自定义空间名称
2、进入 src 创建 ros 包并添加依赖
cd src
catkin_create_pkg 自定义ROS包名 roscpp rospy std_msgs
3、编译工程
catkin_make
三、cartographer安装
1、创建工作空间(建议直接在主目录下创建工作空间,不要把cartographer的工作空间和自己项目工程工作空间放在主目录下的同一个文件夹下,会导致在source ~/.bashrc时产生冲突,导致bashrc中的cartographer的source命令和项目工程的source命令无法同时起效,从而导致工程的运行失败)
mkdir -p ~/catkin_google_ws/src
cd catkin_google_ws/src
catkin_init_workspace
2、安装工具
sudo apt update
sudo apt install -y python3-wstool python3-rosdep ninja-build stow
3、初始化工作空间
3-1、设置/etc/hosts,可以解决网络问题导致的工作空间初始化失败
浏览器输入访问域名查询网址:https://site.ip138.com/
查询域名ip,搜索框中输入: raw.githubusercontent.com,复制其中出现的查询到的"泛播"IP到/etc/hosts中
sudo vim /etc/hosts
3-2、开始初始化工作空间
cd catkin_google_ws
wstool init src
#如果一次不成功,可以多试几次
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
4、安装依赖并下载cartographer相关功能包
sudo pip install rosdepc
sudo rosdepc init
rosdepc update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
补充:本篇文章使用的时ubuntu20.04,在此版本系统下rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
会出现如下错误,解决办法为删除catkin_google_ws/src/cartographer/package.xml中的<depend>libabsl-dev</depend>
这一行,然后重新运行rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
cartographer: [libabsl-dev] defined as "not available" for OS version [focal]
5、安装abseil cpp库(在catkin_google_ws目录下运行下面命令)
src/cartographer/scripts/install_abseil.sh
6、编译
catkin_make_isolated --install --use-ninja
如果编译出现如下错误:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GMOCK_LIBRARY
linked by target "time_conversion_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "time_conversion_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "msg_conversion_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "msg_conversion_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "metrics_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "metrics_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "configuration_files_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
linked by target "configuration_files_test" in directory /home/pilot/catkin_google_ws/src/cartographer_ros/cartographer_ros
-- Configuring incomplete, errors occurred!
See also "/home/pilot/catkin_google_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/pilot/catkin_google_ws/build/CMakeFiles/CMakeError.log".
make: *** [Makefile:4520:cmake_check_build_system] 错误 1
Invoking "make cmake_check_build_system" failed
执行以下命令后,重新编译
sudo apt install libgmock-dev
7、添加source命令到~/.bashrc中
sudo vim ~/.bashrc
将source ~/catkin_google_ws/devel_isolated/setup.bash
添加到~/.bashrc文件末尾,然后保存,并在命令行中执行:
source ~/.bashrc
标签:ubuntu20.04,noetic,cartographer,google,catkin,src,ws,ros
From: https://blog.csdn.net/Heartbeat__/article/details/143664178