ROS 2 Crystal : Can't get parameter list of string from YAML file
Hi, I'm using ROS 2 Crystal and I'm trying to get a list of string from a YAML file in Python.
The problem is that my list also contains numbers, I don't mind them being converted into strings so my YAML file looks like:
some_node:
ros__parameters:
some_list: ['1', '2', '3', '4', 'some_string']
But the parser keeps converting the strings '1', '2', etc into numbers so I get an error Failed to parse yaml params file ...: Sequence should be of same type. Value type 'string' do not belong at line_num X
.
If I change some_string
to an int, I do get an ARRAY_INTEGER
but that's not what I want.
Any way to force the YAML parser to keep '1'
as a string ?
I tried using double quotes "1"
, I tried adding !!str
or !!string
but it seems to be ignored and gives the same result.
As a temporary solution, I escape my list with a :
and remove it in the code but it's a bit ugly...
some_node:
ros__parameters:
some_list: [':1', ':2', ':3', ':4', ':some_string']
Thanks.
edit: Same problem in ROS 2 Dashing.
This sounds like a bug in the YAML parser. If a value is quoted I think it should be interpreted as a string, not a number. You can open an issue at https://github.com/ros2/rcl
ok, I opened an issue: https://github.com/ros2/rcl/issues/461