Ask Your Question
1

rosparam returns string not yaml array

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

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:

{r_arm:{position:{
     my_param:[0.0,0.0,0.0,0.0,0.0,0.0]
    ,my_param2:[0.0,0.0,0.0,0.0,0.0,0.0]
    },force:{ 
       ...

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
2

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

Try to replace

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

with

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 http://wiki.ros.org/roscpp_tutorials/Tutorials/Parameters#Searching_for_Parameters for further details.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 986 times

Last updated: Nov 05 '13