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

rosparam returns string not yaml array

asked 2013-11-03 11:31:47 -0600

dcconner gravatar image

I'm trying to define an array in yaml file and load into parameter server in launch file. The following bit of code

XmlRpc::XmlRpcValue temp;  
nhp.searchParam("/r_arm/position/my_param", temp);  
ROS_ASSERT(temp.getType() == XmlRpc::XmlRpcValue::TypeArray);

Fails with the assertion that "temp" is an XmlRpcValue::TypeString not an array, even though

rosparam get /r_arm/position/my_param
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

shows the array.

They yaml code looks like:


Any ideas what I am doing wrong?

(ros Groovy version)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-11-05 07:07:35 -0600

Try to replace

nhp.searchParam("/r_arm/position/my_param", temp);


nhp.getParam("/r_arm/position/my_param", temp);

searchParam() searches the namespace tree upwards and returns the name of the first existing parameter, not its value. You still would have to call getParam() to retrieve the value. The XmlRpc::XmlRpcValue is implicitly casted into a string reference when passed to searchParam() and therefore has type TypeString afterwards.

See for further details.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-11-03 11:31:47 -0600

Seen: 1,122 times

Last updated: Nov 05 '13