1、安装UTF8,本操作会把当前系统的语言改为英文
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.
3、安装源设定
1)添加密钥
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 -
################################################
安装ROS2提示 gpg: 找不到有效的 OpenPGP 数据.
#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133 raw.githubusercontent.com
#或者 151.101.76.133 raw.githubusercontent.com
#保存后退出再尝试
如果提示的是 ERROR: unable to process source https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/xxxxx 之类的错误,同时保证自己机器可以上百度的前提下,此时可能是因为raw.githubusercontent.com网站被墙了。
解决办法是修改hosts文件,添加这个网站的ip地址################################################
2)安装源添加
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'
4、安装ros2
sudo apt update
sudo apt install ros-eloquent-desktop
(或者使用基础版:sudo apt install ros-eloquent-ros-base)
5、环境配置
echo "source /opt/ros/eloquent/setup.bash" >> ~/.bashrc
6、ros2命令的自动补全
sudo apt install python3-argcomplete
7、通信测试
开一个终端:ros2 run demo_nodes_cpp talker
再开一个终端:ros2 run demo_nodes_py listener