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

ros2 concatenate LaunchConfiguration with string for function argument

asked 2022-01-06 21:30:28 -0500

thejeeb gravatar image

updated 2022-01-07 11:26:28 -0500

In a ros2 python launch script, I want to concatenate a LaunchConfiguration with a string and pass it to a function. I can't seem to figure out how to do this.

def load_file(package_name, file)
   # body of function

prefix = LaunchConfiguration("name")

# package_name = prefix + "_pkg"
contents = load_file(package_name, file)

Here package_name needs to be the concatenation of a LaunchConfiguration and a literal string. There must be a way I can do this - no?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-10 16:15:01 -0500

tnajjar gravatar image

As far as I know, the only easy way* to concatenate a LaunchConfiguration with a string is by passing them as a list in any parameter of type "SomeSubstitutionsType" as shown here.

*The harder convoluted way would be by using the OpaqueFunction as described in this answer. It's feels hackier but gives more flexibility

edit flag offensive delete link more

Comments

Since the parameter that needs the concatenation isn't a substitution type, the list method doesn't work. However, the OpaqueFunction approach works and I was able to get it to work. Thanks.

thejeeb gravatar image thejeeb  ( 2022-01-12 22:28:27 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-01-06 21:30:28 -0500

Seen: 295 times

Last updated: Jan 10 '22