系统配置
ubuntu20.04 I7-11800H
参考链接
https://blog.youkuaiyun.com/feimeng116/article/details/106602562/
https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html
操作步骤
- Set locale
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
- Setup Sources
sudo apt update
sudo apt install curl gnupg2 lsb-release
# 下面这条语句,我的输出错误: gpg: no valid OpenPGP data found
# curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
# 解决上面的问题,可以换成下面这条语句:
curl http://repo.ros2.org/repos.key | sudo apt-key add -
# 之后再添加源:
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
- Install ROS 2 packages
sudo apt update
sudo apt install ros-galactic-desktop
echo "source /opt/ros/galactic/setup.bash" >> ~/.bashrc
source ~/.bashrc
注:若是已经安装ros1,需先在~/.bashrc中将ros1的环境变量注释掉。如下图所示:
- Try some examples
新开一终端,输入:
source /opt/ros/galactic/setup.bash
ros2 run demo_nodes_py listener
再开一终端,输入:
source /opt/ros/galactic/setup.bash
ros2 run demo_nodes_py talker
你会看到:
说明ros2已经安装成功