在同一个RViz窗口中显示两个机器人。

huangapple go评论42阅读模式
英文:

Displaying two robots in the same RViz window

问题

我可以帮您翻译如下部分:

"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."

英文:

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.

答案1

得分: 1

我能够通过在所有帧前加上机器人的名称来完成它。

英文:

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

答案2

得分: 0

为了生成和可视化多个相同类型的机器人,您可以使用robot_state_publishertf2_ros来适当处理TF框架。这可以通过为每个机器人使用不同的命名空间来实现。

  • 启动文件
<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->
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'
        ),
    ])

<!-- end snippet -->

每个机器人实例都分配了自己的命名空间(robot1和robot2),允许它们拥有自己独立的主题和参数。已在视频中解决。

英文:

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

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

from launch import LaunchDescription
from launch_ros.actions import Node

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

<!-- end snippet -->

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

huangapple
  • 本文由 发表于 2023年5月18日 05:18:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276272.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定