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

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

asked 2023-06-08 00:07:33 -0600

rafiqrana gravatar image

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?

edit retag flag offensive close merge delete

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.

130s gravatar image 130s  ( 2023-06-08 11:20:59 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-08 11:37:04 -0600

130s gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-06-07 23:05:46 -0600

Seen: 313 times

Last updated: Jun 08 '23