ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS 2 Crystal : Can't get parameter list of string from YAML file

asked 2019-06-11 03:16:49 -0600

Marc Testier gravatar image

updated 2019-06-11 21:23:11 -0600

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.

edit retag flag offensive close merge delete

Comments

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

jacobperron gravatar image jacobperron  ( 2019-06-18 20:52:06 -0600 )edit
Marc Testier gravatar image Marc Testier  ( 2019-06-19 19:52:45 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-09-19 20:01:32 -0600

Marc Testier gravatar image

updated 2019-09-19 20:02:03 -0600

Seems like the issue as been fixed: https://github.com/ros2/rcl/issues/461.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-06-11 03:16:49 -0600

Seen: 1,637 times

Last updated: Sep 19 '19