parameter communication by using launch file
I'd like to use parameter communication by using launch file.
First, I make the following node.
#include <ros/ros.h>
int a=0;
int b;
int main(int argc, char **argv)
{
ros::init(argc, argv, "param_test");
ros::NodeHandle nh;
nh.setParam("param_str",a);
ros::Rate r(10);
while(ros::ok())
{
nh.getParam("param_str", b);
ROS_INFO_STREAM(b);
r.sleep();
}
}
This node is only showing the value of "b".
then,I make the following launch file.
<launch>
<node pkg="ros_p" name="ros_p_node" type="ros_p_node" output="screen"/>
<param name="param_str" type="int" value="1" />
</launch>
I want to change the value of "b" to 1,but it showed 0.
waht is it incorrect?
I want to set the value 'b' by using launch file even though the initial value(a=0) is allocated .