-2

Could anyone please tell me, how to display two robots in one instance of RViz?

This question can be broken into two:

  1. How can I add a robot to RViz (using UI? Using command line? Using config? What if I have 100 robots, or variable number of robots: how to avoid adding different number of robots every time?)
  1. What does RViz expect? In other words, let's say I have robot1 and robot2 (meaning that all corresponding links, joints and so on in URDF have prefix). What topics should they publish to appear in RViz and to not interfere with each other.

Any help is greatly appreciated. Thank you.

Steve Brown
  • 369
  • 1
  • 3
  • 12

2 Answers2

1

I was able to do it by prefixing all frames with robot's names.

Steve Brown
  • 369
  • 1
  • 3
  • 12
0

To spawn and visualize multiple robots of the same type, you can use robot_state_publisher and the tf2_ros to handle the TF frames appropriately. This can be done using different namespaces for each robot.

  • Launch file

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            namespace='robot1',
            output='screen',
            parameters=[{'robot_description': 'file://path_to_urdf/robot.urdf.xacro'}],
        ),
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            namespace='robot2',
            output='screen',
            parameters=[{'robot_description': 'file://path_to_urdf/robot.urdf.xacro'}],
        ),
        Node(
            package='rviz2',
            executable='rviz2',
            name='rviz2'
        ),
    ])

Each instance of the robot is assigned its own namespace (robot1 and robot2), allowing each to have its own separate topics and parameters.