[ROS in 5 mins] 010 – What is ROS_MASTER_URI?

[ROS in 5 mins] 010 – What is ROS_MASTER_URI?

 

In this video, we will see what the ROS_MASTER_URI is in just 5 minutes. We’ll see what it represents and how it’s used in the entire ROS system.

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:

– ROS Development Studio (RDS), used for the demonstration: ROS Development Stdio
– Robot Ignite Academy, the place to learn to program robots using only a web browser: Robot Ignite Academy
– The openni_launch example from ROS Wiki: http://wiki.ros.org/openni_launch


Below are the Steps to create the project as shown in the video

Step 1

  • Head to ROS Development Studio and create a new project.
  • Provide a suitable project name and some useful description. (We have named the project )
  • Load/Open the project (this will take few seconds).
  • Open Tools > Shell and run following commands

$ echo $ROS_MASTER_URI

Note the result of the above command, it should have the following format http://<ip>:<port>. The following image shows a representational value


The specific values shown in the image are \<ip>=10.8.0.1 and \<port>=11311.

Step 2

  • The ip we just saw is also referred as hostname and it denotes the address of the computer running the roscore program.
  • To understand better, lets run a ros application

$ roslaunch openni_launch openni.launch

When the above command executes, it will launch the openni project. First of all ros master will be run (as shown) and once the ros master is ready other nodes are loaded. Note that there is only one ros master, however any number of nodes can exist.

Step 3

Next we can see how to change the ROS_MASTER_URI. The simplest way to change ROS_MASTER_URI is by editing the .bashrc file. This file is a system file and thus hidden by default, we will modify its content using the vi editor. Use the following command to start editing the .bashrc file (located in home directory)

$ vim ~/.bashrc

The following line is responsible for assigning the ros master ip

export ROS_MASTER_URI=http://10.8.0.1:11311

We can modify this line to use any other ip address. For reflecting the changed ip we will need to load this bash file. Use the following command to do so

$ source ~/.bashrc

Once we have sourced the bashrc file, we will see the changed ros master uri when launching ros project.

 


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] 009 – How to Launch a ROS node

[ROS in 5 mins] 009 – How to Launch a ROS node

 

In this video, we will see how to launch a ROS node in just 5 minutes. We’ll see four different way nodes can be launched in ROS, and how to check that a node has been launched:
* rosnode list

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:

– ROS Development Studio (RDS), used for the demonstration: http://ROS Development Studio
– Robot Ignite Academy, the place to learn to program robots using only a web browser: https://goo.gl/PoGfxC
– More about ‘rosrun’: https://www.theconstruct.ai/ros-5-mins-007-rosrun-works/
– Difference between ‘roslaunch’ and ‘rosrun’: https://www.theconstruct.ai/ros-5-mins-008-difference-rosrun-roslaunch/
– The turtlesim node examplefrom ROS Wiki: http://wiki.ros.org/ROS/Tutorials/UnderstandingNodes
– The openni_launch example from ROS Wiki: http://wiki.ros.org/openni_launch

The following steps take through the development as shown in the video

 

  • Open Robot Development Studio and create a new project (use a suitable name for project).
  • Open the project.
  • Start a Tools > Shell and start the roscore with following command

    $ roscore

This command starts the roscore. If the roscore is already running then it shows a warning message with roscore ip address information (as shown in green box in image)

The roscore starts as a node called /rosout. We can check the node with rostopic list command in another Shell

One way to launch a rosnode is using the rosrun command. For example

$ rosrun turtlesim turtlesim_node

This command will start the following nodes

  • /turtle1/cmd_vel
  • /turtle1/color_sensor
  • /turtle1/pose

We can verify these nodes with rostopic list command in a new window


Next we will see about running a custom node. We will create a project using catkin_create_pkg command. Then we will create a python script with following contents

#! /usr/bin/env python

import rospy

rospy.init_node('Obiwan')
rate = rospy.Rate(2)
while not rospy.is_shutdown():
    print("Help me Obi-wan Kenobi, you're my only hope")
    rate.sleep()

## This program creates an endless loop that repeats itself 2 times per second

Next we will launch the script with the following command

$ rosrun node_demo simple.py

We can check if the node is running or not with rostopic list command in a new shell


Now we will see how to run several nodes at the same time. This is done with the help of launch files and roslaunch command. For example:

$ roslaunch openni_launch openni.launch

This command will launch various nodes that can be listed with the rostopic list command.


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] 008 – What is the difference between rosrun and roslaunch

[ROS in 5 mins] 008 – What is the difference between rosrun and roslaunch

Hi!

In today’s video we are going to see what’s the difference between rosrun and roslaunch, when do we use one or another, and what are their advantages.

But before we start, if you are new to ROS and want to Learn ROS Fast, I recommend you to take any of the following courses on Robot Ignite Academy:

Whether you like the video or not, or if you want to learn about specific ROS subjects, please leave a comment on the comments section below, so we can interact and learn from each other.

