0
$\begingroup$

I'm trying to run a LiDar driver from my robot bringup launch file, I ofcourse need to give the launch file arguments: hostname and frame id, when running this from CLI it works fine and when I'm trying to pass the arguments with launch_arguments then it doesn't work.

        IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(lidar_dir, "launch", "sick_nav_350.launch.py")
        ),
        launch_arguments={
            "frame_id" : 'lidar',
            'hostname' : '169.254.239.240',
        }.items()
    ),    

Not sure what goes wrong but I think it has something to do with the implementation of the Lidar launch file where it passes the arguments to another yaml launch file it checks for the usage of := which is only used in CLI

ld = LaunchDescription()
sick_scan_pkg_prefix = get_package_share_directory('sick_scan_xd')
launchfile = os.path.basename(__file__)[:-3] # convert "<lidar_name>.launch.py" to "<lidar_name>.launch"
launch_file_path = os.path.join(sick_scan_pkg_prefix, 'launch/' + launchfile) # 'launch/sick_nav_350.launch')
node_arguments=[launch_file_path]

# append optional commandline arguments in name:=value syntax
for arg in sys.argv:
    if len(arg.split(":=")) == 2:
        node_arguments.append(arg)

ROS_DISTRO = os.environ.get('ROS_DISTRO') # i.e. 'eloquent', 'foxy', etc.
if ROS_DISTRO[0] <= "e": # ROS versions eloquent and earlier require "node_executable", ROS foxy and later use "executable"
    node = Node(
        package='sick_scan_xd',
        node_executable='sick_generic_caller',
        output='screen',
        remappings=[ ('/sick_nav_350/scan', '/scan'), ], # remap laserscan messages to topic /scan, required for slam_toolbox
        arguments=node_arguments
    )

Any quick solution for this?

$\endgroup$

1 Answer 1

1
$\begingroup$

I think the question is similar to this, you have to declare the launch arguments before to pass it to the launch file.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.