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

    ROS2机器人开发书籍中6.4.4不发布话题的问题

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2 cmdvel
    3
    13
    628
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 小伊小
      机器人小伊
      最后由 编辑

      从您提供的描述和代码来看,您在尝试使用ROS 2和Gazebo来模拟一个机器人,并期望在仿真中看到特定的话题(如/odom),但实际上并没有看到这个话题。这里有几个可能的原因和解决方案:

      1. 检查Gazebo插件的加载

      首先,确保gazebo_control_plugin.xacro中的插件确实被加载到了URDF模型中。从您提供的fishbot.urdf.xacro文件来看,您已经包含了gazebo_control_plugin.xacro,但没有显式调用<xacro:gazebo_control_plugin />宏。虽然您可能通过其他方式(如fishbot_ros2_control.xacro)隐式地包含了它,但最好还是确认一下。

      解决方案:

      • 确保在URDF文件中正确调用了<xacro:gazebo_control_plugin />宏。
      • 检查fishbot_ros2_control.xacro文件,看是否有任何可能影响插件加载的代码。

      2. ROS 2 控制配置

      由于您提到了ros2_control,确保您的控制配置是正确的。ros2_control需要正确的硬件描述(通常通过YAML文件提供)和控制器配置(同样在YAML文件中)。

      解决方案:

      • 检查是否有对应的控制器配置文件(如YAML文件),并确保它们被正确加载。
      • 确保控制器节点正在运行,并且没有报告任何错误。

      3. 重新构建和清理

      有时,旧的构建文件可能会干扰新的构建。尝试清理您的构建目录并重新构建。

      解决方案:

      • 在工作空间目录中运行colcon build --packages-select fishbot_description --symlink-install来仅构建fishbot_description包。
      • 清理构建目录:rm -rf build install log,然后重新构建。

      4. 检查Gazebo和ROS 2的日志

      查看Gazebo和ROS 2的日志文件可能会提供更多关于为什么话题没有发布的线索。

      解决方案:

      • 查看~/.ros/log/目录下的ROS 2日志文件。
      • 查看Gazebo的终端输出或日志文件,看是否有任何错误或警告。

      5. 验证URDF和XACRO文件

      使用check_urdf工具验证URDF文件是否没有错误。

      解决方案:

      • 运行ros2 run robot_state_publisher robot_state_publisher fishbot_description/urdf/fishbot/fishbot.urdf.xacro,并使用check_urdf命令来验证URDF。

      6. 确保Gazebo和ROS 2的兼容性

      确保您使用的Gazebo和ROS 2版本是兼容的。

      解决方案:

      • 查阅ROS 2和Gazebo的官方文档,确认您使用的版本是否相互兼容。

      按照这些步骤检查和调整您的设置,您应该能够更接近问题的根源,并找到解决方案。如果问题仍然存在,您可能需要更详细地检查您的ROS 2控制配置或寻求来自ROS 2社区的帮助。


      以上为生成回答,仅供参考~

      我是小伊,已接入ChatGpt,所有回复,仅供参考~

      1 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @1286588184
        最后由 编辑

        @1286588184 没看到有启动gazebo欸

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        1 条回复 最后回复 回复 引用 0
        • 小鱼小
          小鱼 技术大佬 @1286588184
          最后由 编辑

          @1286588184 在 ROS2机器人开发书籍中6.4.4不发布话题的问题 中说:

          重新构建与启动仿真

          你并没有启动仿真

          新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

          1 1 条回复 最后回复 回复 引用 0
          • 1
            1286588184 @小鱼
            最后由 编辑

            @小鱼

            是启动这个launch文件吗

            an@911:~/ros2bookcode/chapt6$ ros2 launch fishbot_description gazebo_sim.launch.py
            [INFO] [launch]: All log files can be found below /home/an/.ros/log/2024-09-13-16-06-39-026307-911-4420
            [INFO] [launch]: Default logging verbosity is set to INFO
            [INFO] [robot_state_publisher-1]: process started with pid [4422]
            [INFO] [gzserver-2]: process started with pid [4424]
            [INFO] [gzclient-3]: process started with pid [4426]
            [INFO] [spawn_entity.py-4]: process started with pid [4428]
            [robot_state_publisher-1] [INFO] [1726214799.434220248] [robot_state_publisher]: got segment back_caster_link
            [robot_state_publisher-1] [INFO] [1726214799.434303381] [robot_state_publisher]: got segment base_footprint
            [robot_state_publisher-1] [INFO] [1726214799.434308766] [robot_state_publisher]: got segment base_link
            [robot_state_publisher-1] [INFO] [1726214799.434311465] [robot_state_publisher]: got segment camera_link
            [robot_state_publisher-1] [INFO] [1726214799.434314019] [robot_state_publisher]: got segment camera_optical_link
            [robot_state_publisher-1] [INFO] [1726214799.434316513] [robot_state_publisher]: got segment front_caster_link
            [robot_state_publisher-1] [INFO] [1726214799.434318834] [robot_state_publisher]: got segment imu_link
            [robot_state_publisher-1] [INFO] [1726214799.434321177] [robot_state_publisher]: got segment laser_cylinder_link
            [robot_state_publisher-1] [INFO] [1726214799.434323514] [robot_state_publisher]: got segment laser_link
            [robot_state_publisher-1] [INFO] [1726214799.434325751] [robot_state_publisher]: got segment left_wheel_link
            [robot_state_publisher-1] [INFO] [1726214799.434328088] [robot_state_publisher]: got segment right_wheel_link
            [gzclient-3] Gazebo multi-robot simulator, version 11.10.2
            [gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
            [gzclient-3] Released under the Apache 2 License.
            [gzclient-3] http://gazebosim.org
            [gzclient-3] 
            [gzserver-2] Gazebo multi-robot simulator, version 11.10.2
            [gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
            [gzserver-2] Released under the Apache 2 License.
            [gzserver-2] http://gazebosim.org
            [gzserver-2] 
            [spawn_entity.py-4] [INFO] [1726214799.722044380] [spawn_entity]: Spawn Entity started
            [spawn_entity.py-4] [INFO] [1726214799.722312098] [spawn_entity]: Loading entity published on topic /robot_description
            [spawn_entity.py-4] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead.
            [spawn_entity.py-4]   warnings.warn(
            [spawn_entity.py-4] [INFO] [1726214799.723847055] [spawn_entity]: Waiting for entity xml on /robot_description
            [spawn_entity.py-4] [INFO] [1726214799.735158585] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
            [spawn_entity.py-4] [INFO] [1726214799.735467999] [spawn_entity]: Waiting for service /spawn_entity
            [spawn_entity.py-4] [INFO] [1726214800.492925943] [spawn_entity]: Calling service /spawn_entity
            [gzclient-3] [Msg] Waiting for master.
            [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
            [gzclient-3] [Msg] Publicized address: 10.139.109.189
            [gzclient-3] [Err] [InsertModelWidget.cc:403] Missing model.config for model "/home/an/.gazebo/models/.git"
            [gzserver-2] [Msg] Waiting for master.
            [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
            [gzserver-2] [Msg] Publicized address: 10.139.109.189
            [gzserver-2] [Msg] Loading world file [/home/an/ros2bookcode/chapt6/install/fishbot_description/share/fishbot_description/world/custom_room.world]
            [gzserver-2] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
            [gzserver-2] [INFO] [1726214801.132406165] [depth_camera]: Publishing camera info to [/camera_sensor/camera_info]
            [gzserver-2] [INFO] [1726214801.132921282] [depth_camera]: Publishing depth camera info to [/camera_sensor/depth/camera_info]
            [gzserver-2] [INFO] [1726214801.133263243] [depth_camera]: Publishing pointcloud to [/camera_sensor/points]
            [spawn_entity.py-4] [INFO] [1726214801.196537173] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [fishbot]
            [gzserver-2] [Err] [Plugin.hh:212] Failed to load plugin libgazebo_ros2_control.so: libgazebo_ros2_control.so: cannot open shared object file: No such file or directory
            [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 4428]
            [INFO] [ros2-5]: process started with pid [4632]
            [ros2-5] usage: ros2 [-h] [--use-python-default-buffering]
            [ros2-5]             Call `ros2 <command> -h` for more detailed usage. ...
            [ros2-5] ros2: error: argument Call `ros2 <command> -h` for more detailed usage.: invalid choice: 'control' (choose from 'action', 'bag', 'component', 'daemon', 'doctor', 'extension_points', 'extensions', 'interface', 'launch', 'lifecycle', 'multicast', 'node', 'param', 'pkg', 'run', 'security', 'service', 'topic', 'wtf')
            [ERROR] [ros2-5]: process has died [pid 4632, exit code 2, cmd 'ros2 control load_controller --set-state active fishbot_joint_state_broadcaster'].
            [INFO] [ros2-6]: process started with pid [4634]
            [ros2-6] usage: ros2 [-h] [--use-python-default-buffering]
            [ros2-6]             Call `ros2 <command> -h` for more detailed usage. ...
            [ros2-6] ros2: error: argument Call `ros2 <command> -h` for more detailed usage.: invalid choice: 'control' (choose from 'action', 'bag', 'component', 'daemon', 'doctor', 'extension_points', 'extensions', 'interface', 'launch', 'lifecycle', 'multicast', 'node', 'param', 'pkg', 'run', 'security', 'service', 'topic', 'wtf')
            [ERROR] [ros2-6]: process has died [pid 4634, exit code 2, cmd 'ros2 control load_controller --set-state active fishbot_diff_drive_controller'].
            [gzserver-2] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/pose/local/info, deleting message. This warning is printed only once.
            
            

            da35a272-7252-4049-bf28-981b79f90aa2-图片.png

            现在是这样的

            an@911:~$ ros2 topic list
            /camera_sensor/camera_info
            /camera_sensor/depth/camera_info
            /camera_sensor/depth/image_raw
            /camera_sensor/image_raw
            /camera_sensor/points
            /clicked_point
            /clock
            /goal_pose
            /imu
            /initialpose
            /joint_states
            /parameter_events
            /performance_metrics
            /robot_description
            /rosout
            /scan
            /tf
            /tf_static
            
            
            小鱼小 2 条回复 最后回复 回复 引用 0
            • 小鱼小
              小鱼 技术大佬 @1286588184
              最后由 编辑

              @1286588184 你是跳着看的书吗,前面的装依赖之类的是不是没看和操作

              新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

              1 条回复 最后回复 回复 引用 0
              • 1
                1286588184
                最后由 编辑

                我又试了一下,把这里的注释取消掉就正常出现cmd和odem话题了

                <!-- Gazebo 插件 -->
                    <xacro:include filename="$(find fishbot_description)/urdf/fishbot/plugins/gazebo_control_plugin.xacro" />
                    <!-- <xacro:gazebo_control_plugin /> -->
                
                an@911:~$ ros2 topic list
                /camera_sensor/camera_info
                /camera_sensor/depth/camera_info
                /camera_sensor/depth/image_raw
                /camera_sensor/image_raw
                /camera_sensor/points
                /clock
                /cmd_vel
                /imu
                /joint_states
                /odom
                /parameter_events
                /performance_metrics
                /robot_description
                /rosout
                /scan
                /tf
                /tf_static
                
                

                不太明白这里为什么被注释了
                这个代码我是直接下载的,一开始就是带注释的

                小鱼小 1 条回复 最后回复 回复 引用 0
                • 小鱼小
                  小鱼 技术大佬 @1286588184
                  最后由 编辑

                  @1286588184 在 ROS2机器人开发书籍中6.4.4不发布话题的问题 中说:

                  [Err] [Plugin.hh:212] Failed to load plugin libgazebo_ros2_control.so: libgazebo_ros2_control.so: cannot open shared object file: No such file or directory

                  这里的报错很明显了,没有安装依赖

                  新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                  1 1 条回复 最后回复 回复 引用 0
                  • 小鱼小
                    小鱼 技术大佬 @1286588184
                    最后由 编辑

                    @1286588184 建议跟着书操作,了解下代码为什么这么写和注释

                    新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                    1 条回复 最后回复 回复 引用 0
                    • 1
                      1286588184 @小鱼
                      最后由 编辑

                      @小鱼 我发现了这个,但书里没找到关于这个依赖的安装信息,只在6.4.2中提到安装gazebo依赖

                      n@911:~$ sudo apt install ros-humble-gazebo-ros-pkgs
                      正在读取软件包列表... 完成
                      正在分析软件包的依赖关系树... 完成
                      正在读取状态信息... 完成                 
                      ros-humble-gazebo-ros-pkgs 已经是最新版 (3.7.0-1jammy.20240820.174040)。
                      下列软件包是自动安装的并且现在不需要了:
                        libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib
                        python-pkg-resources python-setuptools python2 python2-minimal python2.7
                        python2.7-minimal
                      使用'sudo apt autoremove'来卸载它(它们)。
                      升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 103 个软件包未被升级。
                      
                      

                      我安装了这个,上面报错显示的那个包我在文件夹里找到了,但就是不起作用,有什么办法吗,或者说书里具体哪里有讲这个

                      我是从第六章开始学的,之前一直跟着视频课的动手学ros2,正好学到机器人gazebo仿真出问题了,然后就从这本书的第六章开始学的

                      小鱼小 2 条回复 最后回复 回复 引用 0
                      • 小鱼小
                        小鱼 技术大佬 @1286588184
                        最后由 编辑

                        @1286588184 不是这个,书中应该还提到了ros2_control依赖

                        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                        1 条回复 最后回复 回复 引用 0
                        • 小鱼小
                          小鱼 技术大佬 @1286588184
                          最后由 编辑

                          @1286588184 代码对应的是这章结束的代码,不是刚好6.4的,你运行的代码出现了第六章最后面才出现的内容

                          新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                          1 1 条回复 最后回复 回复 引用 0
                          • 1
                            1286588184 @小鱼
                            最后由 编辑

                            @小鱼 好的 感谢小鱼老师 我找到了 这章的代码我打算重新去理解编写 一步一步按书上来

                            1 条回复 最后回复 回复 引用 0
                            • 第一个帖子
                              最后一个帖子
                            皖ICP备16016415号-7
                            Powered by NodeBB | 鱼香ROS