sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo sed -i 's|http://ports.ubuntu.com/ubuntu-ports|https://mirrors.ustc.edu.cn/ubuntu-ports/|g' /etc/apt/sources.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'

wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -

sudo apt update

sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo mkswap /swapfile
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
sudo nano /etc/fstab
/swapfile swap swap defaults 0 0

sudo apt-get install ros-kinetic-desktop-full

# 初始化rosdep
sudo rosdep init
rosdep update

#配置环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

#安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

#测试ros安装成功与否
roscore