Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remapping lifecycle node from /ldlidar_node/scan to /scan #23

Open
Mubashir-alam opened this issue Jun 22, 2024 · 1 comment
Open

remapping lifecycle node from /ldlidar_node/scan to /scan #23

Mubashir-alam opened this issue Jun 22, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Mubashir-alam
Copy link

Mubashir-alam commented Jun 22, 2024

I am using ldlidar
for cartographer slam ros2 humble. The ldlidar published scan data on topic /ldlidar_node/scan but the cartographer node expects scan data on /scan topic. I remap the topic name from /ldlidar_node/scan to /scan following launch file remap but no data was published on /scan
here is my launch file

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node, LifecycleNode


def generate_launch_description():
    
    node_name = LaunchConfiguration('node_name')

    # Lidar node configuration file
    lidar_config_path = os.path.join(
        get_package_share_directory('ldlidar_node'),
        'params',
        'ldlidar.yaml'
    )

    # Launch arguments
    declare_node_name_cmd = DeclareLaunchArgument(
        'node_name',
        default_value='ldlidar_node',
        description='Name of the node'
    )

    # LDLidar lifecycle node
    ldlidar_node = LifecycleNode(
        package='ldlidar_node',
        executable='ldlidar_node',
        name=node_name,
        namespace='',
        output='screen',
        parameters=[
            # YAML files
            lidar_config_path  # Parameters
        ],
        remappings=[('/ld_scan', '/scan')]
    )

    # URDF path
    urdf_file_name = 'ldlidar_descr.urdf.xml'
    urdf = os.path.join(
        get_package_share_directory('ldlidar_node'),
        'urdf',
        urdf_file_name)
    with open(urdf, 'r') as infp:
        robot_desc = infp.read()

    # Robot State Publisher node
    rsp_node = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='ldlidar_state_publisher',
        output='screen',
        parameters=[{'robot_description': robot_desc}],
        arguments=[urdf]
    )

    # Define LaunchDescription variable
    ld = LaunchDescription()

    # Launch arguments
    ld.add_action(declare_node_name_cmd)

    # Launch Nav2 Lifecycle Manager
    ld.add_action(rsp_node)

    # LDLidar Lifecycle node
    ld.add_action(ldlidar_node)

    return ld
@Mubashir-alam Mubashir-alam added the enhancement New feature or request label Jun 22, 2024
@altineller
Copy link

I have tried 'remappings=[('/ldlidar_node/scan', '/scan')]' which publishes /scan topic but when you ros2 topic echo /scan it does not publish anything.

I understand (from the slam example) that you can remap your cartographer or slam to remap /scan to /ldlidar_node/scan and this kind of works. but considering there are many nodes and software reading /scan for the sake of ergonomics can we not publish at /scan?

I also understand this might not be possible with lifecycle management nodes.

Best Regards,
C.A.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants