ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
How did you create nh in your code? If you declare it with
ros:: NodeHandle nh("~")
then it'll be in the private namespace of your node. Honestly that's the only source of this problem that I can think of. Also make sure you're spelling the names correctly :)
To test the namespaces, you can use the NodeHandle method resolveName (see http://docs.ros.org/indigo/api/roscpp/html/classros_1_1NodeHandle.html#a9eab8c5ff7ca9d3468d2a35dcd84ae40).
2 | No.2 Revision |
How did you create nh in your code? If you declare it with
ros:: NodeHandle nh("~")
then it'll be in the private namespace of your node. Honestly that's the only source of this problem that I can think of. Also make sure you're spelling the names correctly :)
To test the namespaces, you can use the NodeHandle method resolveName (see http://docs.ros.org/indigo/api/roscpp/html/classros_1_1NodeHandle.html#a9eab8c5ff7ca9d3468d2a35dcd84ae40).
EDIT
Editing given the different question. I tried the following:
>> rosparam set /test/m '{"id0":0, "id1":1}'
>> rosparam get /
test:
m: {id0: 0, id1: 1}
>> rosparam get /test/m
{id0: 0, id1: 1}
>> rosparam get /test/m/id0
0
>> rosparam get /test/m/id1
1
This is explained in http://wiki.ros.org/rosparam#rosparam_set, and it basically means that when you give a YAML string to rosparam set, it gets converted in a dictionary of parameters. You can see this behaviour if you do:
>> rosparam set -v /test/m '{"id0":0, "id1":1}'
set parameter [/test/m/id0] to [0]
set parameter [/test/m/id1] to [1]
Therefore the parameter you are looking for in your code (/test//m) doesn't exist as a string, but it's a dictionary! If you want to set a parameter to a string representing a YAML line, you can do something like:
>> rosparam set -v /test/m "\"{'id0':0, 'id1':1}\""
set parameter [/test/m] to [{'id0':0, 'id1':1}]
Even though it looks ugly :)
3 | No.3 Revision |
How did you create nh in your code? If you declare it with
ros:: NodeHandle nh("~")
then it'll be in the private namespace of your node. Honestly that's the only source of this problem that I can think of. Also make sure you're spelling the names correctly :)
To test the namespaces, you can use the NodeHandle method resolveName (see http://docs.ros.org/indigo/api/roscpp/html/classros_1_1NodeHandle.html#a9eab8c5ff7ca9d3468d2a35dcd84ae40).
EDIT
Editing given the different question. since the original question changed. I tried the following:
>> rosparam set /test/m '{"id0":0, "id1":1}'
>> rosparam get /
test:
m: {id0: 0, id1: 1}
>> rosparam get /test/m
{id0: 0, id1: 1}
>> rosparam get /test/m/id0
0
>> rosparam get /test/m/id1
1
This is explained in http://wiki.ros.org/rosparam#rosparam_set, and it basically means that when you give a YAML string to rosparam set, it gets converted in a dictionary of parameters. You can see this behaviour if you do:
>> rosparam set -v /test/m '{"id0":0, "id1":1}'
set parameter [/test/m/id0] to [0]
set parameter [/test/m/id1] to [1]
Therefore the parameter you are looking for in your code (/test//m) doesn't exist as a string, but it's a dictionary! If you want to set a parameter to a string representing a YAML line, you can do something like:
>> rosparam set -v /test/m "\"{'id0':0, 'id1':1}\""
set parameter [/test/m] to [{'id0':0, 'id1':1}]
Even though it looks ugly :)