[Ubuntu18.04 installs ROS Melodic tutorial, the personal test is successful! ! ! 】

ROS installation often encounters the problem of installation timeout or inaccessibility. This article describes the author's steps for successful installation. I hope it will be helpful to you

1. Installation

1.1 set sources.list


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

Here, if you encounter slow download speed or timeout and cannot access, you can switch to the following domestic mirror source settings


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

1.2 Set the key


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

If you cannot connect to the key server, you can try to replace hkp://keyserver.ubuntu.com:80 in the above command with hkp://pgp.mit.edu:80.

You can also use the curl command instead of the apt-key command, which is useful when using a proxy server:


curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -

1.3 Installation

update first

sudo apt update

Then install ros-melodic-desktop-full


sudo apt install ros-melodic-desktop-full

This download time is a bit long, you can wait for the download to complete before proceeding to the next steps. Generally, there are no problems encountered here.

The next step is that most people will get stuck in the step where this step times out or cannot be accessed, making it impossible to continue.

1.4 Initialize rosdep

Before you can use ROS, you need to initialize rosdep. rosdep allows you to easily install source code that you want to compile, or system dependencies that are required by certain ROS core components.

sudo rosdep init
rosdep update

If you don't encounter any problems here and pass it smoothly, you can skip and go directly to the next steps.

If you still look at the estimates here, you will encounter errors and cannot proceed. There are many methods on the Internet, such as modifying files, or adding URLs. I've tried everything, but it still doesn't help me. Here's what I used to initialize smoothly:

Since someone in China has made rosdep—rosdepc from domestic sources
, we use this (rosdepc) for initialization

First install rosdepc

sudo pip3 install rosdepc

If an error is displayed and there is no pip3, then install a pip3 first, and then install the above command

sudo apt-get install python3-pip

After the installation is complete, continue to start our initialization


sudo rosdepc init
rosdepc update

Wait for initialization to complete

1.5 Setting up the environment

Automatically adding ROS environment variables to bashrc will facilitate ROS execution on any terminal:


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

1.6 Build dependencies

So far, you have installed what you need to run the core ROS packages. In order to create and manage your own ROS workspaces, there are various tools and requirements distributed separately. For example: rosinstall is a frequently used command-line tool that enables you to easily download the source tree of many ROS packages from a single command.

To install this tool and other dependencies for building ROS packages, run:


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

2. Test whether the tutorial is installed successfully

2.1 Install the relevant function packages of Little Turtle


sudo apt-get install ros-melodic-turtlesim 

After the installation is complete, open three different terminals and enter the following commands:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

Then you will see a pop-up UI window with a turtle in it, and then you can try to control the movement of the little turtle with the keyboard. If the little turtle test fails, then refer to the above ROS installation steps

123

Guess you like

Origin blog.csdn.net/weixin_44355653/article/details/132085125