Skip to content

Fix robot_state_publisher model directory path and naming consistency for multi-robot support in vrx_gz/launch.py #892

Description

@xiaolixi

Description
branch: jazzy
When attempting to spawn multiple WAM-V models simultaneously in the VRX Gazebo simulation, the robot_state_publisher node fails to work correctly for the second robot. I've identified that the issue stems from hardcoded paths and naming conventions at line ~372 in vrx_gz/src/vrx_gz/launch.py.

Current Implementation (Line ~372)

# robot_state_publisher (tf for wamv)
model_dir = os.path.join(get_package_share_directory('vrx_gazebo'), 'models/wamv/tmp')
urdf_file = os.path.join(model_dir, 'model.urdf')
with open(urdf_file, 'r') as infp:
    robot_desc = infp.read()
params = {'use_sim_time': use_sim_time, 'frame_prefix': 'wamv/', 'robot_description': robot_desc}
nodes.append(Node(package='robot_state_publisher',
                      executable='robot_state_publisher',
                      output='both',
                      parameters=[params],
                      remappings=[('/joint_states', '/wamv/joint_states')]))

Problems Identified

  1. Hardcoded model path: The path models/wamv/tmp is hardcoded, preventing the use of other robot models or custom model names
  2. Inconsistent naming: frame_prefix and remapping topics are hardcoded to wamv/ instead of using the model.model_name variable

Proposed Fix

# robot_state_publisher (tf for wamv)
model_dir = os.path.join(get_package_share_directory('vrx_gazebo'), 'models/' + model.model_name + '/tmp')
urdf_file = os.path.join(model_dir, 'model.urdf')
with open(urdf_file, 'r') as infp:
    robot_desc = infp.read()
params = {'use_sim_time': use_sim_time, 'frame_prefix': model.model_name + '/', 'robot_description': robot_desc}
nodes.append(Node(package='robot_state_publisher',
                      executable='robot_state_publisher',
                      output='both',
                      parameters=[params],
                      remappings=[('/joint_states', '/' + model.model_name + '/joint_states')]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions