oKermorgant / simple_launch

This package provides a Python class to help writing ROS 2 launch files.
MIT License
74 stars 7 forks source link

Cannot use Substitutions in gz_launch arguments #7

Open SelennLamson opened 2 months ago

SelennLamson commented 2 months ago

Hi,

When using SimpleLauncher.gz_launch, neither world_file or the content of gz_args can be substitutions. It must all be str.

  1. The error message is unclear where it comes from: - TypeError: sequence item 0: expected str instance, SimpleSubstitution found

It actually comes from the line 34 of gazebo.py: full_args = ' '.join(arg for arg in [world_file, gz_args] if arg is not None) (i'm using ROS humble release). But anyways, the rest of the function expects strings, not substitutions.

  1. It makes it difficult to input a world file as launch argument, which is quite common I guess.
oKermorgant commented 2 months ago

Hi,

Indeed the function you mention is not robust to substitutions. While I prepare a fix you can use the opaque function way, this is what i usually do when in need of raw Python types.

SelennLamson commented 2 months ago

Hi,

Yes, that's what I've been doing since I noticed the issue :)

Thanks for your package btw, made my launch files much cleaner!

oKermorgant commented 2 months ago

Solved in https://github.com/oKermorgant/simple_launch/commit/cb36d82506910ab003261b3f65b7939a96f694f5. I also removed the default None value for world_file as it makes no sense to launch Gazebo without a world anyway.

Thanks for the feedback, I almost always use the opaque function idiom now and forgot to test new features against substitutions.