Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change variable values in node scripts using in launch files?

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:

<launch>

  <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" />
  </node>

</launch>

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()?

Thanks!

How to change variable values in node scripts using in launch files?

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:

<launch>

  <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" />
  </node>

</launch>

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()?

Thanks!