Ubuntu 18.04 install and test ROS melody (the difficulty lies in initializing rosdep: sudo rosdep init)

Ubuntu 18.04 install ROS melody and test

1. Update the software source to the domestic stability organization

2. Configure ROS software source

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

Using echo and command redirection in Linux is a shortcut to write information to files.
Specific reference: Necessity of sh -c

3. Configure key

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

If you have a problem connecting to the KeyServer, you can try to replace it in the above command hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80

4. Update system software source

sudo apt update

5. Install Melodic

  sudo apt install ros-melodic-desktop-full

This version [desktop full version] (recommended): includes ROS, rqt, rviz, robot general library, 2D/3D simulator, navigation and 2D/3D perception

The installation process is long

6. Initialize rosdep

You also need to initialize rosdep before you start using ROS. Rosdep can easily install some system dependencies when you need to compile some source code. It is also a tool necessary for some ROS core functional components.

sudo rosdep init

The following error appears:


sudo apt install rospack-tools

Still unsuccessful! Keep trying

sudo gedit /etc/hosts

join raw.githubusercontent.com raw.github.com


The following method is finally OK! Wait and see
The main reason is that www.rawgithubusercontent.com may be down. The method that can effectively solve the error reported by rosdep update is to add an agent. The operation process is as follows:
1, Open the file containing the resource download function:

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

Add the position shown in the figure below:


2, Modify the default in the / usr/lib/python2.7/dist-packages/rosdistro/init.py file_ INDEX_ URL

sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'

3, In the following files, in the address https://raw.githubusercontent.com/ Add before https://ghproxy.com/

$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
//Change the address on line 36
$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 72 that 's ok
//Modify line 72
$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
//Amend line 39
$ sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/manifest_provider/github.py
//Modify lines 68, 119

4, Last modification:

$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py 
//Add the following code on line 204 (that is, at the first line under the function block)
gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
//Note that the double quotation marks of the proxy address in the original website are in Chinese. Pasting and copying directly will report character recognition errors

5, Run rosdep update and find a perfect solution to the problem!

7. Add environment variable

If the ROS environment variable can be automatically configured (i.e. added to the bash session) every time a new terminal is opened, it will be much more convenient:
View the / opt / ROS / melody directory

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

If you have multiple ROS versions installed, ~ /. bashrc must only source the setup.bash corresponding to the version you are currently using.
If you only want to change the environment variables under the current terminal, you can execute the following commands:

     source /opt/ros/kinetic/setup.bash

8. Installation package compilation dependency

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

9. Test:

1, CTRL+ALT+T open the terminal and enter the following command to initialize the ROS environment:


Successfully opened, as shown in the figure below:

2, Open a new terminal and enter the following command to pop up a small turtle window:

rosrun turtlesim turtlesim_node

3, After a little turtle's LOGO appears, open a new terminal, enter the following command, and use the direction key on the keyboard to control the little turtle's movement

rosrun turtlesim turtle_teleop_key

4, Open a new terminal and enter the following command to view ROS node information:

rosrun rqt_graph rqt_graph

At this point, ROS melody has been successfully installed under Ubuntu 18.04! A new journey is about to begin

Tags: Machine Learning Deep Learning Object Detection slam Autonomous vehicles

Posted on Fri, 15 Oct 2021 15:23:52 -0400 by dada06