Skip to content

Tutorial for beginner who wants to start using ROS on Linux OS

Notifications You must be signed in to change notification settings

gmp-prem/basic-ros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

ROS1 Tutorial

Tutorial for beginner who wants to start using ROS Noetic on Ubuntu 20 LTS

Topics

  1. Getting started with Linux
    • What is a Linux?
    • Ubuntu interface
    • Performing task on Ubuntu
    • Basic commands
  2. Basic robot operating system (ROS)
    • What is ROS?
    • ROS concept
    • ROS computational graph
      • continuous data streams (topics)
      • remote procedure calls (services)

Getting started with Linux OS

What is Linux?

Linux is an open-source Unix-like OS that manages communication between hardward and software, since Linux is an open-source, many distributions(versions) have been developed, one of the most popular one is Ubuntu we use today.

Ubuntu interface

Desktop elements

Performing task on Ubuntu

Shell is a command-line interface that interprets what should the ubuntu perform from command of user, there are many shells out there but the default one of ubuntu is Bourne-Again shell or bash

As a developer, most of time we spend on ubuntu doing tasks will use what we called terminal, terminal is a power tool that uses shell to interprets the command and it gives us ability to

  • Navigating
  • Manipulating
  • Diagnosis
  • More++

You can start using command prompt or terminal by go to a launcher and type the following word and enter

terminal

or the another way is to use the short-cut which is way better and faster, just press ctrl + alt + t then your terminal should appear as shown below

You can see that on the terminal there is a hayashi@lab:~$

hayashi is the username indicated before @ symbol

lab is the hostname indicated after @ symbol

~ is the directory you are working on (~ or "tilt" means the home directory)

$ is prompt symbol, this symbol will tell where the command you type begin

Basic commands

ls, ls will list what file are in the directory you are working on

ls

cd, cd is the command to change the directory that you want to go to work

cd ~/Desktop

If you want to edit the script or text file, Ubuntu has provided us the default text editor which is called gedit, of course there are more text editors, some text editor gives more functionality for coding such visual studio code, vim, nano and more

gedit my_text_editor

sudo, sudo stands for superuser do, this command gives ability to be an administrator or root privileges, some files could not be directly used local, so the sudo comes into this position

example of sudo command, from the command below, you could see that the terminal will warn us about the permission to update file repository

apt update

to use this command properly, we need to append sudo in front of the command

sudo apt update

These are just the basic commands, if you would like to know more, here is the link to my recommend page to read about command on Linux

Why Ubuntu on developing Robotics? 🔥

  • lightweightness, ubuntu is lightweight in its nature, ypu don't have to pay to get access, you can install along side with your existing operating system, just donwload, install and use!
  • the distribution of ubuntu is a long-term support (usually 5 years)
  • tons of community support, ubuntu has a great community whenever you have a problem, you could get help such as ubuntu community or stackoverflow and more communities++ out there

Basic robot operating system (ROS)

What is ROS?

Robot operating system or ROS for short, ROS is an open-source framework for developing a robotics, ROS has a simple concept and easy to understand, ROS has a lot of communities, so many engineers and researchers use this framework to develop their own robot applications.

Install ROS on ubuntu

To install ROS on ubuntu, first you are going to open the terminal using ctrl + alt + t and cd to the home directory, then you are going to set your computer to accept software from ROS

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

Get the key from ROS to make sure you really get the ROS software from ROS

sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

Update the repository on your computer

sudo apt update

Now the part of ROS, ROS provided many ways to install, but in this tutorial, I will just let you install the full version of ROS since you will get access to all tools and libraries in ROS

sudo apt install ros-noetic-desktop-full

Now, this command may take a while to install ROS depends on your quality of internet connection. After finish from installing ROS, next we will set up the environment before use. We are gonna open up the bash file and add this command to source the workspace, cd to the home directory

gedit ~/.bashrc
source /opt/ros/noetic/setup.bash

Save the text editor and close, then source the .bashrc file

source ~/.bashrc

After that, these dependecies are important for building up the workspace for ROS

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

Next, we will install rosdep. Before we use the ROS tools, we need to have this rosdep to easily install system dependencies for source you want to compile and is required to run some core components in ROS. for full detail about the rosdep, please visit this link

sudo apt install python3-rosdep

Initilize the rosdep

sudo rosdep init
rosdep update

Now, you have ROS installed on your ubuntu !

ROS concept

ROS filesystem level

ROS filesystem level is the part of the ROS that consider the filesystem on the disk, the filesystem level mainly consists of packages, metapackages and message type, service types.

ROS workspace

ROS workspace is where you modify, build, and install catkin packages, the workspace will usually contain build, devel and src folder

  • build is where the build file of the workspace is kept, all cache and information about build is here
  • devel stands for development, it is where the built target is stored, after the build configuration
  • src stands for source, it is where the source file of the workspace are kept, your script file, your package that follows the rule of the filesystem level

Let's create ROS workspace !

Before create the workspace, we must install the catkin_tool package which contains the build tool for our workspace

Open up your terminal using ctrl + alt + t, and get ROS repository that contains the catkin_tool

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

Setup the key for the ROS repository

wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

Update the latest version of packages from repositories

sudo apt-get update

Install catkin_tool package

sudo apt-get install python3-catkin-tools

For additional info about the catkin_tool package, please visit this link

Now we are ready to create our ROS workspace !

To create ROS workspace, open the terminal using shortcut ctrl + alt + t or you can go open the launchpad and type terminal to open your terminal

next, create the folder for your ROS workspace

mkdir -p ~/catkin_ws/src

Go to the catkin_ws directory

cd catkin_ws

Build your ROS workspace

catkin build

your workspace is built with this command then it is ready for your robot application, you could see 3 new folders which are build, devel and logs folder, the logs folder here will just log what catkin build did for you if you want to know what happened of last build

  • .bashrc file? link

After the workspace has created, we will source our workspace to bashrc file, let's go back to home directory and type this command on your terminal

cd ~ && echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc && source ~/.bashrc

For additional info about creating ROS workspace, please visit this link

Create the your first package

Next we will create first ROS package, first let's change directory to src in catkin_ws

cd ~/catkin_ws/src

Create a package

catkin_create_pkg my_package rospy roscpp std_msgs

Your package has created, you could check the current directory by using ls command, next you have to go back to catkin_ws to build your workspace

catkin_create_pkg my_package rospy roscpp std_msgs has a form catkin_create_pkg <package_name> [depend1] [depend2] [depend3]

  • catkin_create_pkg is the command the create the package in your ROS workspace
  • package_name is the name of the package, you could name this package whatever you want
  • dependency means ROS packages that your package depends on
cd ..

Then

catkin build

Now you will see the terminal shows that the package my_package has been built

For additional info about creating ROS package, please visit this link

About

Tutorial for beginner who wants to start using ROS on Linux OS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages