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

Revision history [back]

click to hide/show revision 1
initial version

Now on ROS Indigo, I can get the list to an argument as follows:

rosrun pkg node _param:="[1, 2]"

This will put a list with two numbers on the param server.

It seems to be documented here: http://wiki.ros.org/ROS/YAMLCommandLine . Strings would be quoted by the other type of quotes than the one used to quote the whole list.

In rospy, it works out of the box:

print rospy.get_param("~param")[0]

In roscpp, the use is also as easy as:

std::vector<double> v;
pnh.param("param", v, std::vector<double>());

Problems can arise when you want to pass the array to the node using a roslaunch file - then the clasical "<arg> and <param> policy" won't work, since roslaunch doesn't know about list types and will convert the list to a single string. Since Lunar, you may use the construct <param name="param" type="yaml" value="$(arg param)" /> (documentation). In Indigo, you can achieve a similar result by <rosparam param="param" subst_value="True">$(arg param)</rosparam> (documentation).