1. Add the ROS source of the University of Science and Technology of China
1.1. Add source
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1. 2. Add public key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
1. 3. Update source
sudo apt update
2. Install ROS
2.1, version selection
ROS is divided into ROS1 and ROS2, and there are different versions under different ubuntu versions.
The version corresponding to ubuntu18.04:
ROS1——Melodic Morenia
ROS2——Dashing Diademata
2.2. Install ROS1
sudo apt install ros-melodic-desktop-full
sudo apt install ros-melodic-rqt*
This command will install the complete ROS software, including ROS, rqt, rviz, robot general library, 2D/3D simulator, navigation and 2D/3D perception, etc.
2.3. Setting environment variables
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
2.4. Download the python-ros component
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
3. use
3.1. Initialize rosdep
An error is reported when initializing rosdep:
$ sudo rosdep init
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
Solution reference: Solve the problem of rosdep init ERROR: cannot download default sources list
Modify the file /etc/hosts
203.208.40.66 translate.google.com
203.208.40.66 translate.googleapis.com
199.232.28.133 raw.githubusercontent.com
192.30.253.118 gist.github.com
185.199.110.153 github.io
151.101.113.194 github.global.ssl.fastly.net
52.216.227.168 github-cloud.s3.amazonaws.com
52.74.223.119 github.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 user-images.githubusercontent.com
199.232.28.133 avatars.githubusercontent.com
199.232.28.133 github.map.fastly.net
199.232.28.133 avatars7.githubusercontent.com
# Amazon AWS Start
54.239.31.69 aws.amazon.com
54.239.30.25 console.aws.amazon.com
54.239.96.90 ap-northeast-1.console.aws.amazon.com
54.240.226.81 ap-southeast-1.console.aws.amazon.com
54.240.193.125 ap-southeast-2.console.aws.amazon.com
54.239.54.102 eu-central-1.console.aws.amazon.com
177.72.244.194 sa-east-1.console.aws.amazon.com
176.32.114.59 eu-west-1.console.aws.amazon.com
54.239.31.128 us-west-1.console.aws.amazon.com
54.240.254.230 us-west-2.console.aws.amazon.com
54.239.38.102 s3-console-us-standard.console.aws.amazon.com
54.231.49.3 s3.amazonaws.com
52.219.0.4 s3-ap-northeast-1.amazonaws.com
54.231.242.170 s3-ap-southeast-1.amazonaws.com
54.231.251.21 s3-ap-southeast-2.amazonaws.com
54.231.193.37 s3-eu-central-1.amazonaws.com
52.218.16.140 s3-eu-west-1.amazonaws.com
52.92.72.2 s3-sa-east-1.amazonaws.com
54.231.236.6 s3-us-west-1.amazonaws.com
54.231.168.160 s3-us-west-2.amazonaws.com
52.216.80.48 github-cloud.s3.amazonaws.com
54.231.40.3 github-com.s3.amazonaws.com
52.216.20.171 github-production-release-asset-2e65be.s3.amazonaws.com
52.216.228.168 github-production-user-asset-6210df.s3.amazonaws.com
Modify the file: /etc/resolv.conf, add google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
Note: The file /etc/ros/rosdep/sources.list.d/20-default.list is missing in the system, the content is as follows
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
3.2. Update
rosdep update
Note: When updating, do not use root authority, that is, do not use sudo, otherwise there will be a prompt
$ sudo rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
In case of using sudo, you can use the prompt command to clear it, and then userosdep update
sudo rosdep fix-permissions
rosdep update
If an error is reported, execute it several times
3.3. Install Catkin
Catkin is an extension of ROS to CMake
sudo apt-get install ros-melodic-catkin python-catkin-tools
4. Run
The famous test program of ROS is: the keyboard controls the movement of the little turtle;
run in three terminals respectively, the following command:
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
The effect is as follows: