How to pass a parameter of type double as an input to a roscpp node?
I'm trying to pass a variable of type "double" to a roscpp node as a command-line variable. E.g.
$ rosrun package_name node_name parameter:=0.1
And then access the parameter within the node like so:
ros::NodeHandle nh;
double parameter;
nh.param("parameter", parameter, 0.5);
However this doesn't work, and instead I get the following error:
terminate called after throwing an instance of 'ros::InvalidNameException'
what(): Character [0] is not valid as the first character in Graph Resource Name [0.1]. Valid characters are a-z, A-Z, / and in some cases ~.
I'm sure I've just got the wrong syntax, either within the node or when entering the parameter. I've thoroughly read the wiki pages on NodeHandle and the Parameter Server, but I haven't found a solution. Everything I've tried either produces the error above, or my ignores the input and sets the parameter to it's default value (0.5). Is anyone able to correct my syntax?
Thanks in advance.