Skip to content

Allow concatenating each path component of PathJoinSubstitution#838

Merged
christophebedard merged 1 commit intorollingfrom
christophebedard/path-join-substitution-list-of-somesubstitutionstype
Apr 15, 2025
Merged

Allow concatenating each path component of PathJoinSubstitution#838
christophebedard merged 1 commit intorollingfrom
christophebedard/path-join-substitution-list-of-somesubstitutionstype

Conversation

@christophebedard
Copy link
Copy Markdown
Member

@christophebedard christophebedard commented Mar 16, 2025

Closes #741

As mentioned in the above issue, users want to concatenate multiple substitutions into a single string, which, in this case, is a single path component. This is a very normal use of substitutions, but PathJoinSubstitution does not support it. It only supports joining individual substitutions into a path.

This PR changes PathJoinSubstitution to accept an Iterable[SomeSubstitutionsType] instead of being restricted to Iterable[Union[Text, Substitution]]. This enables the use-case presented in the issue:

PathJoinSubstitution(['robot_description', 'urdf', [LaunchConfiguration('model'), '.xacro']])

If the model launch configuration was set to my_model, this would result in a path equal to:

'robot_description/urdf/my_model.xacro'

As the existing test shows, this is backward compatible, since Iterable[SomeSubstitutionsType] is a superset of Iterable[Union[Text, Substitution]].

I've added an example to the class documentation and expanded the test a bit.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Copy Markdown
Member Author

There's a request to backport this to Humble (and Jazzy while we're at it): #835 (comment)

baconbrot added a commit to baconbrot/launch that referenced this pull request Mar 18, 2025
Signed-off-by: Christian Ruf <c.ruf99@gmail.com>
baconbrot added a commit to baconbrot/launch that referenced this pull request Mar 18, 2025
Signed-off-by: Christian Ruf <c.ruf99@gmail.com>

Support concatenation of substitutions as implemented in ros2#838

Signed-off-by: Christian Ruf <c.ruf99@gmail.com>

Add docstrings

Signed-off-by: Christian Ruf <c.ruf99@gmail.com>

Updatre repr

Signed-off-by: Christian Ruf <c.ruf99@gmail.com>

Fix formatting

Signed-off-by: Christian Ruf <c.ruf99@gmail.com>
@christophebedard
Copy link
Copy Markdown
Member Author

christophebedard commented Apr 14, 2025

Pulls: #838
Branch: christophebedard/path-join-substitution-list-of-somesubstitutionstype
BUILD args: --packages-above-and-dependencies launch
TEST args: --packages-above launch
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15694

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@christophebedard
Copy link
Copy Markdown
Member Author

The test failures are unrelated (ros2param CLI flakes and Connext).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Substitutions for string manipulations and xacro

3 participants