[ROS in 5 mins] 019 – What is a ROS Topic

[ROS in 5 mins] 019 – What is a ROS Topic

 

Hello ROS Developers!

In today’s video we are going to see what are ROS Topics and how they work.

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

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

We love feedback, so, whether you like the video or not, please leave a comment on the comments section below so that 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 Basics in 5 Days course as an example today.

Step2. What is a ROS topic

rqt_graph is a great tool to visualize the nodes and topics in the system. Run the command in a shell and open the graphical tool(you can find it by clicking the computer icon on the edge of the simulation). You should see the gazebo is publishing the joint state.

Then we run roslaunch publisher_example move.launch  and examine the graph again. You should see that a new node called move_node pops out and publishing to the topic cmd_vel topic.

The last step is using rosrun tutorial subscriber.py  command to subscribe the cmd_vel topic. You can see that another new node comes out with the name i_am_the_7th_robot. Actually you can launch as many subscribers as you want and subscribe to the same topic.

In conclusion, the topic is a way that the nodes communicate with each other.

Want to learn more?

If you are interested in this topic, please check our ROS Basics In 5 Days (Python) course. You’ll learn how to use publisher, subscriber, service, and action to control a robot.

 

Edit by: Tony Huang

[ROS in 5 mins] 015 – How to use remap in launch files

[ROS in 5 mins] 015 – How to use remap in launch files

 

Hello ROS Developers!

In today’s video we are going to see how to use remap in a launch file.

For that we are going to use Robot Ignite Academy.

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:

ROS Basics In 5 Days (Python) 
ROS Basics 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!

Step2. Create a package

Let’s go to the Robot Creation with URDF course today, this course teaches you how to create robot description in the URDF format.

Then we type the following command to create a package with dependencies.

cd ~/catkin_ws/src
catkin_create_pkg tutorial rospy

We’ll use a publisher as an example. Let’s call it publisher.py and put it under the tutorial/src directory. Remember to give it permission to execute with chmod +x publisher.py . The code for publisher.py is the following:

#! /usr/bin/env python

import rospy
from std_msgs.msg import String

pub = rospy.Publisher('topic_name', String, queue_size=10)
rospy.init_node('node_name')

r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
pub.publish("hello world")
r.sleep()

After that, we have created a file remap_demo.launch with the following content under the tutorial/launch folder.

<launch>
    <node name="node_name" pkg="tutorial" type="publisher.py" />
</launch>

then we can launch it with roslaunch tutorial remap_demo.launch

By typing rostopic list , you should see that the node_name is published in the topic list.

Then let’s try to remap it by changing the content in remap_demo.launch file.

<launch>
    <remap from="topic_name" to="iloveyou" />
    <node name="node_name" pkg="tutorial" type="publisher.py" />
</launch>

Let’s launch it again, you should see that the name of the node has been changed to iloveyou!

 

 

Edit by: Tony Huang

[ROS in 5 mins] 017 – How to include a launch file inside a launch file

[ROS in 5 mins] 017 – How to include a launch file inside a launch file

Hello ROS Developers!

In today’s video we are going to see how to include a ROS launch file inside of another one, which is really useful specially if you are working with big projects.

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:

ROS Basics In 5 Days (Python)
ROS Basics 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 TF ROS 101 course as an example today.

Step2. Create a package

With the following command, you can create a package without any dependency from a shell

cd ~/catkin_ws/src
catkin_create_pkg tutorial

Let’s say we want to create a launch file called include_demo.launch to launch another launch file called listener_with_user_data.launch from rospy_tutorial package. We can use the include tag in our launch file like this

<launch>
    <include file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" />
</launch>

Then you run roslaunch tutorial include_demo.launch . You should see the talker nodes launched by the tutorial. You can also specify namespace like following  to launch the same file with different namespace multiple times.

<launch> 
    <include ns="robot1" file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" /> 
    <include ns="robot2" file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" /> 
</launch>

This technic is especially useful when you are running a huge project. You can also specify different TF coordinate to the different robot in a similar way.

If you are interested in how to define multiple robot joints coordinates using TF, please check our TF ROS 101 course.

 

Edit by: Tony Huang

[ROS in 5 mins] 013 – What is a ROS Package

[ROS in 5 mins] 013 – What is a ROS Package

 

Hello ROS Developers!

In today’s video we are going to see what are ROS Packages, see their basic structure and also see how to navigate among them.

For that, we are going to use Robot Ignite Academy, which is available here

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:

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

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!

Step2. Create a package

We’ll go to the ROS in 5 Days(C++) course today. Let’s go to 2nd part-ROS Basics and start by creating a package

cd ~/catkin_ws/src
catkin_create_pkg my_package rospy

With the command, ROS will create a package with the CMakeLists.txt and package.xml files automatically for compiling and building. The package is the basic building block for ROS project. Basically, every ROS application is built with packages. Take the following command as an example

