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

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

Written by Ruben Alves

10/07/2018

 

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

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

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