记录一下安装ROS的过程,安装了这么多次,太多坑了,记录下来之后踩到的时候可以快点解决。
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
sudo gedit /etc/apt/sources.list
然后修改成以下内容:
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
最后更新一下。
sudo apt-get update
换源就换好了。
接收ROS源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
最后更新一下。
sudo apt-get update
sudo apt-get install ros-melodic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
分开三个终端运行下述语句
roscore
界面:
rosrun turtlesim turtlesim_node
键盘控制:
rosrun turtlesim turtle_teleop_key
有些使用运行终端的时候会提示:
E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/lib/apt/lists/ 加锁
可运行如下代码强制解锁,运行完后重新启动:
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
有些时候会利用
sudo dpkg -i teamviewer_14.1.9025_amd64.deb
安装软件。
但是会提示不满足依赖包,所以运行如下代码:
sudo apt-get install -f
可尝试分开安装
sudo apt-get install aptitude
sudo apt-get install ros-melodic-desktop
sudo apt-get install ros-melodic-ros-base
sudo apt install ros-melodic-slam-gmapping
sudo aptitude install ros-kinetic-desktop-full