The detailed process of installing ROS Melodic on Ubuntu 18.04 (including filling steps)

Different versions of ubuntu correspond to different versions of ros,

1. Set the 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'


2. Set the secret key

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116


3. Update the source address
 

sudo apt-get update

After running the above command, the system will output some corresponding feedback information, pay attention to see if there are any overlooked or lost connections, if they are all obtained and hits, there is no problem
4. Install, choose the full version of the desktop here, you can also choose Part of the installation, the specific commands can be found in the official website tutorial
 

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

If you are prompted "Unable to locate the software package ros-melodic-desktop-full", it is likely that the execution order of the above steps is wrong or there is an omission, just re-execute it, you can see it in sudo apt-get update

It will no longer prompt "Unable to locate the software package ros-melodic-desktop-full".

5. The install process is very long,

Execute after

sudo apt-get install ros-melodic-rqt*
sudo rosdep init

If prompted "sudo: rosdep: command not found", execute

sudo apt-get install python-rosdep

Continue execution

sudo rosdep init
rosdep update

如果rosdep init报错: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.

Enter in the terminal: sudo vim /etc/hosts, add the following line at the end of the opened file: 151.101.84.133 raw.githubusercontent.com

If the problem is still not solved, it is necessary to overturn the wall.

6. Install rosinstall

sudo apt-get install python-rosinstall

7. Load the environment settings file

source /opt/ros/melodic/setup.bash

 8. Create and initialize the working directory

 ROS uses a special ROS build system called catkin. In order to use it, the user needs to create and initialize the catkin working directory as shown below. Unless the user creates a new working directory, this setting only needs to be set once.

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

Currently, only the src directory and the CMakeLists.txt file are in the catkin working directory, use the catkin_make command to build

cd ~/catkin_ws/
catkin_make

9. Set environment variables:

sudo apt install net-tools
gedit ~/.bashrc
# Set ROS melodic
source /opt/ros/melodic/setup.bash
# Set ROS Network
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=localhost:11311

10. Test

Open three terminals and execute:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

success.

Guess you like

Origin blog.csdn.net/whuzhang16/article/details/109512149