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

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

Written by The Construct

11/06/2018

 

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!

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

0 Comments

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