Install Ros on ubuntu18.04 (details)

I have tried many times to install Ros on Ubuntu 18.04, and there are basically no problems in the installation process, and this method can also be used on Jetson nano/NX.

1. Set the software source:

Tsinghua source:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

2. Set the key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

3. Install Ros-melodic:

sudo apt-get update

sudo apt-get install ros-melodic-desktop-full

sudo apt-get install ros-melodic-rqt*
Note: sudo apt-get install ros-melodic-desktop-full and sudo apt-get install ros-melodic-rqt* sometimes have problems. The specific problem is that all installations have been completed after the two steps are executed, but when ROS is fully installed After that, some problems of not being able to find dependencies will be reported when using it. At this time, you can perform these two steps again.
The reason may be that some dependencies of Ros were uninstalled when installing other things.

Fourth, initialize rosdep:

sudo rosdep init
rosdep update
Note: These two steps will generally go wrong! ! ! ! ! ! ! Just keep reading! ! ! ! !
The general problems are as follows:

After running sudo rosdep init, the following error occurs:
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.

The reason for this problem is that it is blocked. The solution is to download the required files to the local, and then modify the link in the original file to point to the local warehouse, which can be solved.

method:

1. Create a new folder and enter the folder

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

Download items:

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

2. Open another terminal and back up the original file

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

3. Replace the original file URL to local download

sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/main.py
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

And replace all, replace https://raw.githubusercontent.com/ros/rosdistro/master with file:///home/one/git/rosdistro

4. run

sudo rosdep init

The terminal displays rosdep update to enter the next step.

5. 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

And do replace https://raw.githubusercontent.com/ros/rosdistro/master with file:///home/one/git/rosdistro

6. run

rosdep update

It is ok to display the following.
insert image description here

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

Five, install rosinstall

sudo apt-get install python-rosinstall

6. Install catkin compiler

sudo apt-get install ros-melodic-catkin python-catkin-tools

Seven, add environment variables

gedit ./.bashrc

Add the following at the end:

#Ros-melodic
source /opt/ros/melodic/setup.bash

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/121781535