[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

Written by Ruben Alves

11/06/2018

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.

 

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

0 Comments

Trackbacks/Pingbacks

  1. [ROS in 5 mins] 009 - How to Launch a ROS node | The Construct - […] – Difference between ‘roslaunch’ and ‘rosrun’: https://www.theconstruct.ai/ros-5-mins-008-difference-rosrun-roslaunch/ – The turtlesim node examplefrom ROS Wiki: […]

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This