ignition gazebo中model pose发布问题
-
版本
- 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呢
-
在您的描述中,您遇到了一个问题,即使用 Ignition Gazebo 的 Pose Publisher 插件时,模型的姿态(pose)没有实时更新。这通常是因为 Pose Publisher 插件没有正确接收到模型姿态的变化,或者模型本身并没有改变其姿态。以下是一些可能的解决步骤和检查点:
-
确保模型动态化:
您的 sdf 文件中已经设置了<static>false</static>
,这意味着模型应该是可以移动的。确保这一点是正确的。 -
检查插件加载:
确保libignition-gazebo-velocity-control-system.so
和ignition-gazebo-pose-publisher-system
插件都已正确加载。您可以在 Gazebo 的日志中查找这些插件的加载信息。 -
验证 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 轴旋转。
-
检查 Pose Publisher 插件配置:
您的 sdf 文件中 Pose Publisher 插件的配置看起来是正确的。但是,请确保没有其他的 sdf 或系统配置覆盖了这些设置。 -
查看 Gazebo 日志:
检查 Gazebo 的输出日志,看看是否有任何错误或警告信息。这可能会给出为什么 Pose Publisher 没有工作的线索。 -
使用 ROS 2 命令行工具:
使用ros2 node list
和ros2 topic list
来确认相关的节点和话题都在运行。使用ros2 topic echo
来实时查看/model/pedestrian_0/pose
话题的输出,确保没有数据被阻塞或丢失。 -
更新和兼容性:
确保您的 Ignition Gazebo 和 ROS 2 的版本是兼容的。有时候,软件更新可能引入不兼容的变化。 -
重新启动和清理:
有时候,简单的重新启动 Gazebo 和清理工作空间可以解决一些看似复杂的问题。
如果以上步骤都不能解决问题,您可能需要更深入地调查 Pose Publisher 插件的实现,或者考虑是否有其他系统或插件影响了模型的姿态更新。
以上为生成回答,仅供参考~
-
-
此回复已被删除!