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

Revision history [back]

click to hide/show revision 1
initial version

I think the robot_param:= is where you are having the issue.

You should be able to do the following directly:

    robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', <path_to_your_xacro_here>])}]
)

With the following imports

import launch
from launch.substitutions import Command, LaunchConfiguration
import launch_ros
import os

edit: I did not understand the full question, the below is not a satisfactory answer

I think the robot_param:= is where you are having the issue.

You should be able to do the following directly:

    robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', <path_to_your_xacro_here>])}]
)

With the following imports

import launch
from launch.substitutions import Command, LaunchConfiguration
import launch_ros
import os

edit 2

This is the full example launch file I was able to use to pass arguments to XACRO

import launch from launch.substitutions import Command, LaunchConfiguration import launch_ros import os

def generate_launch_description(): pkg_share = launch_ros.substitutions.FindPackageShare(package='test_robot').find('test_robot') default_model_path = os.path.join(pkg_share, 'urdf/test_robot.xacro') default_with_gripper = 'False'

robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', LaunchConfiguration('model'), ' with_gripper:=', LaunchConfiguration('spawn_with_gripper')])}]
)
return launch.LaunchDescription([
    launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
                                        description='Absolute path to robot urdf file'),
    launch.actions.DeclareLaunchArgument(name='spawn_with_gripper', default_value=default_with_gripper,
                                description='Spawn xacro with gripper?'),
    robot_state_publisher_node,
])

edit: I did not understand the full question, the below is not a satisfactory answer

I think the robot_param:= is where you are having the issue.

You should be able to do the following directly:

    robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', <path_to_your_xacro_here>])}]
)

With the following imports

import launch
from launch.substitutions import Command, LaunchConfiguration
import launch_ros
import os

edit 2

This is the full example launch file I was able to use to pass arguments to XACRO

import launch
from launch.substitutions import Command, LaunchConfiguration
import launch_ros
import os

os def generate_launch_description(): pkg_share = launch_ros.substitutions.FindPackageShare(package='test_robot').find('test_robot') default_model_path = os.path.join(pkg_share, 'urdf/test_robot.xacro') default_with_gripper = 'False'

'False'

robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', LaunchConfiguration('model'), ' with_gripper:=', LaunchConfiguration('spawn_with_gripper')])}]
)
return launch.LaunchDescription([
    launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
                                        description='Absolute path to robot urdf file'),
    launch.actions.DeclareLaunchArgument(name='spawn_with_gripper', default_value=default_with_gripper,
                                description='Spawn xacro with gripper?'),
    robot_state_publisher_node,
])

edit: I did not understand the full question, the below is not a satisfactory answer

I think the robot_param:= is where you are having the issue.

You should be able to do the following directly:

    robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': Command(['xacro ', <path_to_your_xacro_here>])}]
)

With the following imports

import launch
from launch.substitutions import Command, LaunchConfiguration
import launch_ros
import os