<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[在rviz2中显示多个机器人]]></title><description><![CDATA[<p dir="auto">平台：Ubuntu22.04，ros2:humble<br />
问题：在学习完小鱼的“动手学ros2”建模仿真篇后，我学会了如何运用launch将单个机器人添加Gazebo中和利用rqt添加多个机器人到gazebo。<br />
现在我想利用一个launch将多个机器人模型展示在gazebo中，并且在rviz2中显示多个机器人。目前，在gazebo中可以显示多个机器人，但是rviz2中，只能显示一个机器人模型，且模型来回跳动，如图：<br />
<img src="/forum/assets/uploads/files/1700059908566-15e34ea1-d62a-42b4-88eb-1a9e5e1aab8f-fe7f53048045685e97000b38f9f03f1.png" alt="15e34ea1-d62a-42b4-88eb-1a9e5e1aab8f-fe7f53048045685e97000b38f9f03f1.png" class=" img-fluid img-markdown" /><br />
<img src="/forum/assets/uploads/files/1700059925114-fa2c85af-236c-4cf8-9345-28de1cbe443d-35c61805ca141e1f60d2e1f6a415c1d-resized.png" alt="fa2c85af-236c-4cf8-9345-28de1cbe443d-35c61805ca141e1f60d2e1f6a415c1d.png" class=" img-fluid img-markdown" /><br />
launch文件如下：<br />
import os<br />
from launch import LaunchDescription<br />
from launch.actions import ExecuteProcess<br />
from launch_ros.actions import Node<br />
from launch_ros.substitutions import FindPackageShare</p>
<p dir="auto">def generate_launch_description():<br />
name1 = 'fishbot1'<br />
name2 = 'fishbot2'<br />
package_name = 'fishbot_description'<br />
urdf_name = "fishbot_gazebo.urdf"</p>
<pre><code>ld = LaunchDescription()
pkg_share = FindPackageShare(package=package_name).find(package_name) 
urdf_model_path = os.path.join(pkg_share, f'urdf/{urdf_name}')
gazebo_world_path = os.path.join(pkg_share, 'world/fishbot.world')

# Start Gazebo server
start_gazebo_cmd =  ExecuteProcess(
    cmd=['gazebo', '--verbose','-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so',gazebo_world_path],
    output='screen')

# Launch the robot1
spawn_entity_cmd1 = Node(
    package='gazebo_ros', 
    executable='spawn_entity.py',
    # namespace='robot1',
    arguments=[
        '-entity', name1,  
        '-file', urdf_model_path,
        '-robot_namespace', name1,
        ], 
    output='screen'
)

# Start Robot1 State publisher
start_robot_state_publisher_cmd1 = Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    namespace=name1,
    arguments=[urdf_model_path]
)

# Launch the robot2
spawn_entity_cmd2 = Node(
    package='gazebo_ros', 
    executable='spawn_entity.py',
    # namespace='robot2',
    arguments=[
        '-entity', name2,  
        '-file', urdf_model_path,
        '-robot_namespace', name2,
        '-x', '0.5' 
        ], 
    output='screen'
)

# Start Robot2 State publisher
start_robot_state_publisher_cmd2 = Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    namespace=name2,
    arguments=[urdf_model_path]
)

# Launch RViz
start_rviz_cmd = Node(
    package='rviz2',
    executable='rviz2',
    name='rviz2',
    output='screen',
    # arguments=['-d', default_rviz_config_path]
    
    )


ld.add_action(start_gazebo_cmd)
ld.add_action(spawn_entity_cmd1)
ld.add_action(spawn_entity_cmd2)
ld.add_action(start_robot_state_publisher_cmd1)
ld.add_action(start_robot_state_publisher_cmd2)
ld.add_action(start_rviz_cmd)

return ld
</code></pre>
]]></description><link>https://fishros.org.cn/forum/topic/1896/在rviz2中显示多个机器人</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 04:46:34 GMT</lastBuildDate><atom:link href="https://fishros.org.cn/forum/topic/1896.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Nov 2023 14:53:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Thu, 10 Oct 2024 03:22:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fishros.org.cn/forum/uid/6171">@2660767689</a> 能看一下在哪里添加了命名空间么</p>
]]></description><link>https://fishros.org.cn/forum/post/13210</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/13210</guid><dc:creator><![CDATA[liuyuan]]></dc:creator><pubDate>Thu, 10 Oct 2024 03:22:30 GMT</pubDate></item><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Fri, 26 Jul 2024 08:08:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fishros.org.cn/forum/uid/6171">@2660767689</a> 那如果要运行很多台机器呢，怎么办，一个一个加吗<img src="https://fishros.org.cn/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f915.png?v=4lf04vikhdr" class="not-responsive emoji emoji-android emoji--face_with_head_bandage" style="height:23px;width:auto;vertical-align:middle" title=":face_with_head_bandage:" alt="🤕" /></p>
]]></description><link>https://fishros.org.cn/forum/post/11457</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/11457</guid><dc:creator><![CDATA[1540302317]]></dc:creator><pubDate>Fri, 26 Jul 2024 08:08:20 GMT</pubDate></item><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Fri, 12 Jan 2024 11:47:19 GMT]]></title><description><![CDATA[<p dir="auto">我解决了，我是加了命名空间，而且修改了urdf、xacro模型文件里关节和连杆的名称，比如link1改成robot1_link1。我猜你和我一样，都是从网上下载了不同模型的xacro或者urdf文件，这些文件里都是采用了link1、joint1之类的命名，所以运行rviz2时，系统分不清那个是link1,2,3.。。，存在命名冲突，所以会一闪一闪</p>
]]></description><link>https://fishros.org.cn/forum/post/8478</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/8478</guid><dc:creator><![CDATA[2660767689]]></dc:creator><pubDate>Fri, 12 Jan 2024 11:47:19 GMT</pubDate></item><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Fri, 17 Nov 2023 17:47:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fishros.org.cn/forum/uid/2618">@2918095496</a> ros2 topic list 看一下 和 TF 也看一下</p>
]]></description><link>https://fishros.org.cn/forum/post/8001</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/8001</guid><dc:creator><![CDATA[小鱼]]></dc:creator><pubDate>Fri, 17 Nov 2023 17:47:24 GMT</pubDate></item><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Thu, 16 Nov 2023 07:18:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fishros.org.cn/forum/uid/2">@小鱼</a> 怎么样去添加命名空间，我看他这个好像有用啊，是不是用的不对。</p>
]]></description><link>https://fishros.org.cn/forum/post/7981</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/7981</guid><dc:creator><![CDATA[2918095496]]></dc:creator><pubDate>Thu, 16 Nov 2023 07:18:03 GMT</pubDate></item><item><title><![CDATA[Reply to 在rviz2中显示多个机器人 on Thu, 16 Nov 2023 01:13:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fishros.org.cn/forum/uid/4306">@1654939697</a> 两个机器人没有使用明明空间可能</p>
]]></description><link>https://fishros.org.cn/forum/post/7977</link><guid isPermaLink="true">https://fishros.org.cn/forum/post/7977</guid><dc:creator><![CDATA[小鱼]]></dc:creator><pubDate>Thu, 16 Nov 2023 01:13:40 GMT</pubDate></item></channel></rss>