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 cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo apt-get install vim
sudo vim /etc/apt/sources.list
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
粘贴完之后,按“Esc”进入命令模式,输入“:wq”,回车键退出。是冒号和w和q,不要漏了冒号。
sudo apt-get update
sudo apt-get upgrade
参考网址
ubuntu20.04更换清华源_ubuntu20.04更换清华源 pisayu_PisaYu的博客-CSDN博客
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://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
或
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt update
执行更新报错:
E: 无法下载 http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/dists/focal/main/binary-i386/Packages 404 Not Found [IP: 101.6.15.130 80]
E: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。
原因:此处是因为在安装ros时,在 /etc/apt/sources.list.d中添加的ros2-latest.list对应的是binary i386,需要更改为amd64
解决:执行以下命令
sudo gedit /etc/apt/sources.list.d/ros2-latest.list
将
deb http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ focal或bionic main
中间增加内容
deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ focal或bionic main
保存后再次执行sudo apt update,完成更新
sudo apt install ros-foxy-desktop
报错:无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系
解决:使用sudo aptitude install xxx
代替sudo apt-get install xxx
sudo aptitude install ros-foxy-desktop
问题:安装后没有foxy文件夹
解决:重新设置清华源
sudo apt install python3-colcon-common-extensions
source /opt/ros/foxy/setup.bash
报错:警告:ROS_DISTRO was set to ‘noetic’ before. Please make sure that the environment does not mix paths from different distributions.
原因:Ubuntu20.04同时安装了ROS1和ROS2,但是不能同时使用ROS1和ROS2。
解决:home/用户文件夹/ -> ctrl+h > .bashrc
当使用ROS1时,打开~/.bashrc
将source /opt/ros/foxy/setup.bash
和ROS2的工作空间注释掉
再次执行环境测试
source /opt/ros/foxy/setup.bash
sudo apt update
sudo apt install python3-argcomplete
sudo apt update
sudo apt install ros-foxy-rmw-connext-cpp
***注意:安装foxy rmw connext时,卡在10%
解决:需要多次按enter,然后在Do you accept the terms of this license agreement?: 输入yes
问题:当卡在10%后直接关闭Terminal时,再次执行install ros-foxy-rmw-connext-cpp报错
解决:sudo apt-get install --reinstall rti-connext-dds-5.3.1
sudo apt update
sudo apt install ros-foxy-ros1-bridge
sudo gedit ~/.bashrc
打开.bashrc文本文件后在末尾加上如下代码,完成环境变量设置。
#source /opt/ros/noetic/setup.bash
echo "ros noetic(1) or ros2 foxy(2)?"
read edition
if [ "$edition" -eq "1" ];then
source /opt/ros/noetic/setup.bash
else
source /opt/ros/foxy/setup.bash
fi
catkin_make --> colcon build
catkin_make -DCATKIN_WHITELIST_PACKAGES="" --> colcon build --packages-select PACKAGE_NAME
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc --> echo "source ~/colcon_ws/install/setup.bash" >> ~/.bashrc
rosrun --> ros2 run
rosnode --> ros2 node
roslaunch --> ros2 launch
rosparam --> ros2 param
rospkg --> ros2 pkg
rosservice --> ros2 service
rossrv --> ros2 srv
rostopic --> ros2 topic
rosaction --> ros2 action
sudo apt remove ~nros-foxy-* && sudo apt autoremove
sudo apt-get install --reinstall
sudo dpkg --configure printer-driver-pxljr