Follow these steps to recreate the project as shown in the video

  • Go to Robot Ignite Academy. You will need to signup if you have not registered already.
  • In the home page, choose the course ROS Autonomous Vehicles 101 in the Advanced Courses category

  • Once you start the course, you will be greeted with the workspace like following (note: it will take a while to load the full page)

 

Now we will use the rosrun command to start a rqt_image_view node. Enter the following command in one of the SHELLS

rosrun rqt_image_view rqt_image_view

  • In order to see the visualisation we need to open the Graphical View by clicking on the graphical tool icon shown in the previous image. The graphical view opens in a new tab like follows

Since the model we are using (autonomous car) has many camera topics, we will need to choose one from the drop-down in the graphical view (shown in image).

  • rosrun essentially lets us start a single node. However, in many cases one needs to start multiple nodes at a time. To do this (launching multiple nodes simultaneously) we have launch file and the roslaunch command. Lets create such a launch file to launch xyz. Navigate to ~/catkin_ws/tuto/src/ and create a launch directory and create a file inside this directory launch_rviz.launch. Use the following command to achieve this

    $ cd ~/catkin_ws/src/tuto/ $ mkdir launch
    $ cd launch
    $ touch launch_rviz.launch

Next, we will add the following content to this file using the cloud9 editor. Use the editor to browse to the file and then double click on the file name to open it (as shown in image)

The code for the launch file as follows

<launch> 
    <node name="cam1" pkg="rqt_image_view" type="rqt_image_view" /> 
    <node name="cam2" pkg="rqt_image_view" type="rqt_image_view" /> 
</launch>

 

Now we will launch this launch file with the following command

roslaunch tuto launch_rviz.launch

On executing the above command we will see two new nodes appear and two rqt_image_view appear in the Graphical window tab. That’s all for this video.

 

[ROS in 5 mins] 007 – What is rosrun and how it works?

[ROS in 5 mins] 007 – What is rosrun and how it works?

 

Hi!

In today’s video we are going to see what’s rosrun, how rosrun works and what are its advantages.

If you are new to ROS and want to Learn ROS Fast, I recommend you to take any of the following courses on Robot Ignite Academy:

Whether you like the video or not, or if you want to learn about specific ROS subjects, please leave a comment on the comments section below, so we can interact and learn from each other.

Step1. 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 Mastering with ROS: TIAGO course as an example today.

Step2. What is rosrun and how it works?

At first, let’s try the command directly! Please type rosrun key_teleop key_teleop.py in the shell. You can move the robot with the arrow key now. If you type rosrun -h , you’ll see how you can use this command. The command will try to find the executable in the given package and execute it. If you go to the package directly, you can of course execute the executable with ./ command. The rosrun , however, offers you a much faster way to find your executable located in different packages.

Want to learn more?

If you are interested in this topic, please visit our ROS In 5 Days (Python)  course. You’ll learn not only how to create the workspace, but also packages, topic, service, and action in ROS.

 

Edit by: Tony Huang

 

[ROS In 5 Minutes] 006 – What is a ROS launch file?

Hi all!

Welcome to this “ROS In 5 Minutes” videos series.

In today’s videos we are going to see what’s a launch file and how to launch it.

If you want to Learn ROS Fast, we recommend you the following courses:

ROS In 5 Days (Python)
ROS In 5 Days (C++) 

Whether you like the video or not, please leave a comment on the comments section below, so we can interact and learn from each other.

 

Step1. 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 ROS Basic course as an example today.

Step2. Create package

Let’s create a package called tutorial first with the following command

cd ~/catkin_ws/src
catkin_create_pkg tutorial rospy

Under the tutorial/src folder, create 2 files called publisher.py and subscriber.py.

#! /usr/bin/env python

import rospy
from std_msgs.msg import String

rospy.init_node('tutorial')

publisher = rospy.Publisher('/say_hello', String, queue_size=1)
rate = rospy.Rate(3) # 3 Hz

while not rospy.is_shutdown():
    publisher.publish('Hey!')
    rate.sleep()
#! /usr/bin/env python
import rospy
from std_msgs.msg import String

rospy.init_node('subscriber')

def callback(data):
    print 'Subscriber received a msg: ', data.data

sub = rospy.Subscriber('/say_hello', String, callback)
rospy.spin()

Remember to give execute permission to the file with chmod +x  command. Then you can run the file with rosrun  command. However, it’s not quite convenient, right? What if you want to run several files at the same time?

That’s why we need launch files. Let’s create one called pub_sub.launch under the tutorial/launch folder with the following content.

<launch>
    <node name="publisher" pkg="tutorial" type="publisher.py" />
    <node name="subscriber" pkg="tutorial" type="subscriber.py" output="screen" />
</launch>

Then we can run it with roslaunch tutorial pub_sub.launch . You can see a launch file is a powerful tool for us to launch multiple files in one single file.

If you want to learn more about this topic, please check our  ROS In 5 Days (Python) course. You’ll learn much more about what launch files can do in this course.

 

Edit by: Tony Huang

Pin It on Pinterest