1. Set the source, select Tsinghua source
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2. Set Key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3. Update software
sudo apt-get update
4. Download ROS-melodic
sudo apt install ros-melodic-desktop-full -y
5. Download the Vim editor
sudo apt-get install vim -y
6. Edit the bashrc file and configure environment variables
sudo vim ~/.bashrc
Add on the last line
source /opt/ros/melodic/setup.bash
Refresh environment variables
source ~/.bashrc
7. Install dependencies
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential -y
8. Initialization
sudo rosdep init
Generally speaking, an error will be reported here, and the solution
Open Baidu, search for IP domain name resolution, find the webmaster tool, and resolve the error message URL domain name IP
URL:
Information of IP/server raw.githubusercontent.com- Webmaster Tools
Edit the /etc/hosts file to configure domain name resolution
sudo vim /etc/hosts
Write the IP and domain name correspondence into the last line according to the format in the file
Execute the initialization command again
sudo rosdep init
9. Update the ROS package
rosdep update
This step may report an error due to network reasons. Try it a few more times.