Ask Your Question

How to use <param> in launch files to change variable values in node scripts?

asked 2016-03-28 20:32:05 -0600

pgigioli gravatar image

updated 2016-03-28 20:52:13 -0600

I'm trying to use in launch files to change variable values in node scripts but it doesn't seem to work.

Here is my launch file:


  <include file="$(find turtlebot_bringup)/launch/minimal.launch" />

  <include file="$(find turtlebot_navigation)/launch/gmapping_demo.launch" />

  <include file="$(find frontier_exploration)/launch/global_map.launch" />

  <node name="send_exploration_goal" pkg="turtlebot_demos" type="send_exploration_goal"/>
     <param name="set_linear_vel" value="0.1" />
     <param name="set_angular_vel" value="0.1" />


And here is a skeleton of the node script:

#include ...

void function()

int main(int arcg, char** argv)
   float set_linear_vel = 0.25;
   float set_angular_vel = 0.50;
  1. My first question is, am I doing this right?
  2. Second, does it matter where I define the variables in the node script? Should they be defined as global variables, defined inside int main(), or inside void function()?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-28 20:53:00 -0600

ahendrix gravatar image

updated 2016-03-28 20:56:03 -0600

If you want to use ROS parameters in your C++ code, you need to explicitly read those parameters into a variable.

I'd suggest you go through the ROS C++ parameters tutorial

When you declare a parameter with a <param> tag in a launch file, you're creating a private parameter within that node's namespace, so you should also read through the tutorial on private namespaces: Accessing Private Names from a NodeHandle (roscpp)

edit flag offensive delete link more


Thanks! I didnt realize there was documentation for this. I'll check it out.

pgigioli gravatar image pgigioli  ( 2016-03-28 22:11:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-03-28 20:32:05 -0600

Seen: 2,914 times

Last updated: Mar 28 '16