【问题标题】:Subscribe to a child-link of the sdf model in Gazebo-simulated world订阅 Gazebo 模拟世界中 sdf 模型的子链接
【发布时间】:2018-06-22 17:24:02
【问题描述】:

我有在 Gazebo 中模拟的 Baxter 机器人(Baxter SDK urdf)和一个操纵杆模型(简单的 sdk 文件)。需要记录的是摇杆俯仰和滚动的位置,显示在 Gazebo 中。

(我无法在 Gazebo 中记录世界的日志,因为 Baxter SDK 使用 Gazebo 版本 2,此功能在那里无法正常工作)。

摇杆的sdf是这样的:

<?xml version="1.0" ?>
<sdf version='1.4'>
  <model name='joystick'>
    <link name='joystick_base'>
      <pose>0 0 0 0 -0 0</pose>
      <inertial>
        <pose>0 0 0.75 0 -0 0</pose>
        <mass>0.01</mass>
        <inertia>
          <ixx>0.0001</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>0.0001</iyy>
          <iyz>0</iyz>
          <izz>0.0001</izz>
        </inertia>
      </inertial>
      <collision name='joystick_base_collision'>
        <pose>0 -0 0.77 0 -0 0</pose>
        <geometry>
          <box>
            <size>0.07 0.07 0.04</size>
          </box>
        </geometry>
      </collision>
      <visual name='joystick_base_visual'>
        <pose>0 -0 0.775 0 -0 0</pose>
        <geometry>
          <box>
            <size>0.07 0.07 0.05</size>
          </box>
        </geometry>
      </visual>
      <velocity_decay>
        <linear>0</linear>
        <angular>0</angular>
      </velocity_decay>
    </link>
    <link name='link_roll'>
      <pose>0 0 0.05 0 -0 0</pose>
      <inertial>
        <pose>0 -0 0.75 0 -0 0</pose>
        <mass>0.01</mass>
        <inertia>
          <ixx>0.0002</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>0.0002</iyy>
          <iyz>0</iyz>
          <izz>0.0002</izz>
        </inertia>
      </inertial>
      <velocity_decay>
        <linear>0</linear>
        <angular>0</angular>
      </velocity_decay>
    </link>
    <joint name='joint_roll' type='revolute'>
      <child>link_roll</child>
      <parent>joystick_base</parent>
      <axis>
        <xyz>0 1 0</xyz>
        <limit>
          <lower>-1.2</lower>
          <upper>1.2</upper>
          <effort>15</effort>
          <velocity>4</velocity>
        </limit>
        <dynamics>
          <damping>0.7</damping>
        </dynamics>
      </axis>
    </joint>
    <link name='joystick'>
      <pose>0 0 0.05 0 -0 0</pose>
      <inertial>
        <pose>0 -0 0.75 0 -0 0</pose>
        <mass>0.01</mass>
        <inertia>
          <ixx>0.0002</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>0.0002</iyy>
          <iyz>0</iyz>
          <izz>0.0002</izz>
        </inertia>
      </inertial>
      <collision name='joystick_collision'>
        <pose>0 -0 0.835 0 -0 0</pose>
        <geometry>
          <cylinder>
            <length>0.17</length>
            <radius>0.01</radius>
          </cylinder>
        </geometry>
      </collision>
      <visual name='joystick_visual'>
        <pose>0 -0 0.835 0 -0 0</pose>
        <geometry>
          <cylinder>
            <length>0.17</length>
            <radius>0.01</radius>
          </cylinder>
        </geometry>
      </visual>
      <velocity_decay>
        <linear>0</linear>
        <angular>0</angular>
      </velocity_decay>
    </link>
    <joint name='joint_pitch' type='revolute'>
      <child>joystick</child>
      <parent>link_roll</parent>
      <axis>
        <xyz>1 0 0</xyz>
        <limit>
          <lower>-1.2</lower>
          <upper>1.2</upper>
          <effort>15</effort>
          <velocity>4</velocity>
        </limit>
        <dynamics>
          <damping>0.7</damping>
        </dynamics>
      </axis>
    </joint>
  </model>
</sdf>

我想订阅 'joint_pitch''joint_roll' 以接收它们的值,例如类似:

from geometry_msgs.msg import Pose, PoseStamped
model_coordinates = rospy.ServiceProxy('/gazebo/get_model_state', GetModelState)
resp_coordinates = model_coordinates('joystick', 'joint_roll')
print(str(resp_coordinates.axis.position.x))

有什么想法可以让它真正起作用吗?

【问题讨论】:

  • 你想听链接还是联合状态?你的标题说的是链接,但你的问题需要关节。

标签: python publish-subscribe ros


【解决方案1】:

如果您想知道当前的关节属性(位置和速率),您可以请求 Gazebo 服务/gazebo/get_joint_properties。 你只需要按照here的解释写一个python服务客户端,或者你也可以先尝试通过rqt_service_caller获取信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-10
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    相关资源
    最近更新 更多