—
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
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
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.
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:
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.
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)
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.
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.
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.