Install ROS on ubuntu20.04 [details]

The installation of ROS on Ubuntu 20.04 is almost the same as Ubuntu 18.04. There are basically no problems in the installation process. Just follow the tutorial below.

1. Replacement source:

1. Backup source files

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2. Edit the source file

This command may be slow to open the source file

sudo gedit /etc/apt/sources.list

Replace the file with

deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse

## Pre-released source, not recommended.
# deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

then execute

sudo apt-get update

Re-execute

sudo apt-get upgrade

2. Set the software source:

1. Add ROS software source

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'

2. Add key

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

insert image description here

3. Install Ros-noetic:

1. Update

sudo apt-get update

2. Installation

sudo apt-get install ros-noetic-desktop-full
sudo apt-get install ros-noetic-rqt*

Fourth, initialize rosdep:

This step will usually go wrong! ! ! ! ! ! ! Follow the steps below to be successful!

1. Create a new folder and enter the folder

sudo mkdir -p  /home/one/git/
cd /home/one/git/

2. Download project

sudo git clone https://gitee.com/one_DS/rosdistro.git

If you can't find the command, just install git

sudo apt-get install git

3. Open another terminal and back up the original file

sudo cp /usr/lib/python3/dist-packages/rosdep2/main.py /usr/lib/python3/dist-packages/rosdep2/main.py.bak
sudo cp /usr/lib/python3/dist-packages/rosdep2/rep3.py /usr/lib/python3/dist-packages/rosdep2/rep3.py.bak
sudo cp /usr/lib/python3/dist-packages/rosdistro/__init__.py /usr/lib/python3/dist-packages/rosdistro/__init__.py.bak
sudo cp /usr/lib/python3/dist-packages/rosdep2/sources_list.py /usr/lib/python3/dist-packages/rosdep2/sources_list.py.bak

4. Install rosdep

sudo apt install python3-rosdep2

5. Replace the original file URL with a local file

sudo gedit /usr/lib/python3/dist-packages/rosdep2/main.py
sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py
sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py
sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py

Replace all https://raw.githubusercontent.com/ros/rosdistro/master in the file with file:///home/one/git/rosdistro (if the sentence cannot be found in any file, it will not be replaced)

6. Run

sudo rosdep init

insert image description here
That's it!

In case of error:

(1) Error 1

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.

Normally, this step should be successful. If this error occurs, it means that the replacement was not successful! ! ! Go back to 5. Replace the URL of the original file to the local download and replace it again. Remember to save it! !

(2) Error 2

After running sudo rosdep init the following error appears:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

implement

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

Re-execute

sudo rosdep init

7. Backup and replace

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

Replace all https://raw.githubusercontent.com/ros/rosdistro/master in the file with file:///home/one/git/rosdistro

8. Run

rosdep update

insert image description here
That's it! !

Note: The file /home/one/git/rosdistro cannot be deleted and is kept. Because we are directly pointing to the local.

5. Set environment variables

1. Add

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

2. Effective

source ~/.bashrc

6. Install rosinstall

sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool

7. Verify that ROS is installed successfully

roscore

If it appears:
insert image description here
Execute:

sudo apt install python3-roslaunch

Then it appears when executing roscore:
insert image description here
execute:

sudo apt install ros-noetic-desktop-full

Restart and restart roscore to start normally.

8. Test the little turtle

Open three terminals and enter the following:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

Guess you like

Origin blog.csdn.net/weixin_50060664/article/details/128690140