鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    ROS2-humble下使用gazebo仿真多个机器人

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ur5e controller gazebo
    5
    15
    1.7k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 13933998981
      santidad D.A.Y
      最后由 编辑

      问题已解决,如需帮助请与我联系

      F G 2 条回复 最后回复 回复 引用 0
      • F
        FantaTerry @1393399898
        最后由 编辑

        @1393399898 您好,请问解决了命名空间后还需要做什么工作才可以正常运行?我现在是在humble的gazebo试图加载三台turtlebot3,下面是日志:

        lab1@lab1-colorful:~/ros2_ws$ ros2 launch rl_turtlebot_launch multi_turtlebot3.launch.py 
        [INFO] [launch]: All log files can be found below /home/lab1/.ros/log/2024-07-19-09-22-44-801730-lab1-colorful-263368
        [INFO] [launch]: Default logging verbosity is set to INFO
        urdf_file_name : turtlebot3_waffle.urdf
        urdf_file_name : turtlebot3_waffle.urdf
        [INFO] [gzserver-1]: process started with pid [263381]
        [INFO] [gzclient-2]: process started with pid [263383]
        [INFO] [robot_state_publisher-3]: process started with pid [263385]
        [INFO] [spawn_entity.py-4]: process started with pid [263387]
        [INFO] [spawn_entity.py-5]: process started with pid [263389]
        [INFO] [spawn_entity.py-6]: process started with pid [263391]
        [spawn_entity.py-5] [INFO] [1721352166.060579777] [spawn_entity]: Spawn Entity started
        [spawn_entity.py-5] [INFO] [1721352166.060771871] [spawn_entity]: Loading entity XML from file /home/lab1/ros2_ws/install/rl_turtlebot_launch/share/rl_turtlebot_launch/urdf/turtlebot3_waffle.urdf
        [spawn_entity.py-5] [INFO] [1721352166.062016813] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
        [spawn_entity.py-5] [INFO] [1721352166.062347773] [spawn_entity]: Waiting for service /spawn_entity
        [spawn_entity.py-6] [INFO] [1721352166.074252112] [spawn_entity]: Spawn Entity started
        [spawn_entity.py-6] [INFO] [1721352166.074442278] [spawn_entity]: Loading entity XML from file /home/lab1/ros2_ws/install/rl_turtlebot_launch/share/rl_turtlebot_launch/urdf/turtlebot3_waffle.urdf
        [spawn_entity.py-4] [INFO] [1721352166.074493023] [spawn_entity]: Spawn Entity started
        [spawn_entity.py-4] [INFO] [1721352166.074674658] [spawn_entity]: Loading entity XML from file /home/lab1/ros2_ws/install/rl_turtlebot_launch/share/rl_turtlebot_launch/urdf/turtlebot3_waffle.urdf
        [spawn_entity.py-6] [INFO] [1721352166.074846235] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
        [spawn_entity.py-6] [INFO] [1721352166.074978259] [spawn_entity]: Waiting for service /spawn_entity
        [spawn_entity.py-4] [INFO] [1721352166.075055066] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
        [spawn_entity.py-4] [INFO] [1721352166.075188369] [spawn_entity]: Waiting for service /spawn_entity
        [robot_state_publisher-3] [INFO] [1721352166.078197592] [robot_state_publisher]: got segment base_footprint
        [robot_state_publisher-3] [INFO] [1721352166.078255204] [robot_state_publisher]: got segment base_link
        [robot_state_publisher-3] [INFO] [1721352166.078259586] [robot_state_publisher]: got segment base_scan
        [robot_state_publisher-3] [INFO] [1721352166.078261874] [robot_state_publisher]: got segment camera_depth_frame
        [robot_state_publisher-3] [INFO] [1721352166.078264109] [robot_state_publisher]: got segment camera_depth_optical_frame
        [robot_state_publisher-3] [INFO] [1721352166.078266519] [robot_state_publisher]: got segment camera_link
        [robot_state_publisher-3] [INFO] [1721352166.078268708] [robot_state_publisher]: got segment camera_rgb_frame
        [robot_state_publisher-3] [INFO] [1721352166.078270838] [robot_state_publisher]: got segment camera_rgb_optical_frame
        [robot_state_publisher-3] [INFO] [1721352166.078273050] [robot_state_publisher]: got segment caster_back_left_link
        [robot_state_publisher-3] [INFO] [1721352166.078275165] [robot_state_publisher]: got segment caster_back_right_link
        [robot_state_publisher-3] [INFO] [1721352166.078277151] [robot_state_publisher]: got segment imu_link
        [robot_state_publisher-3] [INFO] [1721352166.078279245] [robot_state_publisher]: got segment wheel_left_link
        [robot_state_publisher-3] [INFO] [1721352166.078281434] [robot_state_publisher]: got segment wheel_right_link
        [spawn_entity.py-5] [INFO] [1721352166.569728255] [spawn_entity]: Calling service /spawn_entity
        [spawn_entity.py-6] [INFO] [1721352166.577600512] [spawn_entity]: Calling service /spawn_entity
        [spawn_entity.py-4] [INFO] [1721352166.578143401] [spawn_entity]: Calling service /spawn_entity
        [spawn_entity.py-5] [INFO] [1721352166.615479641] [spawn_entity]: Spawn status: Entity pushed to spawn queue, but spawn service timed outwaiting for entity to appear in simulation under the name [turtlebot3_waffle_2]
        [spawn_entity.py-5] [ERROR] [1721352166.615657547] [spawn_entity]: Spawn service failed. Exiting.
        [spawn_entity.py-6] [INFO] [1721352166.694504006] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [turtlebot3_waffle_3]
        [ERROR] [spawn_entity.py-5]: process has died [pid 263389, exit code 1, cmd '/opt/ros/humble/lib/gazebo_ros/spawn_entity.py -entity turtlebot3_waffle_2 -file /home/lab1/ros2_ws/install/rl_turtlebot_launch/share/rl_turtlebot_launch/urdf/turtlebot3_waffle.urdf -x 0.0 -y 0.0 -z 0.01 --ros-args'].
        [INFO] [spawn_entity.py-6]: process has finished cleanly [pid 263391]
        [spawn_entity.py-4] [INFO] [1721352166.920741484] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [turtlebot3_waffle_1]
        [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 263387]
        

        我在的rqt_graph界面没有显示预先规定的命名空间,所以我觉得我的launch文件可能存在一些问题:

        def generate_launch_description():
            launch_file_dir = os.path.join(get_package_share_directory('rl_turtlebot_launch'), 'launch')
            pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
        
            use_sim_time = LaunchConfiguration('use_sim_time', default='true')
        
            world = os.path.join(
                get_package_share_directory('rl_turtlebot_launch'),
                'worlds',
                'lab.world'
            )
        
            gzserver_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')
                ),
                launch_arguments={'world': world}.items()
            )
        
            gzclient_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py')
                )
            )
        
            robot_state_publisher_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(launch_file_dir, 'robot_state_publisher.launch.py')
                ),
                launch_arguments={'use_sim_time': use_sim_time}.items()
            )
        
            spawn_turtlebot1_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(launch_file_dir, 'spawn_turtlebot3.launch.py')
                ),
                launch_arguments={
                    'x_pose': '-2.0',
                    'y_pose': '-0.5',
                    'robot_name': 'turtlebot3_waffle_1'
                }.items()
            )
        
            spawn_turtlebot2_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(launch_file_dir, 'spawn_turtlebot3.launch.py')
                ),
                launch_arguments={
                    'x_pose': '0.0',
                    'y_pose': '0.0',
                    'robot_name': 'turtlebot3_waffle_2'
                }.items()
            )
        
            spawn_turtlebot3_cmd = IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(launch_file_dir, 'spawn_turtlebot3.launch.py')
                ),
                launch_arguments={
                    'x_pose': '2.0',
                    'y_pose': '0.5',
                    'robot_name': 'turtlebot3_waffle_3'
                }.items()
            )
        
            ld = LaunchDescription()
        
            # Add the commands to the launch description
            ld.add_action(gzserver_cmd)
            ld.add_action(gzclient_cmd)
            ld.add_action(robot_state_publisher_cmd)
            ld.add_action(spawn_turtlebot1_cmd)
            ld.add_action(spawn_turtlebot2_cmd)
            ld.add_action(spawn_turtlebot3_cmd)
        
            return ld```
        13933998981 1 条回复 最后回复 回复 引用 0
        • 13933998981
          santidad D.A.Y @FantaTerry
          最后由 编辑

          @FantaTerry 您好,感谢您的提问

          我和您的构件思路不同,但是我发现您的robot_state_publisher只启动了一次。我的两个机械臂均有各自的robot_state_publisher用于发布机器人状态,也使用命名空间进行区分,我不确定启动一次是否可以无冲突调用,所以我进行了区分,以下是我的部分launch代码:

          left_robot_state_publisher_node = Node(
                  package='robot_state_publisher',
                  executable='robot_state_publisher',
                  namespace='/left_ur_ft',
                  output='both',
                  parameters=[{"use_sim_time": True}, left_robot_description],
              )
          
          right_robot_state_publisher_node = Node(
                  package='robot_state_publisher',
                  executable='robot_state_publisher',
                  namespace='/right_ur_ft',
                  output='both',
                  parameters=[{"use_sim_time": True}, right_robot_description],
              )
          

          希望能够帮到您

          1 条回复 最后回复 回复 引用 0
          • G
            guoshanqi @1393399898
            最后由 编辑

            @1393399898 您好,我最近也在做多机器人,请问您是怎么解决的

            1 条回复 最后回复 回复 引用 0
            • G
              guoshanqi @1393399898
              最后由 编辑

              @1393399898 我也是遇到,第二个机器人的gazebo_ros2_control仍然使用第一个机器人的命名空间,我试过很多办法都没法解决

              13933998981 1 条回复 最后回复 回复 引用 0
              • 13933998981
                santidad D.A.Y @guoshanqi
                最后由 编辑

                @guoshanqi 非常抱歉这么久才回复您

                我使用的方式是在github下载ros2的包重新编译安装,不使用二进制安装,例如:control,controller,control_msgs,control_toolbox,gazebo_ros2_control等一系列包,除此之外,还有ur机械臂的包和realsense相机的包。这些包在几乎每周都在更新版本,而二进制安装的版本还是非常过时。

                我将这些包直接编译安装在系统下(/opt/ros/humble),没有试过放在项目中,不确定放在项目中是否会成功。因此,这就改变了系统原有的依赖,可能会造成其他项目无法正常执行,因此在这之前请慎重考虑,使用二进制重新安装即可回退。我目前没有其他更好的解决方式

                希望能够帮助到您

                W 1 条回复 最后回复 回复 引用 0
                • W
                  wind2918 @1393399898
                  最后由 编辑

                  @1393399898 你好有具体解决教程吗我也是这个问题控制器明明已经区分空间但节点还是会重复

                  13933998981 1 条回复 最后回复 回复 引用 0
                  • 13933998981
                    santidad D.A.Y @wind2918
                    最后由 编辑

                    @wind2918 在项目代码方面没有什么改动,我是重新编译了ros2下的系统功能包,在之前已经介绍过这种方式的利弊,您可也翻阅一下。

                    造成这个问题的主要原因是:二进制安装(apt install)的ros2系统功能包(主要为controller_manager等)重复使用,这一点目前还无法通过修改自己的项目代码解决。但是在github中这部分已经进行了更新,二进制安装中还没有被更新,所以我们需要下载源码然后编译。我为了方便使用,将编译后的文件添加到了系统文件夹下(https://blog.csdn.net/m0_60346726/article/details/132858862)。

                    希望能够帮助到您

                    W 1 条回复 最后回复 回复 引用 0
                    • W
                      wind2918 @1393399898
                      最后由 编辑

                      @1393399898 可以再发一下这个教程吗,这个显示打不开了,万分感谢

                      13933998981 1 条回复 最后回复 回复 引用 0
                      • 13933998981
                        santidad D.A.Y @wind2918
                        最后由 编辑

                        @wind2918 这个不是完整教程,这个只是将编译文件添加到系统文件夹下。完整操作你需要参考我之前发的回答,评估自己需要重新编译的功能包。以及安装时的注意事项

                        https://blog.csdn.net/m0_60346726/article/details/132858862

                        W 1 条回复 最后回复 回复 引用 0
                        • W
                          wind2918 @1393399898
                          最后由 编辑

                          @1393399898 非常感谢你的帮助我现在已经解决了,这个问题困扰我很久

                          1 条回复 最后回复 回复 引用 0
                          • 2 2118561423 在 中 引用了 这个主题
                          • 第一个帖子
                            最后一个帖子
                          皖ICP备16016415号-7
                          Powered by NodeBB | 鱼香ROS