IV Development record of ubuntu system installation ROS and development environment

The column series is as follows:

I Develop documented AHRS, inertial navigation sensor SBG-Ellipse-N sensor configuration and use_ goldqiu's blog - CSDN blog_ SBG sensor data format

II Remote use of dispatch IPC and configuration of ubuntu and ROS environment_ goldqiu's blog - CSDN blog

III The configuration, environment, installation and backup of various software, etc. of the mobile hard disk ubuntu system recorded in the development_ goldqiu's blog - CSDN blog

This article is mainly about Ubuntu 18 04 installing ROS melody

Install ROS

Select Tsinghua source

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'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update

sudo rosdep init appears

ERROR: cannot download default sources list from:

Step 1:

First enter


Go and download this package.

Step 2:

Modify the rosdep / source in this package list. File 20 default under D / List, point this file to http://raw.githubusercontent.com The url address of the is all modified to the address pointing to the local file, that is, the address of the downloaded package. The following is a modified example:

# os-specific listings first

yaml file:///home/xxx/rosdistro/rosdep/osx-homebrew.yaml osx

# generic

yaml file:///home/xxx/rosdistro/rosdep/base.yaml

yaml file:///home/xxx/rosdistro/rosdep/python.yaml

yaml file:///home/xxx/rosdistro/rosdep/ruby.yaml

gbpdistro file:///home/xxx/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

Note: in py language, the format of url local file address is: File: / / + file address, and it is the same when changing the address in other files later.

Step 3:

Modify / usr / lib / python2 7 / dist packages / rosdep2 sources under this folder_ list. Py file, as follows:

# default file to download with 'init' command in order to bootstrap

# rosdep

DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdistro/rosdep/sources.list.d/20-default.list'

# seconds to wait before aborting download of rosdep data

Step 4

Modify the code in the following two files:



The following are the modified examples:

/usr/lib/python2.7/dist-packages/rosdep2/rep3.py file:

# location of targets file for processing gbpdistro files

REP3_TARGETS_URL = 'file:///home/xxx/rosdistro/releases/targets.yaml'

# seconds to wait before aborting download of gbpdistro data

/usr/lib/python2.7/dist-packages/rosdistro/init.py file:

# index information

DEFAULT_INDEX_URL = 'file:///home/xxx/rosdistro/index-v4.yaml'

def get_index_url():

Then perform sudo rosdep init:

Install ros development environment

Download deb from the official website


sudo dpkg -i xxxx.deb

Install these plug-ins

Create workspace:

mkdir -p test_ws/src
cd test_ws/
code .

Compiling ros in vscode:

The shortcut key ctrl + shift + B calls compilation and selects: catkin_make:build

Or modify vscode/tasks.json file

// About tasks JSON format, see
    // https://go.microsoft.com/fwlink/?LinkId=733558
    "version": "2.0.0",
    "tasks": [
            "label": "catkin_make:debug", //Descriptive information representing the prompt
            "type": "shell",  //You can choose shell or process. If it is a shell, the code runs a command in the shell. If it is a process, it runs as a process
            "command": "catkin_make",//This is the command we need to run
            "args": [],//If you need to add some suffixes after the command, you can write it here, such as - DCATKIN_WHITELIST_PACKAGES=“pac1;pac2”
            "group": {"kind":"build","isDefault":true},
            "presentation": {
                "reveal": "always"//Optional always or silence, which indicates whether to output information
            "problemMatcher": "$msCompile"

Create ROS function pack

Select src and right-click -- > create catkin package

Set package name add dependency

Add cpp

    Console output HelloVSCode!!!
#include "ros/ros.h"
int main(int argc, char *argv[])
    //Perform node initialization
    //Output log
    ROS_INFO("Hello VSCode!!!");
    return 0;

If there is no code prompt:

Modification vscode/c_cpp_properties.json

Setting "cppStandard": "c++17"

Configure cmakelists txt:

add_executable(Node name
  src/C++Source file name.cpp
target_link_libraries(Node name

At present, it seems that the node tab cannot be found here. Execute this sentence

rospack list

QT, vscade or clion are used for the commissioning of a ROS or cmake project.

QT is more often used for qmake as UI, clion is cmake, and vscade is cmake and ros, which are more convenient


Keywords: Linux Ubuntu ROS

Added by PHPnewby! on Tue, 11 Jan 2022 07:06:27 +0200