[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!

[ROS in 5 mins] 035 – How to create a ROS Action Client

[ROS in 5 mins] 035 – How to create a ROS Action Client

Hi ROS Developers,

in today’s post, we are going to learn how to create a ROS Action Client, how to call the Action Server and print the feedback and result messages.

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

Let’s get started.

Creating the ROS Action Server

In order to create a ROS Action Client, we first need to create the Action Server. We have already learned how to do that on the previous post: https://www.theconstruct.ai/ros-5-mins-033-create-ros-action-server/

Please make sure you follow that post first since the client we will create here will call that server.

Creating the ROS Action Client

If you followed the post on how to create an Action Server, we should have the following output after running the tree . command on the ~/catkin_ws/srcfolder.

user:~/catkin_ws/src$ tree .
.
├── actions_tutorial
│   ├── action
│   │   └── WashTheDishes.action
│   ├── CMakeLists.txt
│   ├── package.xml
│   ├── scripts
│   │   └── action_server.py
│   └── src
└── CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake

4 directories, 5 files

As you can see we have a scripts folder with our action_server.py there. We will create our action_client.py in the same folder. Let’s use the commands below for that:

cd ~/catkin_ws/src/actions_tutorial/scripts/
touch action_client.py
chmod +x action_client.py

With the code above we created an empty python file and gave it execute permissions. With the tree ~/catkin_ws/src command you should have something like:

tree ~/catkin_ws/src
/home/user/catkin_ws/src
├── actions_tutorial
│   ├── action
│   │   └── WashTheDishes.action
│   ├── CMakeLists.txt
│   ├── package.xml
│   ├── scripts
│   │   ├── action_client.py
│   │   └── action_server.py
│   └── src
└── CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake

4 directories, 6 files

Now let’s paste the following code on the action_client.py file:

#! /usr/bin/env python

import rospy
import actionlib
from actions_tutorial.msg import WashTheDishesAction, WashTheDishesGoal

def feedback_cb(msg):
 print 'Feedback received:', msg

def call_server():

    client = actionlib.SimpleActionClient('wash_dishes_as', WashTheDishesAction)

    client.wait_for_server()

    goal = WashTheDishesGoal()
    goal.number_of_minutes = 7

    client.send_goal(goal, feedback_cb=feedback_cb)

    client.wait_for_result()

    result = client.get_result()

    return result

if __name__ == '__main__':

    try:
        rospy.init_node('action_client')
        result = call_server()
        print 'The result is:', result
    except rospy.ROSInterruptException as e:
        print 'Something went wrong:', e

In this file what we do is basically call the Action Server defined in the previous post and print the feedback and the result messages sent by the server.

Running the ROS Action Client

With everything in place, let’s now launch our server and our client and see they work together. To launch the server we can use the command below:

source ~/catkin_ws/devel/setup.bash
rosrun actions_tutorial action_server.py

and in a different shell we run the next command:

source catkin_ws/devel/setup.bash
rosrun actions_tutorial action_client.py

Everything should have run smoothly and you should see in the output something like:

Feedback received: last_dish_washed: "bowl-0"
Feedback received: last_dish_washed: "bowl-1"
Feedback received: last_dish_washed: "bowl-2"
Feedback received: last_dish_washed: "bowl-3"
Feedback received: last_dish_washed: "bowl-4"
Feedback received: last_dish_washed: "bowl-5"
Feedback received: last_dish_washed: "bowl-6"
The result is: dishes_washed: [bowl-0, bowl-1, bowl-2, bowl-3, bowl-4, bowl-5, bowl-6]

So, congratulations, you now know how to create an Action Server as well as an Action Client.

To make your life easier, we have also prepared a video showing all the process explained in this post.

I hope you have enjoyed the post and the video, if so, please consider giving us a thumbs up. You can also subscribe to our channel and press the bell so that you won’t miss our updates.

We love feedback, so, whether you like the video or not, please share your thoughts on the comments section of the video.

Keep pushing your ROS Learning.

[ROS in 5 mins] 034 – What is ROS Action?

[ROS in 5 mins] 034 – What is ROS Action?

In this post, we will see what a ROS Action is. We’ll also see the difference between a ROS Service and a ROS Action.

Let’s go!

Step 1: Understand blocking and non-blocking activities: two possible ways to buy Pizza

Let’s assume you wish to order some pizza. There are two possible ways you could go about it:

  1. Go the Pizza shop
    1. Place your order.
    2. Wait for the order.
    3. Get the Pizza.
  2. Order online.
    1. Place your order.
    2. Order confirmation notice.
    3. Possibly cancel the order.
    4. Check up your order status once in a while.
    5. Do other things.
    6. Pizza is delivered.

Option 1 is a blocking activity because you have to wait (in theory not able to do anything else) for the pizza, while option 2 is non-blocking because you can do some other things while your order is being processed.

Step 2: Apply blocking and non-blocking concept to ROS

Option 1 (Going to Pizza shop) is similar to a ROS Service, while option 2 is similar to a ROS Action. Not 100% the same, but I suppose you get the point. But what is a ROS Action specifically, in ROS terminology?

An action is an asynchronous call to another node’s functionality. “Asynchronous” means you don’t have to wait for the result. You can do other things pending the result.

The node that provides the functionality has to implement an Action Server (Pizza shop). The node that uses the functionality has to use an Action Client (online ordering system).

Step 3: Dive a bit deeper – ROSified pizza ordering

Now, let’s see what ROS calls each of the steps for buying pizza:

  1. Go the Pizza shop
    1. Place your order (request).
    2. Wait for the order.
    3. Get the Pizza (response).
  2. Order online
    1. Place your order (request).
    2. Order confirmation notice (feedback).
    3. Possibly cancel the order (cancel).
    4. Check up your order status once in a while (status).
    5. Do other things.
    6. Pizza is delivered (response).

To wrap up, consider the image below, saying roughly saying the same thing we have been saying, only in a “thousand words”:

ros_action

 

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!

Pin It on Pinterest