Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROS 2 Crystal : Can't get parameter list of string from command line

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.

ROS 2 Crystal : Can't get parameter list of string from command line

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.

ROS 2 Crystal : Can't get parameter list of string from command lineYAML 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.