roslaunch turtlebot_teleop keyboard_teleop.launch

Where the turtlebot_teleop is a ROS package and keyboard_teleop.launch is a launch file in this package.

In the RIA, all the packages you’ll need is already installed for you. The only thing you need to do is focus on learning ROS!

 

Edit by: Tony Huang

What is ROS Parameter Server?

What is ROS Parameter Server?

Hello ROS Developers! In this post, we will see what the ROS parameter server is in less than 5 minutes! We’ll see what it entails and some of the commands we can use to work with it within the ROS system.

Let’s go!

Step 1: Setup your development environment

To follow this post, you need a computer with ROS already installed. There are three options, but I strongly recommend option 3 as it’s the easiest and the only one I can guarantee will work. That’s the option I’m using for this post.

  1. You have ROS installed locally, such that kinetic <= version < crystal. Good to go; just be ready to spin up a terminal.
  2. You don’t have ROS installed but you have docker: run docker run -it osrf/ros:kinetic-desktop in your terminal to pull a ROS docker image. Please note:
    • Docker will “pull” this image if you don’t have it locally already.
    • You need to run this command on every terminal you use in this post, before typing any other command!
  3. Neither ROS nor docker is installed? No problem – launch a ready-to-go development environment on ROS Development Studio (ROSDS) within your browser! If you don’t have an account yet, you can create a free account. Once you log in, create a project and call it rosparam_demo. In your project configuration, select Ubuntu 16.04 + ROS Kinetic + Gazebo 7. To “open a terminal”, pick the Shell app from the Tools menu.

Step 2: Run some commands to learn about the ROS Parameter Server

Open a terminal and run the following command:

user:~$ rosparam list
ERROR: Unable to communicate with master!

I got my fingers burned while trying that command…ouch! The parameter server is part of the ROS master, so we need to get it started first. If you didn’t get your fingers burned, then you “cheated” – you had the ROS master running previously 🙂 .

Now let’s do the right thing by starting the master first. In another terminal, run

user:~$ roscore
...

started roslaunch server http://instance:45696/
ros_comm version 1.12.14


SUMMARY
========
PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES

auto-starting new master
process[master]: started with pid [22611]

...

We can already see two parameters listed under the heading “PARAMETERS”: /rosdistro and /rosversion, from the output of the command above. But back up there and let’s rerun the “finger-burning” command:

user:~$ rosparam list
ERROR: Unable to communicate with master!
user:~$ rosparam list
/rosdistro
/roslaunch/uris/host_instance__45696
/rosversion
/run_id

Great, now I got away with my fingers intact, and here we have a list of all current ROS parameters, including the ones mentioned earlier in the roscore command output. Next, let’s explore another sub-command of rosparam: get.

user:~$ rosparam get /roslaunch/uris/host_instance__45696
http://instance:45696/
user:~$ rosparam get /roslaunch/uris/
{host_instance__45696: 'http://instance:45696/'}
user:~$ rosparam get /roslaunch
uris: {host_instance__45696: 'http://instance:45696/'}

I decided to get one of the params from the list command that demonstrates that ROS parameters can be stored and retrieved in hierarchies, to store related parameters and to prevent parameter names from colliding.

Finally, let’s explore one more command: set.

user:~$ rosparam set /our_own_param "learning ROS params"
user:~$ rosparam list
/our_own_param
/rosdistro
/roslaunch/uris/host_instance__45696
/rosversion
/run_id
user:~$ rosparam get /our_own_param
learning ROS params

You get the gist! Finally, here’s a list of commands available for working with ROS parameters; have fun exploring them!

user:~$ rosparam -h
rosparam is a command-line tool for getting, setting, and del
eting parameters from the ROS Parameter Server.

Commands:
        rosparam set    set parameter
        rosparam get    get parameter
        rosparam load   load parameters from file
        rosparam dump   dump parameters to file
        rosparam delete delete parameter
        rosparam list   list parameter names

And that’s it! Now’s let wrap up by doing some “small talk” about the topic.

Step 3: Master the concept – what is ROS Parameter Server?

I believe that by now you know what the ROS parameter server is in practiceIn theory, according to ROS Wiki, “A parameter server is a shared, multi-variate dictionary that is accessible via network APIs. Nodes use this server to store and retrieve parameters at runtime.”

You can use the parameter server to store data that you want to access ‘globally’ from your ROS code. Since it exists on the ROS master, it’s available to all nodes and all machines connected to the master.

You can read more about the parameter server from the ROS Wiki: http://wiki.ros.org/Parameter%20Server.

endsmalltalk.

Extra: Video

Not a “postworm” and prefer to see the ‘sights and sounds’ version of this post? We made this video just for you!

Feedback

If you want to learn more about ROS parameters, please remember to check our ROS Basics In 5 Days (Python)  course!

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

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

Pin It on Pinterest