Interbotix / interbotix_ros_turrets

ROS Packages for Interbotix Turrets
BSD 3-Clause "New" or "Revised" License
7 stars 10 forks source link

[Question]: Launching 2 xsturret_description.launch.py. Overlapping publishing despite different namespacing but rqt node graph is correct #4

Closed nicholaschan23 closed 6 months ago

nicholaschan23 commented 6 months ago

Question

When launching 2 xsturret_description.launch.py, they both publish to the same joints. Even though I'm namespacing it with the robot_name_launch_arg (pxxls_1 and pxxls_2), both robot_descriptions (robot_state_publisher node) are publishing to the same pxxls_1. Is there something I'm doing wrong?

Here is my launch file. You'll have to run rviz2 and add the robot models manually and change the fixed frame to one of the base_links.

from launch import LaunchDescription
from launch.actions import (
    IncludeLaunchDescription,
    OpaqueFunction,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
    PathJoinSubstitution,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

def launch_setup(context, *args, **kwargs):
    pxxls_1_launch_include = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('interbotix_xsturret_descriptions'),
                'launch',
                'xsturret_description.launch.py'
            ])
        ]),
        launch_arguments={
            'robot_model': 'pxxls',
            'robot_name': 'pxxls_1',
            'use_rviz': 'false',
            'use_joint_pub': 'false',
            'use_joint_pub_gui': 'true',
            'use_world_frame': 'false'
        }.items(),
    )

    pxxls_2_launch_include = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('interbotix_xsturret_descriptions'),
                'launch',
                'xsturret_description.launch.py'
            ])
        ]),
        launch_arguments={
            'robot_model': 'pxxls',
            'robot_name': 'pxxls_2',
            'use_rviz': 'false',
            'use_joint_pub': 'false',
            'use_joint_pub_gui': 'true',
            'use_world_frame': 'false'
        }.items(),
    )

    static_transform_publisher_node = Node(
        package="tf2_ros",
        executable='static_transform_publisher',
        name='static_transform_publisher',
        namespace='',
        arguments=['--x', '0',
                   '--y', '0.6',
                   '--z', '0.1',
                   '--frame-id', f'pxxls_1/base_link',
                   '--child-frame-id', f'pxxls_2/base_link'],
        output='log',
    )

    return [
        pxxls_1_launch_include,
        pxxls_2_launch_include,
        static_transform_publisher_node,
    ]

def generate_launch_description():
    declared_arguments = []
    return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])

Robot Model

pxxls

Operating System

Other (Describe in "Anything Else")

ROS Version

Other (Describe in "Anything Else")

Anything Else

Ubuntu 22.04, Humble

lukeschmitt-tr commented 6 months ago

This is likely because the robot_description LaunchArgument is being declared once and used by both turret description launch files.

We recently added a way to declare multiple robot description launch arguments for the X-Series arms in this PR: https://github.com/Interbotix/interbotix_ros_toolboxes/pull/65. See demo usage in the interbotix_xsarm_dual launch file. You should be able to take what was changed there and apply it to the turrets.

nicholaschan23 commented 6 months ago

May you add the changes you have in https://github.com/Interbotix/interbotix_ros_toolboxes/pull/65 to the DeclareInterbotixXSTurretRobotDescriptionLaunchArgument class too?

lukeschmitt-tr commented 6 months ago

Let me know if the changes in https://github.com/Interbotix/interbotix_ros_toolboxes/pull/66 work for you.

nicholaschan23 commented 6 months ago

Yes it works! Thank you for the amazing help as always :smile:

lukeschmitt-tr commented 6 months ago

The PR has been merged. Feel free to update your local toolboxes repo and close this issue if your question has been answered.