Open paulerikf opened 11 months ago
I now realize that I can work around this issue by having the substitution return a string with the list specified in yaml format. Would still be nice to be able to use a singular substitution that returns a non-string.
@adityapande-1995 @methylDragon would one of you be willing to try reproducing this on rolling? 🧇
I'm also having the same traceback on Humble and workedaround it for the moment. I haven't yet pinpointed where the issue comes from to create a minimal reproducible example, I'll try to find some time for it
Bug report
Required Info:
Steps to reproduce issue
Hopefully I'm not misunderstanding something major about substitutions here, please let me know if I am.
I'm attempting to set a parameter value with a substitution that returns a list of strings. Everything is fine if I set the parameter value with a normal list i.e:
'ingredients': ['apples', 'oranges', 'berries']
. However, when I use a Substitution that returns the same list I get an error.Simple test node that gets a string list parameter:
Launch file example:
Expected behavior
I expect the parameter to be set to the result of the substitution. In this case, a list of strings (in the example: ['berries', 'chocolate', 'grapes', 'apples', 'oranges']).
This feels like it should be in line with the description of possible parameter values in normalize_parameters.py
Actual behavior
It seems like it's being treated as a list of substitutions: https://github.com/ros2/launch_ros/blob/bc609787102ae1c0b8ad2ee9dbecf0165a9108a2/launch_ros/launch_ros/utilities/evaluate_parameters.py#L69-L72
And therefore an attempt is made to convert it into a string: https://github.com/ros2/launch/blob/dd6ab0edf19c2f35b8e71aa8151df50b8a2feff9/launch/launch/utilities/perform_substitutions_impl.py#L24-L26
Which results in:
TypeError: sequence item 0: expected str instance, list found
However this is just a single substitution. It would be great if it wasn't treated as a list of them.
Full stacktrace:
Additional information
I was able to hack my way around this by adding a ListSubstitution type to launch/substitutions, and modifying evaluate_parameters.py to check for a ListSubstitution.
But I don't really know my way around the launch / launch_ros codebase, so I'm not sure that's a very clean solution.