Tangwx

Tangwx

博客网站

02. Installing ROS Melodic on Ubuntu 18.04

02. Installing ROS#

Related Links:

ROS: Home

Installation of ROS Melodic on Ubuntu 18.04 (Detailed, Tested Installation with Clear Step-by-Step Screenshots) - Mango's Blog on CSDN Blog_xubuntu18.04 Installation of ROS

After this article, there will be no more rosdep update failure in the world! If there is... Little Fish will... (qq.com)

2.1 What is ROS?#

ROS is an open-source meta-operating system for robots. It provides the services expected from an operating system, including hardware abstraction, low-level device control, implementation of common functions, inter-process message passing, and package management. It also provides tools and libraries for acquiring, building, writing, and running code across multiple computers. In some ways, ROS is similar to a "robot framework" such as Player, YARP, Orocos, CARMEN, Orca, MOOS, and Microsoft Robotics Studio.

The runtime "blueprint" of ROS is a loosely coupled peer-to-peer process network based on the ROS communication infrastructure. ROS implements several different communication styles, including a service mechanism based on synchronous RPC-style communication, a topic mechanism based on asynchronous streaming data, and a parameter server for data storage. For a more in-depth explanation of these concepts, please refer to the concept overview.

ROS is not a real-time framework, but it can be embedded in real-time programs. The Willow Garage PR2 robot uses a system called pr2_etherCAT to send or receive ROS messages in real-time. ROS can also be seamlessly integrated with the Orocos real-time toolkit.

2.2 Installation Steps#

The version installed in this article is ROS Melodic, using the Ubuntu 18.04 system.

2.2.1 Add Mirror Source#

Here, I set the mirror source to Tsinghua University.

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'

image-20220905222456802

2.2.2 Set Key#

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

image-20220909204803529

2.2.3 Update Package Index#

Make sure your Debian package index is up to date:

sudo apt update

image-20220905222914935

If you encounter a GPG error:

image-20220909205040109

Solution:

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

Replace FEEA9169307EA071 with your own NO_PUBKEY value.

image-20220910093010025

Modify /etc/apt/sources.list:

sudo gedit /etc/apt/sources.list

Solution (not sure if necessary):

Applicable to Ubuntu 18.04

Use aliyun, modify the contents of sources.list to the following:

deb http://mirrors.aliyun.com/ubuntu bionic main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-updates main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-backports main multiverse restricted universe
12345

Finally, update the software packages:

sudo apt update

or

sudo apt-get update

2.2.4 Install ROS Desktop Full Version#

Desktop Full Version (recommended): Includes ROS, rqt, rviz, common libraries for robots, 2D/3D simulators, navigation, and 2D/3D perception packages.

sudo apt install ros-melodic-desktop-full

If an error occurs:

image-20220905223058629

Finally, I found the simplest solution:
Open system updates in Ubuntu settings...

image-20220908202313324

Then sudo apt-get install ros-melodic-desktop-full
Reinstall, and there will be no problem.

image-20220908202147090

To avoid the prompt "sudo rosdep: command not found" later, execute the following command:

sudo apt install python-rosdep

image-20220910202825879

2.2.5 Initialize rosdep and perform rosdep update#

Before using ROS, initialize rosdep first. Rosdep can easily install system dependencies for the source code to be compiled. Rosdep is the foundation on which the core components of ROS run.

sudo rosdep init (deprecated) rosdep update (deprecated)

Since it involves downloading and the website is overseas, these two commands will result in an error. Therefore, we abandon this solution and use the solution provided by a domestic expert (WeChat public account: Fish Fragrance ROS).

2.2.5.1 Install python3-pip#

sudo apt-get install python3-pip

image-20220910203039317

2.2.5.2 Install rosdepc#

sudo pip3 install rosdepc

image-20220910203332026

2.2.5.3 Initialize rosdepc#

 sudo rosdepc init

image-20220910203611122

2.2.5.4 Update rosdepc#

rosdepc update

image-20220910203719056

2.2.6 Add ROS Environment Variables#

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

image-20220910203812925

2.2.7 To build and manage your own ROS workspace, install rosinstall#

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

image-20220910203957839

2.2.8 Launching the Turtle Example to Test the ROS Environment#

2.2.8.1 Run the following command in the first terminal#

roscore

image-202209102040420092.2.8.2 Open the second terminal, or use the Ctrl+Shift+T shortcut to open a new terminal, and run the following command. You will see a stationary turtle.#

rosrun turtlesim turtlesim_node

image-20220910204130447

2.2.8.3 If you want the turtle to move, open the third terminal, use the Ctrl+Shift+T shortcut to open another new terminal, and start the turtle_teleop_key node for keyboard control of turtlesim. Run the following command:#

rosrun turtlesim turtle_teleop_key

(Here, your mouse should stay on the current terminal interface, and use the up, down, left, right keys on the keyboard to control the movement of the turtle)

"Up, Down, Left, Right" on the keyboardTurtle Movement
UpForward
DownBackward
LeftRotate Left
RightRotate Right

image-20220910204332072


ROS installation is now complete.

Celebrate with confetti! ✿✿ヽ (°▽°) ノ✿


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.