Closed Affonso-Gui closed 2 years ago
if this feature is supported by roscpp/rospy, we'd better to support in roseus
Yes, this is supported in both rospy and roscpp:
# test.py
rospy.init_node("py")
rospy.get_param("/that")
# {'test': {'a': 1, 'b': [1, 2, 3]}}
rospy.set_param("/this", rospy.get_param("/that"))
rospy.get_param("/this")
# {'test': {'a': 1, 'b': [1, 2, 3]}}
// test.cpp
#include <ros/ros.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "cpp");
ros::NodeHandle n;
XmlRpc::XmlRpcValue val;
n.getParam("/that", val);
n.setParam("/another", val);
}
$ rosparam get this
test:
a: 1
b: [1, 2, 3]
$ rosparam get that
test:
a: 1
b: [1, 2, 3]
$ rosparam get another
test:
a: 1
b: [1, 2, 3]
Actually, roseus does support recursive ros::set-param
through alists, it is only not able to interpret string names, which happen to be the format returned by ros::get-param
.
I have adjusted the code to accept string params as well, and added test code.
Found another problem:
irteusgl$ (ros::set-param "test" '(((a . 1) (b . 2))))
[ERROR] [1652371517.860218315] [${node}]: ROSEUS_SET_PARAM: EusValueToXmlRpc: assuming symbol
(a . 1)
t
This corresponds to a list of dictionaries, as in the following:
test:
- {a: 1, b: 2}
This is because in https://github.com/jsk-ros-pkg/jsk_roseus/blob/master/roseus/roseus.cpp#L1282 an alist is defined as a cons with a cons car. A list of dictionaries meets this criteria, but does not have a key element, thus leading to the error.
Added tests & fixed.
@Kanazawanaoaki
Allows to recursively set values organized in alists at
ros::set-param
.Needs discussion & testing.
Partially related to https://github.com/jsk-ros-pkg/jsk_roseus/issues/709