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

    ignition gazebo中model pose发布问题

    已定时 已固定 已锁定 已移动
    ROS2机器人开发:从入门到实践
    ros2 ignition gazebo
    2
    3
    215
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 3
      386894633
      最后由 386894633 编辑

      版本

      • Ubuntu 22.04
      • ROS2 humble
      • ignition gazebo 6.17

      问题描述:

      • 尝试使用plugin来控制场景的model来构建一个有动态障碍物场景,sdf文件如下:
      <?xml version="1.0" ?>
      <sdf version="1.7">
        <world name="dynamic_world">
      
          <physics name="1ms" type="ignored">
              <max_step_size>0.001</max_step_size>
              <real_time_factor>1.0</real_time_factor>
          </physics>
      
          <!-- 插入天空环境 -->
          <atmosphere type="adiabatic"/>
          <!-- 插入一个光源 -->
          <light name="sun_light" type="directional">
            <cast_shadows>true</cast_shadows>
            <pose>0 0 10 0 0 0</pose>
            <diffuse>1 1 1 1</diffuse>
            <specular>0.1 0.1 0.1 1</specular>
            <direction>-0.5 0.5 -1</direction>
          </light>
          <!-- 插入地面平面 -->
          <model name="ground_plane">
            <static>true</static>
            <link name="link">
              <collision name="collision">
                <geometry>
                  <plane>
                    <normal>0 0 1</normal>
                    <size>100 100</size>
                  </plane>
                </geometry>
              </collision>
              <visual name="visual">
                <geometry>
                  <plane>
                    <normal>0 0 1</normal>
                    <size>100 100</size>
                  </plane>
                </geometry>
                <material>
                  <ambient>0.5 0.5 0.5 1</ambient>
                  <diffuse>0.5 0.5 0.5 1</diffuse>
                </material>
              </visual>
            </link>
          </model>
      <model name="pedestrian_0">
              <static>false</static>
              <link name="link_p0">
                  <pose>-4 7 0 0 0 0</pose>
                  <inertial>
                      <mass>55</mass>
                      <inertia>
                          <ixx>14.86</ixx><ixy>0</ixy><ixz>0</ixz>
                          <iyy>16.23</iyy><iyz>0</iyz>
                          <izz>2.36</izz>
                      </inertia>
                  </inertial>
                  <collision name="box">
                      <pose>0 0 0.9 0 0 0</pose>
                      <geometry>
                          <cylinder>
                              <radius>0.17</radius>
                              <length>1.77</length>
                          </cylinder>
                      </geometry>
                  </collision>
                  <visual name="visual">
                <geometry>
                  <cylinder>
                    <radius>0.17</radius>
                    <length>1.77</length>
                  </cylinder>
                </geometry>
                <material>
                  <ambient>0.8 0.2 0.2 1</ambient>
                  <diffuse>0.8 0.2 0.2 1</diffuse>
                </material>
              </visual>
              </link>
      
              <plugin filename="libignition-gazebo-velocity-control-system.so" name="ignition::gazebo::systems::VelocityControl">
                <initial_linear>0.0 0.0 0.0</initial_linear>
                <initial_angular>0.0 0.0 0.0</initial_angular>
                <topic>/pedestrian_0/cmd_vel</topic>
                <link_name>link_p0</link_name>
              </plugin>
      
              <plugin filename="libignition-gazebo-pose-publisher-system.so" name="ignition::gazebo::systems::PosePublisher">
      <publish_link_pose>true</publish_link_pose>
                  <publish_model_pose>true</publish_model_pose>
              </plugin>
          </model>
        </world>
      </sdf>
      
      • 但是ign topic -e -t /model/pedestrian_0/pose一直只输出model的初始位置,如下:
      ...
      header {
        stamp {
          sec: 20
          nsec: 985000000
        }
        data {
          key: "frame_id"
          value: "pedestrian_0"
        }
        data {
          key: "child_frame_id"
          value: "pedestrian_0::link_p0"
        }
      }
      name: "pedestrian_0::link_p0"
      position {
        x: -4
        y: 7
      }
      orientation {
        w: 1
      }
      
      header {
        stamp {
          sec: 20
          nsec: 986000000
        }
        data {
          key: "frame_id"
          value: "pedestrian_0"
        }
        data {
          key: "child_frame_id"
          value: "pedestrian_0::link_p0"
        }
      }
      name: "pedestrian_0::link_p0"
      position {
        x: -4
        y: 7
      }
      orientation {
        w: 1
      }
      
      header {
        stamp {
          sec: 20
          nsec: 987000000
        }
        data {
          key: "frame_id"
          value: "pedestrian_0"
        }
        data {
          key: "child_frame_id"
          value: "pedestrian_0::link_p0"
        }
      }
      name: "pedestrian_0::link_p0"
      position {
        x: -4
        y: 7
      }
      orientation {
        w: 1
      }
      
      header {
        stamp {
          sec: 20
          nsec: 988000000
        }
        data {
          key: "frame_id"
          value: "pedestrian_0"
        }
        data {
          key: "child_frame_id"
          value: "pedestrian_0::link_p0"
        }
      }
      name: "pedestrian_0::link_p0"
      position {
        x: -4
        y: 7
      }
      orientation {
        w: 1
      }
      ...
      

      这个怎么解决呢,怎么实时输出场景中model的pose呢😧

      1 条回复 最后回复 回复 引用 0
      • 小伊小
        机器人小伊
        最后由 编辑

        在您的描述中,您遇到了一个问题,即使用 Ignition Gazebo 的 Pose Publisher 插件时,模型的姿态(pose)没有实时更新。这通常是因为 Pose Publisher 插件没有正确接收到模型姿态的变化,或者模型本身并没有改变其姿态。以下是一些可能的解决步骤和检查点:

        1. 确保模型动态化:
          您的 sdf 文件中已经设置了 <static>false</static>,这意味着模型应该是可以移动的。确保这一点是正确的。

        2. 检查插件加载:
          确保 libignition-gazebo-velocity-control-system.so 和 ignition-gazebo-pose-publisher-system 插件都已正确加载。您可以在 Gazebo 的日志中查找这些插件的加载信息。

        3. 验证 Velocity Control 插件:
          您的 sdf 文件中使用了 ignition::gazebo::systems::VelocityControl 插件来控制模型的速度。请确保该插件正在接收速度命令,并且这些命令正在影响模型的运动。您可以通过发布速度命令到 /pedestrian_0/cmd_vel 话题来测试这一点。例如,使用以下命令:

          ros2 topic pub /pedestrian_0/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 1.0}, angular: {z: 0.5}}"
          

          这将尝试让模型沿 x 轴移动,并绕 z 轴旋转。

        4. 检查 Pose Publisher 插件配置:
          您的 sdf 文件中 Pose Publisher 插件的配置看起来是正确的。但是,请确保没有其他的 sdf 或系统配置覆盖了这些设置。

        5. 查看 Gazebo 日志:
          检查 Gazebo 的输出日志,看看是否有任何错误或警告信息。这可能会给出为什么 Pose Publisher 没有工作的线索。

        6. 使用 ROS 2 命令行工具:
          使用 ros2 node list 和 ros2 topic list 来确认相关的节点和话题都在运行。使用 ros2 topic echo 来实时查看 /model/pedestrian_0/pose 话题的输出,确保没有数据被阻塞或丢失。

        7. 更新和兼容性:
          确保您的 Ignition Gazebo 和 ROS 2 的版本是兼容的。有时候,软件更新可能引入不兼容的变化。

        8. 重新启动和清理:
          有时候,简单的重新启动 Gazebo 和清理工作空间可以解决一些看似复杂的问题。

        如果以上步骤都不能解决问题,您可能需要更深入地调查 Pose Publisher 插件的实现,或者考虑是否有其他系统或插件影响了模型的姿态更新。


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

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

        3 1 条回复 最后回复 回复 引用 0
        • 3
          386894633 @小伊
          最后由 386894633 编辑

          解决了,自问自答一下,正确的配置示例如下:

           <model name="pedestrian_0" canonical_link="link">
                  <pose relative_to="world">-4 7 0.1 0 0 0</pose>
                  <static>false</static>
          
                  <link name="link" >
                      <pose relative_to="__model__">0 0 0 0 0 0</pose>
                      <inertial>
                          <mass>55</mass>
                          <inertia>
                              <ixx>0.5807</ixx><ixy>0</ixy><ixz>0</ixz>
                              <iyy>0.5807</iyy><iyz>0</iyz>
                              <izz>0.7948</izz>
                          </inertia>
                      </inertial>
                      <collision name="collision">
                        <geometry>
                          <cylinder>
                            <radius>0.17</radius>
                            <length>0.2</length>
                          </cylinder>
                        </geometry>
                      </collision>
                      <visual name="visual">
                        <geometry>
                          <cylinder>
                            <radius>0.17</radius>
                            <length>0.2</length>
                          </cylinder>
                        </geometry>
                        <material>
                          <ambient>0.2 0.2 0.2 1</ambient>
                          <diffuse>0.2 0.2 0.2 1</diffuse>
                        </material>
                      </visual>
                  </link>
          
                  <plugin filename="libignition-gazebo-velocity-control-system.so" name="ignition::gazebo::systems::VelocityControl">
                    <initial_linear>0.0 0.0 0.0</initial_linear>
                    <initial_angular>0.0 0.0 0.0</initial_angular>
                    <topic>/pedestrian_0/cmd_vel</topic>
                    <!-- <link_name>link</link_name> -->
                  </plugin>
          
                  <plugin filename="libignition-gazebo-pose-publisher-system.so" name="ignition::gazebo::systems::PosePublisher">
                      <publish_link_pose>true</publish_link_pose>
                      <publish_nested_model_pose>true</publish_nested_model_pose>
                      <publish_visual_pose>false</publish_visual_pose>
                      <static_publisher>false</static_publisher>
                      <use_pose_vector_msg>true</use_pose_vector_msg>
                  </plugin>
              </model>
          

          需要注意canonical_link属性和link标签下<pose relative_to="__model__">0 0 0 0 0 0</pose>的配置

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