Robotics StackExchange | Archived questions

How to concatinate LaunchConfiguration's default value with String in ros-humble python launch file?

Hi guys, I need to concatinate default value of LaunchArgument with string, not sure how to achieve that. I have the following scenario in the ros2-humble python launch file:

declare_namespace = DeclareLaunchArgument(
    name="namespace",
    default_value="robot_1",
)

and I want to do the the following operation in the Node parameters:

 {"frame_prefix": LaunchConfiguration("namespace") + "/"}

detailed Node:

robot_state_publisher_node = Node(
    package="robot_state_publisher",
    executable="robot_state_publisher",
    output='screen',
    namespace=LaunchConfiguration('namespace'),
    parameters=[
        {"robot_description": Command(["xacro ", LaunchConfiguration("xacro_file")])},
        {"publish_frequency": 60.0},
        {"use_tf_static": False},
        {"ignore_timestamp": True},
        {'use_sim_time': LaunchConfiguration("use_sim_time")},
        # {"frame_prefix": LaunchConfiguration("namespace"). + "/"}
    ], )

Is there anything to do with perform member function of LaunchConfiguration?

Asked by rafiqrana on 2023-06-07 23:05:46 UTC

Comments

Do you mind updating your post to add what you tried and the (error) message the system returned? That allows Google to search. Many people look for info by the error message.

Asked by 130s on 2023-06-08 11:20:59 UTC

Answers

Looks like nav2 project has come up with a way using nav2_common.launch.ReplaceString. See detail robotics.stackexchange.com#24470/60.

I guess modifying arg in a .launch.py is a common desire so started discussion navigation2#3610 to potentially escalate some functionalities to broader audience.

Asked by 130s on 2023-06-08 11:37:04 UTC

Comments