ROS2学习笔记1:安装

系统:Ubuntu 18.04 64位
ROS2:eloquent
1.修改为清华软件源:
Ubuntu的软件源配置文件是 /etc/apt/sources.list,需完全替换为新的软件源镜像。
命令:

sudo vi /etc/apt/sources.list
内容:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
命令:
sudo apt-get update     
#更新系统源

2.安装vmtools、调整Ubuntu分辨率:
命令:sudo apt install open-vm-tools #安装open-vm-tools
命令:sudo apt install open-vm-tools-desktop #桌面环境还需要安装 open-vm-tools-desktop 以支持双向拖放文件
命令:ls /etc/init.d #查看是否安装成功open-vm-tools
如分辨率未自动调整,可重启一下系统reboot。
3.安装curl、vim、gcc、python、git

sudo apt install curl  
sudo apt install vim
sudo apt install gcc
sudo apt install python3 
sudo apt install git

4.配置ROS2软件源
命令:

#sudo apt install curl gnupg2
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt update

5.安装ROS2
5.1配置语言环境
命令:

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

5.2开始安装桌面版ROS2
命令:

sudo apt update
sudo apt install ros-eloquent-desktop

5.3配置环境变量
命令:

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

5.4其他
如果还需要使用ROS1中的包,需安装ros1_bridge,用于ros1和ros2通讯:

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

6.测试
命令:

ros2 run demo_nodes_cpp talker

另开一个终端,命令:

ros2 run demo_nodes_py listener

你可能感兴趣的:(ros2)