ROS1: setting up workspaces

    

            

ROS1: setting up workspaces

ROS1 is a very useful framework if you have some older microprocessors or you don't want or cannot install a newer version Ubuntu variant of Linux(ROS1 is stable for Debian and Ubuntu version of Linux up to Ubuntu 20.04 only) such as if you are going to purchase nvidea jetson series Linux board which btw has inbuilt gpu, for that you can only install L4T(Linux for Tegra) and it only comes with Ubuntu 18.04, then ROS1 get very handy.

ROS1 service is deprecated for newer versions of Linux i.e 22.04 and it is being replaced by ROS2.ROS2 has so much functionality improvement over ROS1 that it is much more suitable to use for industrial purposes.


Some improvement ROS2 has over ROS1 are:

  1. They can be much more usable on Windows and mac os as well
  2. They are not dependent on the “master” system that is if the system which runs ROSMASTER is offline then our ROS can be used.

To learn more about ROS’s framework refer to this article.


However ROS1 still has some advantages over ROS2, like some of the well-used application in ROS hasn't transitioned from ROS1 to ROS2, and even though ROS1 has some bugs which are sometimes irritating, ROS1 is quite stable for Ubuntu.


Before installing you need to have some experience with Linux terminal as almost all the work is done through the Terminal. 


ROS1: setting up workspaces



If you are understanding what's happening in this image then you are good to continue with this tutorial. if not go through these links

https://ubuntu.com/tutorials/command-line-for-beginners#1-overview

http://www.ee.surrey.ac.uk/Teaching/Unix/

 Installing ROS1

Before installing ROS1, understand a bit of its history.

ROS's first release was in 2009 named mango tango or ROS 0.4 and after that developer decided to use an interesting name for its distribution 


  • Box Turtle, in 2010
  • ROS C-Turtle, in 2010
  • Diamond Back, in 2011
  • ROS Electric Emys, in 2011
  • ROS Fuerte Turtle, in 2012
  • ROS Groovy Galapagos, in 2012
  • ROS Hydro Medusa, in 2013
  • ROS Indigo Igloo, in 2014
  • ROS Jade Turtle, in 2015
  • ROS Kinetic Kame, in 2016
  • ROS Lunar Loggerhead, in 2017
  • ROS Melodic Morenia, in 2018
  • ROS noetic Ninjemys, in 2020

We will continue with ROS melodic as it is available for Ubuntu 18.04(Jetson nano runs on Ubuntu 18.04 plus it has some bugs issues which will be covered here).

To Install ROS melodic

Copy the following and paste it into your terminal 


sudo apt install curl # if you haven't already installed curl

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

*if having problems with the key installation then use this snippet. It was implemented because the previous key posed a security threats


sudo -E apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full

Then you have to set up the environment 


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


source /opt/ros/melodic/setup.bash

With this, you made your system ready to run ROS but to work with ros you need to have a workspace. A ros workspace is where all your nodes will be placed and compiled so that they can be used with ros commandlets

Before setting up the ros workspace run this code it will ensure that you have all the required binaries so that you don't have problems in building ros workspaces

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


sudo apt install python-rosdep


sudo rosdep init

rosdep update

Next, create a ros workspace by let's say you want to build your ros workspace in Documents Then 


 mkdir -p /Documents/”name of your ros workspace”/src

cd /Documents/”name of your ros workspace”

catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

catkin make is a type of make file that is used by ROS to build your sources. A make is a special type of file that help to compile multiple files which can be converted to executables. An example of an executable is a c file(not technically executable but for the sake of simplicity we will consider a c file can be executed) or Python etc. We need to make files because they simplify by compiling multiple files by just one line. There are many types of make files, catkin can be used to build projects as cmake projects can be built, but catkin also provides the concept of ros workspaces, where you can build multiple, interdependent packages together all at once.
we can also run 

catkin_make

 

But the above code uses Python2 to compile your Python files instead of Python3. Python has 2 versions python2 and Python3. And there won't be any python4 as a transition from python2 to python3 has some severe compatibility issues where python2 files with python3 syntax might not compile.ROS melodic is also a victim of python2 python3 compatibility issues. Some nodes of need to build using Python3 but by default catkin_make for melodic uses Python2, for the first time, add this line later you won't require 


source devel/setup.bash

echo "source devel/setup.bash" >> ~/.bashrc

Now you are ready to build your ros projects.


A ros workspace has many files.


ROS1: setting up workspacesFor us mostly src file concern. As there is where we store our projects as you can see it has different SLAM package and other packages as well(building all of them doesn't mean that unnecessary packages will also be executed). The beauty of ros is that you don't have to create all of them from scratch you can just download them from GitHub or copy them through any other source knowing that they were built without error.


Every ros package must contain 

  • Package.xml
  • CMakeList.txt
  • Src (or any other folder where you will write scripts)

ROS1: setting up workspaces


A package.xml file contains the list of dependencies that catkin will require to build our scripts.




ROS1: setting up workspaces


here this package depends on rospy, geometry_msgs, etc (To learn more about package.xml click here)

Similarly, CMakeList should also dependencies on what our project will be needed so that it can be built. 


ROS1: setting up workspaces


  Next src folder, here you have different node scripts, Which will depend on the files and binaries specified in package.xml and CMakeList.txt


ROS1: setting up workspaces


Each script is a ROS node.

ROS launch folder launch file. A launch file in ROS helps to execute multiple nodes and even passes on parameters if a node requires any.


ROS1: setting up workspaces


And that's what the ros1 workspace looks like.

Post a Comment

0 Comments