Can't get double parameter in node (C++)
I have a launch file with:
<arg name="INTENSITY" default="1.2" />
<param name="my_intensity" type="double" value="$(arg INTENSITY)" />
The same launch file starts a ROS node, my_node . In my_node's main method I have the following, to get that parameter:
ros::init(argc, argv, "my_node");
ros::NodeHandle nh;
string param_name;
if(!nh.searchParam("/my_intensity", param_name) ){
ROS_ERROR("Can't find param.");
return -1;
}
double it;
ros::param::get(param_name, it);
ROS_INFO("Intensity is %f.", it);
...
Running this prints Intensity is 0.0.
. Although when I run rosparam get /my_intensity
in a terminal window I get the correct value (1.2).
When I change the type of it
to string, what I get is an empty string. The same approach always worked for my other nodes. So I am really confused. What may be causing this behavior?
Thank you.
System: Ubuntu 16.04, ros-kinetic.
Please add the bit from your launch file where you start your node.