[Python] ros2 control topic remapping inconsistency

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    Issue

    When bringing up my gazebo simulation, the specified topic remaps for my ros2 controllers are not consistently remapping. It seems to be a toss up as to when the topic gets remapped. I'll provide more context as well as solutions I attempted bellow.

    note: this issue only occurs when the dock is spawned alongside the robot, instances where the robot is spawned alone the topics remap correctly.

    Context

    I'm working on a simulation project which uses ros2_control to control a diff drive robot. In addition to this my dock is controlled using forward position controller. I have remapped the velocity command topics to '/cmd_vel' within my urdf for each robot.

    Attempted Solutions

    • Remapping topics within python launch files through the 'remappings' param
    • Monitoring ros2 nodes on shutdown to ensure no remnants of previous runs are left hanging and potentially interfering with subsequent bring up attempts
    • Changing Node launch order to start remapped topics first to subsequent nodes recognize the remapping

    Code

    remapping within robot_1 urdf (diff drive robot)

    <gazebo>
    <plugin filename="ign_ros2_control-system" name="ign_ros2_control::IgnitionROS2ControlPlugin">
    <parameters>$(find test_robot_description)/config/test_robot_diff_drive_controller.yaml</parameters>
    <ros>
    <remapping>/diff_drive_base_controller/odom:=/robot_controller/odometry</remapping>
    <remapping>/diff_drive_base_controller/cmd_vel_unstamped:=/cmd_vel</remapping>
    </ros>
    </plugin>
    </gazebo>


    Remapping within dock

    <gazebo>
    <plugin filename="ign_ros2_control-system" name="ign_ros2_control::IgnitionROS2ControlPlugin">
    <parameters>$(find test_dock_robot_description)/config/dock_forward_controller.yaml</parameters>
    <ros>
    <namespace>dock</namespace>
    <remappings>/robot_description:=/dock/robot_description</remappings>
    <remappings>/joint_states:=/dock/joint_states</remappings>
    <remappings>/position_forward_controller:=/dock/position_forward_controller</remappings>
    </ros>
    </plugin>
    </gazebo>


    portion of bring up responsible for ros2_controls in robot

    joint_state_broadcaster_spawner = Node(
    package='controller_manager',
    executable='spawner',
    arguments=[
    'joint_state_broadcaster',
    '--controller-manager',
    '/controller_manager',
    ],
    condition=UnlessCondition(
    PythonExpression(
    [
    "'",
    LaunchConfiguration('ros2_control'),
    "' == 'None'",
    ]
    )
    ),
    )

    diff_drive_controller_spawner = Node(
    package='controller_manager',
    executable='spawner',
    arguments=[
    'diff_drive_base_controller',
    '--param-file',
    controller_config,
    ],
    condition=UnlessCondition(
    PythonExpression(
    [
    "'",
    LaunchConfiguration('ros2_control'),
    "' == 'None'",
    ]
    )
    ),
    )


    portion of bring up responsible for ros2_controls in dock

    joint_state_broadcaster_spawner = Node(
    package='controller_manager',
    executable='spawner',
    name='dock_spawner_joint_state_broadcaster',
    arguments=[
    'joint_state_broadcaster',
    '-c',
    '/dock/controller_manager',
    '--param-file',
    controller_param_file,
    ],
    condition=UnlessCondition(
    PythonExpression(
    [
    "'",
    LaunchConfiguration('ros2_control'),
    "' == 'None'",
    ]
    )
    ),
    )

    forward_position_controller_spawner = Node(
    package='controller_manager',
    executable='spawner',
    name='dock_spawner_forward_position_controller',
    arguments=[
    'forward_position_controller',
    '-c',
    '/dock/controller_manager',
    '--param-file',
    controller_param_file,
    ],
    condition=UnlessCondition(
    PythonExpression(
    [
    "'",
    LaunchConfiguration('ros2_control'),
    "' == 'None'",
    ]
    )
    ),
    )

    Continue reading...

Compartilhe esta Página