I am trying to use the following as input values to an arg command in my roslaunch file as follows:

  <arg name="x_pos" value="3.0"/>
  <arg name="y_pos" value="4.0"/>
  <arg name="z_pos" value="0.0"/>
  <arg name="yaw" value="0.0"/>

However, the doubles I entered do not show up when I try to access them from my C++ node; I read the arg attributes and they do not mention anything about the type of value. Is it by default only string? If that's the case, how do I pass in the doubles so that I can access them in my C++ node?

  • $\begingroup$ Please edit your question to show us your launch file xml which writes the value to the parameter server. $\endgroup$
    – Mike973
    Commented Sep 28, 2023 at 21:20

2 Answers 2


As there is no C++ code mentioned in the question, I wonder if I understood your requirements correctly. However, I never faced issues with integers or double datatypes with the ROS launch file. Below is a code snippet:

ROS launch file:

  <!-- your integer arguments -->
  <arg name="k_neighbors" default="10"/>
  <arg name="max_itr" default="1000"/>

  <!-- your double arguments -->
  <arg name="weight" default="0.05"/>
  <arg name="d_thresh" default="0.005"/>
  <arg name="prob" default="0.99999"/>

  <!-- your float arguments -->
  <arg name="radius" default="0.05"/>

  <!-- your string arguments -->
  <arg name="limb" default="right"/>

C++ node:

int main(int argc, char **argv)
  ros::init(argc, argv, "my_node");
  ros::NodeHandle nh("~");

  // define integer parameter and then fetch their values from parameter server
  int k_neighbors, max_itr;
  nh.getParam("k_neighbors", k_neighbors);
  nh.getParam("max_itr", max_itr);

  // define double parameter and then fetch their values from parameter server
  double weight, d_thresh, prob;
  nh.getParam("weight", weight);
  nh.getParam("d_thresh", d_thresh);
  nh.getParam("prob", prob);

  // define float parameter and then fetch their values from parameter server
  float sphere_radius;
  nh.getParam("radius", sphere_radius);

  // define string parameter and then fetch their values from parameter server
  std::string limb;
  nh.getParam("limb", limb);

  // rest of your logic goes here
  return 0;

You may look for launch file and C++ node.


I looked at github issue "Can't pass in a numerical string as arg param to C++ node" and found that putting single quotes around the double, within double quotes, works:

  <arg name="x_pos" value="'3.0'"/>
  <arg name="y_pos" value="'4.0'"/>
  <arg name="z_pos" value="'0.0'"/>
  <arg name="yaw" value="'0.0'"/>
  • 1
    $\begingroup$ This is ugly, and requires users of your launch file to remember that some args need weird quoting to be done. If you really want to force a property to be a string on the parameter server, then specify that in a param tag: <param name="x_pos" type="str" value="$(arg x_pos)" />. $\endgroup$
    – Mike973
    Commented Sep 30, 2023 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.