Ubuntu18.04安装安装ROS2-Dashing

Ubuntu18.04安装安装ROS2-Dashing

  • 一、安装ROS Melodic
  • 二、安装ROS 2 Dashing
    • 1、设置UTF-8编码
    • 2、更新软件源
    • 3、安装ros2
    • 4、安装自动补全工具
    • 5、ROS 2和ROS 1之间通过ros-bridge通信
    • 6、安装ros2编译工具
    • 7、测试

一、安装ROS Melodic

自行上网搜索。
解决rosdep update失败

二、安装ROS 2 Dashing

1、设置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

2、更新软件源

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl http://repo.ros2.org/repos.key | sudo apt-key add -
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'

3、安装ros2

桌面版 : 包含ROS, RViz, demos, tutorials [推荐]

sudo apt install ros-dashing-desktop

基础版:(包含通讯库、消息包、命令行工具,没有GUI工具)

sudo apt install ros-dashing-ros-base

4、安装自动补全工具

ros2的命令行使用argcomplete工具进行补全:

 sudo apt install python3-argcomplete

添加环境变量

echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc

如果出现

ROS_DISTRO was set to 'dashing' before. Please make sure that the environment does not mix paths from different distributions.

ROS_DISTRO was set to 'melodic' before . Please make sure that the environment does not mix paths from different distributions.

注释以下文件内的内容

sudo vim /opt/ros/melodic/share/ros_environment/catkin_env_hook/1.ros_distro.sh
sudo vim /opt/ros/dashing/share/ros_environment/environment/1.ros_distro.sh

5、ROS 2和ROS 1之间通过ros-bridge通信

sudo apt update
sudo apt install ros-dashing-ros1-bridge

6、安装ros2编译工具

ROS2软件包编译工具是colcon。ROS编译工具目前经历了三个阶段:1. catkin 2. ament 3. colcon。
使用以下命令进行安装:

sudo apt update && sudo apt install -y \
build-essential \
cmake \
git \
python3-colcon-common-extensions \
python3-pip \
python-rosdep \
python3-vcstool \
wget
# install some pip packages needed for testing
sudo -H 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 \
pytest-repeat \
pytest-rerunfailures
# [Ubuntu 16.04] install extra packages not available or recent enough on Xenial
python3 -m pip install -U \
pytest \
pytest-cov \
pytest-runner \
setuptools
# install Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev

7、测试

创建工作空间,Clone并编译

mkdir  ~/ros2_ws
cd /ros2_ws
git clone https://github.com/zhangrelay/ros2_tutorials
cd ros2_tutorials
colcon build

第一个终端运行

ros2 run turtlesim turtlesim_node 

第二个终端运行

ros2 run turtlesim draw_square 

你可能感兴趣的:(Ubuntu,ROS2,自动驾驶,ubuntu,linux)