ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I think your problem here is not with getParam, but with the way you've structured your output.

The evaluation order of "<<" is undefined, so the compiler is free to evaluate the statements on the output line in whatever order it chooses. If it chooses a right-to-left order, then it will try and string-ify the value of "myDoubleFromRos" before the call to _node.getParam(), so the value is uninitialized.

Try the following:

double myDouble = 7.7, myDoubleFromRos;
_node.setParam("/my_double", myDouble);

std::cout << "get success = " << _node.getParam("/my_double", myDoubleFromRos);
std::cout << "get value = " << myDoubleFromRos << " value should be = " << myDouble;

For more explanation, see the discussion here.