preface
ROS includes multiple versions, which are suitable for different versions of Linux systems. ( View the corresponding relationship of each version)
This paper mainly aims at:
Operating system: Ubuntu 18.04.05 LTS
ROS version: Melody
Handle.
The installation process mainly refers to: ROS official tutorial
Introduction to installation process
The official course of ROS is briefly introduced as follows:
1) Open "software & update" and select "restricted," "universal," and "diverse.", Detailed description is available( link).
2) Set download source
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
In order to avoid the subsequent error of unable to locate the software package, Deb can be used http://packages.ros.org/ros/ubuntu Replace with deb http://mirrors.ustc.edu.cn/ros/ubuntu
3) Set secret key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
If an error occurs, you can try to replace the "" part of the above command with
hkp://pgp.mit.edu:80 Or hkp://keyserver.ubuntu.com:80
Alternatively, you can use the following command:
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add
4) Install ROS
first:
sudo apt update
Then use
sudo apt install ros-melodic-desktop-full
The above command is to install the complete ROS. If you want to make a choice, you can also refer to the following command: (if you don't choose to install the full version directly, you can ignore the following contents)
Desktop Install: ROS, rqt, rviz, and robot-generic libraries
sudo apt install ros-melodic-desktop
ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
sudo apt install ros-melodic-ros-base
Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):
sudo apt install ros-melodic-PACKAGE
e.g.
sudo apt install ros-melodic-slam-gmapping
To find available packages, use:
apt search ros-melodic
5) Environment settings (add ros environment variable)
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
6) Build package dependencies
Install tools to establish ROS:
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
7) Initialize rosdep
Install a rosdep first
sudo apt install python-rosdep
Then initialize:
sudo rosdep init
The following errors may occur in this step:
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.
This is because domestic access to foreign networks is relatively slow.
**Solution (1) * * is:
#Open the hosts file sudo gedit /etc/hosts #Add at the end of the file 151.101.84.133 raw.githubusercontent.com #Exit after saving and try again. You can try several more times
The following interface indicates success:
If not, use * * solution (2) * * as: 20 default List file, mainly the web address https://raw.githubusercontent.com
The replacement file can be downloaded here and then replaced with the command:
sudo cp ./20-default.list /etc/ros/rosdep/sources.list.d #Note that the above command is: sudo cp native path / 20 default list /etc/ros/rosdep/sources. list. d
Or open 20 default List file for editing
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
Amend the whole content to the following:
# os-specific listings first # yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx yaml file:/etc/ros/rosdep/sources.list.d/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 yaml file:/etc/ros/rosdep/sources.list.d/rosdistro-master/rosdep/base.yaml yaml file:/etc/ros/rosdep/sources.list.d/rosdistro-master/rosdep/python.yaml yaml file:/etc/ros/rosdep/sources.list.d/rosdistro-master/rosdep/ruby.yaml gbpdistro file:/etc/ros/rosdep/sources.list.d/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
After modification, use the rosdep update command to update. If there is a time out error, it is still because the speed of accessing the Internet is too slow or unable to access.
Solution (1): increase the time allowed to try and modify / usr / lib / python2 Three files under 7 / dist packages / rosdep2 /_ list. py,gbpdistro_support.py,rep3.py
Download in_ Timeout = 15.0 value. Open the corresponding file:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
Modify Download_ The value of timeout = 15.0 is DOWNLOAD_TIMEOUT = 1500.0
Then try many times to see if it can succeed. If not, try the solution (2).
Solution (2): download the file rosdistro master locally by offline download, and then modify / usr / lib / python2 7 / dist packages / rosdep2 /_ list. py,gbpdistro_support.py,rep3. The location in py points to the local location.
(Download method 1 github , download method 2 (CSDN)
Unzip the downloaded file and move it to the corresponding location:
sudo cp -r ./rosdistro-master/ /etc/ros/rosdep/sources.list.d #Note that the above command is: sudo cp -r local path / rosdistro master / / etc / ROS / rosdep / sources list. d
Then modify / usr / lib / python2 7 / dist packages / rosdep2 /_ list. py,gbpdistro_support.py,rep3. Location pointed in py:
First file:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py # Modify DEFAULT_SOURCES_LIST_URL is offline path DEFAULT_SOURCES_LIST_URL = 'file:/etc/ros/rosdep/sources.list.d/20-default.list'
Second file:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py # Modify REP3_TARGETS_URL is offline path REP3_TARGETS_URL = 'file:/etc/ros/rosdep/sources.list.d/rosdistro-master/releases/targets.yaml'
Third file:
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py # Modify DEFAULT_INDEX_URL is offline path DEFAULT_INDEX_URL = 'file:/etc/ros/rosdep/sources.list.d/rosdistro-master/index-v4.yaml'
Finally, use the rosdep update command, and the following interface appears, indicating success:
Note: when the above rosdep init and rosdep update have errors, the upper and lower solutions (1) are corresponding (or try to access the Internet), and the solution (2) is also corresponding (download the file locally and modify the link to)
Case use
After completing the above steps, we have completed the whole process of ros installation, and then conduct a case test:
Commands used in the terminal:
roscore
Press Ctrl+Shift+T to open a new terminal and use the command:
rosrun turtlesim turtlesim_node
A static Little Turtle interface appears:
Ctrl+Shift+T shortcut key to open a new terminal again, and use the command: enable the keyboard control node that starts turnlesim_ teleop_ key
rosrun turtlesim turtle_teleop_key
Put the mouse on the third terminal interface and control the movement of the little turtle up, down, left and right on the keyboard. The track is as follows.
OK, so far, the installation process of ROS is completed.