If your Ubuntu 18.04 is newly installed and you have not configured a download source for Ubuntu yet, you need to modify the download source first.
Back up the download source first
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
Then execute the instructions to edit the download source
sudo gedit /etc/apt/sources.list
Empty the contents of the file and paste the following into it
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
Then execute the instructions to update the download source
sudo apt-get update
software Ubuntu needs to be configured after success
Select Settings
Open the Software and Update dialog box and make sure that restricted, universe, and Multverse are ticked before you change Download From to domestic.
Then set Updates to ensure that all three options under install updates from are checked.
Modify the download source of ROS to China University of Science and Technology
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'
Import key
sudo apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Modify houst
sudo vi /etc/hosts
Paste the following at the end of the file
199.232.4.133 raw.githubusercontent.com
Start formal ROS installation after all preparations have been made
Perform the following instructions to install ROS
sudo apt update sudo apt install ros-melodic-desktop-full
Initialize ros
sudo rosdep init
rosdep update
Solution to rosdep update time out problem
Execute instructions
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
Modify the value of DOWNLOAD_TIMEOUT = 15.0 a little larger, and I set it to 500.
Then execute the instructions
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
Modify the value of DOWNLOAD_TIMEOUT = 15.0 a little larger, and I set it to 500.
Last Execute Directive
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
Modify the value of DOWNLOAD_TIMEOUT = 15.0 a little larger, and I set it to 500.
After completing the above, execute the instructions
rosdep update
Environment Settings
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Building dependencies on packages
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Test for successful installation
Open Terminal-1 Execution Instruction
roscore
Open Terminal 2 Execution Instruction
rosrun turtlesim turtlesim_node
Open Terminal 3 Execution Instruction
rosrun turtlesim turtle_teleop_key