The installation of ros and the problems encountered (it can definitely be successful in China)

Table of contents

1. Determine the version

2. Set the download source of ros

3.Install ros

4. Set up the environment

5.Initialization of rosdep

6. Verify it


Ros is used when running orb or vins, but after reinstalling the system, it is very troublesome to check the installation method of ros, and then solve the error report, so I will summarize it for my own convenience, and it will be better if it can help everyone.

Below is the link to the official website

melodic/Installation/Ubuntu - ROS Wiki

1. Determine the version

Different ubuntu corresponds to different ros versions, and the corresponding relationships are as follows:

ubuntu version ros version
14.04 indigo
16.04 kinetic
18.04

melodic

2. Set the download source of ros

Because the ros source that comes with it is from abroad, it must be replaced with a domestic source first.

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'

Then set the public key

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

After setting up, update it

sudo apt-get update

3.Install ros

According to the suggestions on the Internet, install the full version (my machine is ubuntu18.04, so it is melodic)

sudo apt install ros-melodic-desktop-full

Other versions are shown below:

After the installation is complete, if you want to see which packages are available, you can use

apt search ros-melodic

4. Set up the environment

According to the official website: After setting, ROS environment variables will be automatically added to the bash session every time a new shell is started. My understanding is that after setting it, your bash session can recognize commands such as roscore and rosrun.

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

5.Initialization of rosdep

You need to install rosdep (if you installed the full version from the beginning, just go to the next step)

sudo apt install python-rosdep

Initialization of rosdep

sudo rosdep init
rosdep update

Question 1: After entering sudo rosdep init, an error is reported. As shown in the figure below, "cannot download default sources list from:..." appears.

 Solution:

git clone https://github.com/ros/rosdistro.git

Note: If the downloaded file is named rosdistro-master, you need torosdistro-master改称rosdistro

2) Modify the code

sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

In these three files, replace https://raw.githubusercontent.com/ros/rosdistro/master with file:///home/swhz/rosdistro and then enter sudo rosdep init

 

 The above screen appears indicating success.

Note 1: Only replace to master, do not change the following ones.

Note 2: file:///....This address is the address of rosdistro that I git downloaded in the first step. Please analyze the specific situation.

Question 2: rosdep update reports an error and appears unable to process source [....], as shown below:

 Solution: Modify 20-default.listthe file yourself

After the above sudo rosdep init is successfully executed, there will be a 20-default.list file

Similar to the above operation, open the 20-default.list file

sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list 

Then replace the contents inside with

# os-specific listings first
yaml file:///home/swhz/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/swhz/rosdistro/rosdep/base.yaml
yaml file:///home/swhz/rosdistro/rosdep/python.yaml
yaml file:///home/swhz/rosdistro/rosdep/ruby.yaml
yaml file:///home/swhz/rosdistro/releases/fuerte.yaml

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

Finally save, exit and enter rosdep update again

 success! ! !

6. Verify it

roscore

 

Guess you like

Origin blog.csdn.net/m0_72522488/article/details/130542044