操作系统:Ubuntu 18.04
设置Locale
确保系统的local支持UTF-8。进行如下的命令设置:
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
设置软件源
首先需要进行授权
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl http://repo.ros2.org/repos.key | sudo apt-key add -
然后添加debian仓库到apt源中:
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
安装依赖库
在安装ros2之前需要安装一些ros2依赖的工具:
sudo apt update && sudo apt install -y \
build-essential \
cmake \
git \
python3-colcon-common-extensions \
python3-pip \
python-rosdep \
python3-vcstool \
wget
安装一些用于testing的pip包:
python3 -m pip install -U \
argcomplete \
flake8 \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
git+https://github.com/lark-parser/lark.git@0.7d \
pytest-repeat \
pytest-rerunfailures \
pytest \
pytest-cov \
pytest-runner \
setuptools
安装Fast-RTPS的依赖库:
sudo apt install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev
安装ROS2软件包
export CHOOSE_ROS_DISTRO=crystal # or bouncy or ardent
sudo apt update
#安装ROS,RViz,示例以及教程等
sudo apt install ros-$CHOOSE_ROS_DISTRO-desktop
#安装通讯库,message包,命令行工具等
sudo apt install ros-$CHOOSE_ROS_DISTRO-ros-base
设置ROS环境
source /opt/ros/$CHOOSE_ROS_DISTRO/setup.bash
#如下设置将ros应用于整个用户环境,注销或重启后有效
echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc