[ROS in 5 mins] 042 – What is roswtf?

[ROS in 5 mins] 042 – What is roswtf?

In this video, we’ll see what the roswtf tool is. We’ll also see how and why this tool is used in ROS.

Let’s go!

Step 0. Create a project in Robot Ignite Academy(RIA)

We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the TF ROS 101 unit 4  as an example today.

Step 1. roswtf

The roswtf is a debugging tool in ROS which helps you to find the problem in your simulation.

Let’s have some examples. In the terminal, please type

ROS_IP= roswtf

The roswtf will check the system statically and dynamically. The static errors(e.g. the compilation error) will be shown in the static checks summary part. The dynamic checks summary shows the error found while running the ROS graph with ROS master. Here you can see that the roswtf found that the ROS_IP is invalid because it’s an empty string!

Let’s try it one more time with

ROS_MASTER_URI=127.1.1.1 roswtf

This time you will get an error shows that the 127.1.1.1 is not a valid url.

In conclusion, the roswtf is a powerful debugging tool to help you debugging your ROS program.

Want to learn more?

If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:

 

Edited by: Tony Huang


Resources mentioned in the video:

Robot Ignite Academy, the place to learn to program robots using only a web browser (the environment used in the video for demonstration)

ROS Development Studio (ROSDS), another powerful online tool for pushing your ROS learning in a practical way

– roswtf on the ROS wiki

 

We love feedback!

Did you like this video? Whatever the case, please leave a comment in the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.

Thank you!

[ROS in 5 mins] 040 – What is in the directories src, build and devel?

[ROS in 5 mins] 040 – What is in the directories src, build and devel?

In this post, we will see what the ROS workspace directories src, build and devel contain. We’ll also see how these directories are used in ROS workspace management.

Let’s go!

Step 1: Create a Project (ROSject) on ROSDS

Head to http://rosds.online and create a project called “ros workspace” (or whatever you wish). Please ensure you select “Ubuntu 16.04 + ROS Kinetic + Gazebo 7” under “Configuration”. Once done with that, open up the project by clicking on “Open ROSject”.

Step 2: Check out what we have in the catkin_ws workspace and save its current state in git

Pick a Shell tool from the Tools menu and locate the catkin_ws directory.

user:~$ cd catkin_ws/
user:~/catkin_ws$ ll
total 24
drwxrwxr-x  5 user user 4096 Jun 11  2018 ./
drwxrwxrwx 10 user user 4096 Dec  2 12:16 ../
-rw-rw-r--  1 user user   98 Nov 17  2017 .catkin_workspace
drwxrwxr-x  7 user user 4096 Jun 11  2018 build/
drwxrwxr-x  3 user user 4096 Jun 11  2018 devel/
drwxrwxr-x  2 user user 4096 Nov 17  2017 src/

So we see that we have three subfolders in the workspace: src, build and devel. Now we are going to save the current state of that directory before we make further changes:

user:~/catkin_ws$ git init
Initialized empty Git repository in /home/user/catkin_ws/.git/
user:~/catkin_ws$ git add .
user:~/catkin_ws$ git commit -m "Initial workspace state"
[master (root-commit) d18311c] Initial workspace state
 112 files changed, 7467 insertions(+)
 create mode 100644 .catkin_workspace
 ...# truncated messages
user:~/catkin_ws$ git status
On branch master
nothing to commit, working tree clean

Step 3: Create a new package in the workspace and observe the changes

Take note that only the src folder has been changed here.

# We change the workspace's src folder and create a package.
user:~/catkin_ws$ cd src
user:~/catkin_ws/src$ catkin_create_pkg test_package rospy
Created file test_package/package.xml
Created file test_package/CMakeLists.txt
Created folder test_package/src
Successfully created files in /home/user/catkin_ws/src/test_package. Please adjust the values in package.xml.

# We change back to the workspace (catkin_ws) directory and see that we have new untracked files and directories. 
# We commit them to git.
user:~/catkin_ws/src$ cd ..
user:~/catkin_ws$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        src/test_package/

nothing added to commit but untracked files present (use "git add" to track)
user:~/catkin_ws$ git add src/test_package/
user:~/catkin_ws$ git commit -m "Create a test package"
[master 13e3e91] Create a test package
 2 files changed, 266 insertions(+)
 create mode 100644 src/test_package/CMakeLists.txt
 create mode 100644 src/test_package/package.xml

# We check the workspace folder again in git and see that it's "clean"
user:~/catkin_ws$ git status
On branch master
nothing to commit, working tree clean
user:~/catkin_ws$

Step 4: Compile the workspace and observe the changes

Now we will compile the workspace and see what happens.

# COMPILE THE WORKSPACE
user:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "cmake /home/user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install -G Unix Makefiles" in "/home/user/catkin_ws/build"
####

#...lots of truncated messages

# CHECK THE WORKSPACE IN GIT
user:~/catkin_ws$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   build/CMakeCache.txt
        modified:   build/CMakeFiles/Makefile.cmake
        modified:   build/CMakeFiles/Makefile2
        modified:   build/CMakeFiles/TargetDirectories.txt
        modified:   build/CTestTestfile.cmake
        modified:   build/Makefile
        modified:   build/catkin/catkin_generated/version/package.cmake
        modified:   build/catkin_generated/generate_cached_setup.py
        modified:   build/catkin_generated/installspace/_setup_util.py
        modified:   build/catkin_generated/installspace/setup.sh
        modified:   build/catkin_generated/order_packages.cmake
        modified:   build/catkin_generated/order_packages.py
        modified:   build/catkin_generated/setup_cached.sh
        modified:   build/catkin_generated/stamps/Project/_setup_util.py.stamp
        modified:   build/catkin_generated/stamps/Project/package.xml.stamp
        modified:   build/catkin_make.cache
        modified:   build/cmake_install.cmake
        modified:   devel/_setup_util.py
        modified:   devel/setup.sh

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        build/CTestConfiguration.ini
        build/CTestCustom.cmake
        build/atomic_configure/
        build/catkin_generated/installspace/local_setup.bash
        build/catkin_generated/installspace/local_setup.sh
        build/catkin_generated/installspace/local_setup.zsh
        build/test_package/
        devel/cmake.lock
        devel/lib/
        devel/local_setup.bash
        devel/local_setup.sh
        devel/local_setup.zsh
        devel/share/

no changes added to commit (use "git add" and/or "git commit -a")

Now we see that there a lot of modified and new files in both build and devel, (no) thanks to the command we just ran.

Let’s put it all together in the next step.

Step 5: Put it all together – translate the action into words

I strongly believe you already got some hints about the src, build and devel directories from the commands we ran in the steps above. Now let’s consolidate those hints:

  • src contains the source files for packages created. That’s why we created a package in this folder in Step 3.
  • we run cmake from build  to build the packages in src. You can call it cmake‘s working directory. You’ll also notice that the bulk of modified files are in this direction after we ran catkin_make.
  • ROS places built files of the package in devel for development/testing. Yep, and that’s why most of the files in this directory after catkin_make are new.
  • Extra: install – this folder will be created if you compile with the command catkin_make install. Try it out!

And…that was it!

Extra: Video

Prefer to listen to the “sights and sounds” version of this post? We have one for you below; happy watching!

Further Learning

If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:

Feedback

Did you like this post? Whatever the case, please leave a comment in the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a post or video about it.

Thank you!

[ROS in 5 mins] 039 – What is setup.bash or setup.sh

[ROS in 5 mins] 039 – What is setup.bash or setup.sh

Welcome again to a new post about ROS.

In order to work properly, ROS uses the setup.bash files, but what are those files? In today’s post, we’re going to learn what are setup.bash (or setup.sh) files, where are they located and how to use them.

Before we start, if you are new to ROS, I highly recommend you taking any of the following courses on Robot Ignite Academy:

Let’s get started, shall we?

Where the setup.bash and setup.sh files are located

In this post, we are going to use Robot Ignite Academy, but the commands used here could be executed in your own computer if you have ROS installed.

When you open a course on Robot Ignite Academy, you have among other things, the web shell, which we use to run our commands. By running ls ~/catkin_ws/devel/  we can see that among other files, we have setup.bash and setup.sh:

user:~$ ls ~/catkin_ws/devel/
_setup_util.py env.sh lib setup.bash setup.sh setup.zsh

Files with the same name can be found on /opt/ros/kinetic/  and /usr/share/gazebo-7 as can be seen with the commands ls /opt/ros/kinetic and  ls /usr/share/gazebo-7.

user:~$ ls /opt/ros/kinetic/
_setup_util.py bin env.sh etc include lib setup.bash setup.sh setup.zsh share
user:~$
user:~$ ls /usr/share/gazebo-7/
media models setup.sh worlds

How the setup.bash files are used

The main function of these files is to set environment variables used by ROS and by the Gazebo simulator. If we look for variables with the ROS prefix with the command env | grep ROS, we will find them:

user:~$ env | grep ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/user/catkin_ws/src:/home/simulations/public_sim_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=/home/user/catkin_ws/devel/share/common-lisp:/home/simulations/public_sim_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

The ROS_PACKAGE_PATH variable, for example, is used by ROS to find ROS Packages. If we unset it with unset ROS_PACKAGE_PATH and try to enter to the image_common package with roscd image_common, for example, we will have an error message saying that the package was not found:

user:~$ roscd image_common
roscd: No such package/stack 'image_common'

If we source our setup.bash files again with source ~/catkin_ws/devel/setup.bash, we will be able to navigate to the image_common package because the ROS_PACKAGE_PATH will be set:

user:~$ source ~/catkin_ws/devel/setup.bash
user:~$ roscd image_common
user:/opt/ros/kinetic/share/image_common$

Unsetting ROS and GAZEBO variables

Just to make clear that the setup.bash and setup.sh files define variables used by ROS and Gazebo, let’s unset all variables with ROS and GAZEBO prefix with the commands below:

for var in $(env | grep ^GAZEBO| cut -d'=' -f1); do unset $var; done

for var in $(env | grep ^ROS| cut -d'=' -f1); do unset $var; done

We can confirm the variables were removed with the commands env | grep ^ROS and env | grep ^GAZEBO.

If we now source ~/catkin_ws/devel/setup.bash  and source /usr/share/gazebo/setup.sh  and check the variables again, we will see they were correctly set.

user:~$ source ~/catkin_ws/devel/setup.bash
user:~$ source /usr/share/gazebo/setup.sh
user:~$ env | grep ^GAZEBO
GAZEBO_MODEL_PATH=/usr/share/gazebo-7/models:/home/simulations/public_sim_ws/install/share/osrf_gear/models:
GAZEBO_RESOURCE_PATH=/usr/share/gazebo-7:
GAZEBO_MASTER_URI=http://localhost:11345
GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-7/plugins:
GAZEBO_MODEL_DATABASE_URI=http://models.gazebosim.org
user:~$
user:~$ env | grep ^ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/user/catkin_ws/src:/home/simulations/public_sim_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=/home/user/catkin_ws/devel/share/common-lisp:/home/simulations/public_sim_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

So, that is the post of today. Remember that below we also have a video showing everything described here. If you liked the post or the video, please leave your thoughts on the comments section of the video.

Related courses

ROS for Beginners Course (Python)

ROS-Basics-cpp course background

ROS for Beginners Course (C++)

 

 

 

 

 

 

 

Keep pushing your ROS Learning.

[ROS in 5 mins] 038 – What is ROS_IP?

[ROS in 5 mins] 038 – What is ROS_IP?

 

In this video, we will see what ROS_IP is, and when to use it, in about five minutes! We’ll be using a very simple simulation to demonstrate this.

If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:

Let’s go!


Links mentioned in the video and other useful links:

– ROS_IP from the ROS wiki: http://wiki.ros.org/ROS/NetworkSetup

 

We Love Feedback!

Did you like this video? Whatever the case, please leave a comment in the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.

Thank you!

[ROS in 5 mins] 037 – What is ROS PACKAGE PATH and how to use it?

[ROS in 5 mins] 037 – What is ROS PACKAGE PATH and how to use it?

Hello ROS Developers

Welcome to this new post about ROS. In today’s post, we are going to learn what is the ROS_PACKAGE_PATH variable and how it is used by the ROS ecosystem.

The commands used here can be executed in your own computer if you have ROS installed, but for simplicity, we are going to use Robot Ignite Academy.

Before we start, if you are new to ROS, I highly recommend you taking the following course:

Ok, let’s get started, shall we?

In a computer with ROS installed, we have many variables with the ROS_ prefix. If we run env | grep ROS , for example, we may have something like the output below:

ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/user/catkin_ws/src:/home/simulations/public_sim_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=/home/user/catkin_ws/devel/share/common-lisp:/home/simulations/public_sim_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

Among these variables we can find the one we are looking for: ROS_PACKAGE_PATH

This variable is used by ROS in order to find ROS Packages. To better understand this, let’s consider the command below, used to control robots using the keyboard:

roslaunch turtlebot_teleop keyboard_teleop.launch

The first parameter of the roslaunch  command is the package name, which in this case is turtlebot_teleop .

When we run the command exemplified above, in order to find the turtlebot_teleop  package, ROS will look for the ROS_PACKAGE_PATH variable.

If we run roscd turtlebot_teleop to enter on the that package, for instance, on Robot Ignite Academy the package is located at /home/simulations/public_sim_ws/src/all/turtlebot/turtlebot_teleop  as can be seen below:

user:~$ roscd turtlebot_teleop
user:/home/simulations/public_sim_ws/src/all/turtlebot/turtlebot_teleop$ pwd
/home/simulations/public_sim_ws/src/all/turtlebot/turtlebot_teleop

If you look carefully, you can notice that the turtlebot_telop package is on the “Public Simulations Workspace”, which is /home/simulations/public_sim_ws/src. Now, with a closer look at the ROS_PACKAGE_PATH variable, we can find that path on it:

ROS_PACKAGE_PATH=/home/user/catkin_ws/src:/home/simulations/public_sim_ws/src:/opt/ros/kinetic/share

So, the turtlebot_teleop package only was found because its workspace path is set on ROS_PACKAGE_PATH.

If we unset that variable and try to roscd on that package again, it is not going to work, as can be seen with the commands  unset ROS_PACKAGE_PATH and roscd turtlebot_teleop.

user:~$ cd
user:~$ unset ROS_PACKAGE_PATH
user:~$ roscd turtlebot_teleop
roscd: No such package/stack 'turtlebot_teleop'

Here we can see that ROS wasn’t able to find the package. If we look at the ROS_ prefixed environment variables again, we won’t find ROS_PACKAGE_PATH:

user:~$ env | grep ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=/home/user/catkin_ws/devel/share/common-lisp:/home/simulations/public_sim_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

If we source our catkin_ws again with source ~/catkin_ws/devel/setup.bash, the variable will be exported and ROS  will be able to find the package again:

user:~$ source ~/catkin_ws/devel/setup.bash
user:~$ roscd turtlebot_teleop
user:/home/simulations/public_sim_ws/src/all/turtlebot/turtlebot_teleop$

Creating a package in an unexpected location

Now let’s go a bit further and create a package in a place that nobody would do it. We are going to create it in the /tmp folder, just to let you better understand the importance of ROS_PACKAGE_PATH.

We can use the cd /tmp/  and catkin_create_pkg tutorial_package  commands to achieve that:

user:~$ cd /tmp/
user:/tmp$ catkin_create_pkg tutorial_package
Created file tutorial_package/package.xml
Created file tutorial_package/CMakeLists.txt
Successfully created files in /tmp/tutorial_package. Please adjust the values in package.xml.

We can clearly see that the package was created in /tmp/tutorial_package, but if we try to navigate to it using roscd tutorial_package, ROS won’t be able to find it:

user:/tmp$ roscd tutorial_package
roscd: No such package/stack 'tutorial_package'

That happens because the /tmp folder is not on the ROS_PACKAGE_PATH variable. We can easily add it using the next command:

export ROS_PACKAGE_PATH=/tmp:$ROS_PACKAGE_PATH

Now if we check the value of the variable with env | grep ROS_P , we can find /tmp there:

user:/tmp$ export ROS_PACKAGE_PATH=/tmp:$ROS_PACKAGE_PATH
user:/tmp$ env | grep ROS_P
ROS_PACKAGE_PATH=/tmp:/home/user/catkin_ws/src:/home/simulations/public_sim_ws/src:/opt/ros/kinetic/share

If we try to enter our package with roscd tutorial_package again, ROS will find it:

user:/tmp$ roscd tutorial_package
user:/tmp/tutorial_package$ pwd
/tmp/tutorial_package

So easy to understand the ROS_PACKAGE_PATH variable, isn’t it?

Remember that we also have a video version of this post on YouTube:

I hope you liked the post (and the video), if that is the case, please consider subscribing to our channel on YouTube. Additionally, should you have any questions or suggestions, please leave your comment on the comments section of the video.

Keep pushing your ROS Learning.

[ROS in 5 mins] 036 – How to use and configure rosed

[ROS in 5 mins] 036 – How to use and configure rosed

 

In this video, we will see what rosed is, and how to use and configure it, in less than five minutes! We’ll be using a very simple sample package to demonstrate this.

If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:

Let’s go!


We Love Feedback!

Did you like this video? Whatever the case, please leave a comment in the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.

Thank you!

Pin It on Pinterest