首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >URDF文件中的多个Realsense摄像机

URDF文件中的多个Realsense摄像机
EN

Stack Overflow用户
提问于 2019-02-26 14:31:02
回答 2查看 1.2K关注 0票数 0

我只和ROS合作了几个星期,如果我误解了一些事情,很抱歉。我制作了一个带有机器人的URDF文件。现在我想增加两个真实感D435相机到它上,这样我就可以在里维兹看到它了。根据英特尔给出的测试文件,我在模型中显示了一台相机,但是,当我试图创建第二台相机时,它就是没有出现。

问题:,我怎么能在我的机器人上安装两个真实感摄像头?

这是我的URDF文件:

代码语言:javascript
复制
<?xml version="1.0" ?>

<robot name="mrm" xmlns:xacro="http://www.ros.org/wiki/xacro">
  
  <!-- BGN - Include -->
  <xacro:include filename="$(find mrm_description)/urdf/robot_parameters.xacro" />
  <xacro:include filename="$(find mrm_description)/urdf/links_joints.xacro" />
  <xacro:include filename="$(find realsense2_camera)/urdf/_r435.urdf.xacro"/>
<xacro:include filename="$(find realsense2_camera)/urdf/_r430.urdf.xacro"/>


<m_link_box name="${link_00_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 0"
              mass="1024"
              ixx="170.667" ixy="0" ixz="0"
              iyy="170.667" iyz="0"
              izz="170.667"
              size="1 1 1" />
              
  <m_joint name="${link_00_name}__${link_01_name}" type="revolute"
           axis_xyz="0 0 1"
           origin_rpy="0 0 0" origin_xyz="0 0 0.5"
           parent="base_link" child="link_01"
           limit_e="1000" limit_l="-3.14" limit_u="3.14" limit_v="0.5" />
           
  <m_link_mesh name="${link_01_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 -0.1"
              mass="157.633"
              ixx="13.235" ixy="0" ixz="0"
              iyy="13.235" iyz="0"
              izz="9.655"
              meshfile="package://mrm_description/meshes/Link1-v2.stl"
              meshscale="0.001 0.001 0.001" />
  
  
              
  <m_joint name="${link_01_name}__${link_02_name}" type="revolute"
           axis_xyz="0 1 0"
           origin_rpy="0 0 0" origin_xyz="0 0 0.4"
           parent="link_01" child="link_02"
           limit_e="1000" limit_l="0" limit_u="0.5" limit_v="0.5" />
           
  <m_link_cylinder name="${link_02_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 0.4"
              mass="57.906"
              ixx="12.679" ixy="0" ixz="0"
              iyy="12.679" iyz="0"
              izz="0.651"
              radius="0.15" length="0.8" />
              
  <m_joint name="${link_02_name}__${link_03_name}" type="revolute"
           axis_xyz="0 1 0"
           origin_rpy="0 0 0" origin_xyz="0 0 0.8"
           parent="link_02" child="link_03"
           limit_e="1000" limit_l="0" limit_u="0.75" limit_v="0.5" />
           
  <m_link_cylinder name="${link_03_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 0.4"
              mass="57.906"
              ixx="12.679" ixy="0" ixz="0"
              iyy="12.679" iyz="0"
              izz="0.651"
              radius="0.15" length="0.8" />
              
  <m_joint name="${link_03_name}__${link_04_name}" type="revolute"
           axis_xyz="0 1 0"
           origin_rpy="0 0 0" origin_xyz="0 0 0.8"
           parent="link_03" child="link_04"
           limit_e="1000" limit_l="0" limit_u="0.75" limit_v="0.5" />
           
  <m_link_cylinder name="${link_04_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 0.4"
              mass="57.906"
              ixx="12.679" ixy="0" ixz="0"
              iyy="12.679" iyz="0"
              izz="0.651"
              radius="0.15" length="0.8" />
              
  <m_joint name="${link_04_name}__${link_05_name}" type="revolute"
           axis_xyz="0 0 1"
           origin_rpy="0 0 0" origin_xyz="0 0 0.8"
           parent="link_04" child="link_05"
           limit_e="1000" limit_l="-3.14" limit_u="3.14" limit_v="0.5" />
           
  <m_link_cylinder name="${link_05_name}"
              origin_rpy="0 0 0" origin_xyz="0 0 0.125"
              mass="18.056"
              ixx="0.479" ixy="0" ixz="0"
              iyy="0.479" iyz="0"
              izz="0.204"
              radius="0.15" length="0.25" />

  <sensor_r435 name="Camera 1" parent="${link_05_name}">
        <origin xyz="0 0 0" rpy="1 0 0"/>
  </sensor_r435>  

  
<sensor_r435 name="Camera 2" parent="${link_05_name}">
    <origin xyz="0.17 0 0" rpy="0 0 0"/>
  </sensor_r435>
  
  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    </plugin>
  </gazebo>
  
</robot> 
EN

回答 2

Stack Overflow用户

发布于 2019-03-03 15:19:51

看起来realsense xacro没有您要提供的"name“参数,所以它似乎什么也不做。理想情况下,你可以修改英特尔xacro线-

<xacro:macro name="sensor_d415" params="parent *origin">

<xacro:macro name="sensor_d415" params="sensor_name parent *origin">

然后将${sensor_name}添加到intel xacro中的每个链接和框架名中。因此,当您用不同的sensor_name在URDF中包含这个xacro时,每次都会重新创建完整的描述。

如果你得到这个干净的工作,请提交一个拉请求到英特尔github页面。

票数 0
EN

Stack Overflow用户

发布于 2019-03-05 14:02:39

同时,在等待响应时,我创建了第二个文件,并在每个变量的末尾添加了2个,这是可行的。当然,我知道这不是一个永久的解决方案,我应该把它保存在一个文件中。多亏了Vik我有了解决办法。我将第二个文件中的所有变量替换为${sensor_name}。由于某种原因,相机不再出现在里维兹。我没有收到任何错误信息,但它们只是消失了。人们能看到我的代码有什么问题吗?

代码语言:javascript
复制
   <?xml version="1.0"?>

<!--
License: Apache 2.0. See LICENSE file in root directory.
Copyright(c) 2017 Intel Corporation. All Rights Reserved

This is the URDF model for the Intel RealSense 430 camera, in it's
aluminum peripherial evaluation case.
-->

<robot name="sensor_d4352" xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:macro name="sensor_d415" params="sensor_name parent *origin">
    <xacro:property name="M_PI" value="3.1415926535897931" />

    <!-- The following values are approximate, and the camera node
     publishing TF values with actual calibrated camera extrinsic values -->
    <xacro:property name="d435_cam_depth_to_left_ir_offset" value="0.0"/>
    <xacro:property name="d435_cam_depth_to_right_ir_offset" value="-0.050"/>
    <xacro:property name="d435_cam_depth_to_color_offset" value="0.015"/>

    <!-- The following values model the aluminum peripherial case for the
    D435 camera, with the camera joint represented by the actual 
    peripherial camera tripod mount -->
    <xacro:property name="d435_cam_width" value="0.090"/>
    <xacro:property name="d435_cam_height" value="0.025"/>
    <xacro:property name="d435_cam_depth" value="0.02505"/>
    <xacro:property name="d435_cam_mount_from_center_offset" value="0.0149"/>

    <!-- The following offset is relative the the physical D435 camera peripherial
    camera tripod mount -->
    <xacro:property name="d435_cam_depth_px" value="${d435_cam_mount_from_center_offset}"/>
    <xacro:property name="d435_cam_depth_py" value="0.0175"/>
    <xacro:property name="d435_cam_depth_pz" value="${d435_cam_height/2}"/>

    <material name="aluminum${sensor_name}">
      <color rgba="0.5 0.5 0.5 1"/>
    </material>


    <!-- camera body, with origin at bottom screw mount -->
    <joint name="camera_joint${sensor_name}" type="fixed">
      <xacro:insert_block name="origin" />
      <parent link="${parent}"/>
      <child link="camera_bottom_screw_frame${sensor_name}" />
    </joint>
    <link name="camera_bottom_screw_frame${sensor_name}"/>

    <joint name="camera_link_joint${sensor_name}" type="fixed">
      <origin xyz="0 ${d435_cam_depth_py} ${d435_cam_depth_pz}" rpy="0 0 0"/>
      <parent link="camera_bottom_screw_frame${sensor_name}"/>
      <child link="camera_link${sensor_name}" />
    </joint>

    <link name="camera_link${sensor_name}">
      <visual>
      <origin xyz="${d435_cam_mount_from_center_offset} ${-d435_cam_depth_py} 0" rpy="${M_PI/2} 0 ${M_PI/2}"/>
        <geometry>
          <!-- <box size="${d435_cam_width} ${d435_cam_height} ${d435_cam_depth}"/> -->
      <mesh filename="package://realsense2_camera/meshes/d435.dae" />
          <!--<mesh filename="package://realsense2_camera/meshes/d435/d435.dae" />-->

        </geometry>
        <material name="aluminum"/>
      </visual>
      <collision>
        <origin xyz="0 ${-d435_cam_depth_py} 0" rpy="0 0 0"/>
        <geometry>
        <box size="${d435_cam_depth} ${d435_cam_width} ${d435_cam_height}"/>
        </geometry>
      </collision>
      <inertial>
        <!-- The following are not reliable values, and should not be used for modeling -->
        <mass value="0.564" />
        <origin xyz="0 0 0" />
        <inertia ixx="0.003881243" ixy="0.0" ixz="0.0" iyy="0.000498940" iyz="0.0" izz="0.003879257" />
      </inertial>
    </link>


<!-- camera depth joints and links -->
<joint name="camera_depth_joint${sensor_name}" type="fixed">
  <origin xyz="0 0 0" rpy="0 0 0"/>
  <parent link="camera_link${sensor_name}"/>
  <child link="camera_depth_frame${sensor_name}" />
</joint>
<link name="camera_depth_frame${sensor_name}"/>

<joint name="camera_depth_optical_joint${sensor_name}" type="fixed">
  <origin xyz="0 0 0" rpy="${-M_PI/2} 0 ${-M_PI/2}" />
  <parent link="camera_depth_frame${sensor_name}" />
  <child link="camera_depth_optical_frame${sensor_name}" />
</joint>
<link name="camera_depth_optical_frame${sensor_name}"/>

<!-- camera left IR joints and links -->
<joint name="camera_left_ir_joint${sensor_name}" type="fixed">
  <origin xyz="0 ${d435_cam_depth_to_left_ir_offset} 0" rpy="0 0 0" />
  <parent link="camera_depth_frame${sensor_name}" />
  <child link="camera_left_ir_frame${sensor_name}" />
</joint>
<link name="camera_left_ir_frame${sensor_name}"/>

<joint name="camera_left_ir_optical_joint${sensor_name}" type="fixed">
  <origin xyz="0 0 0" rpy="${-M_PI/2} 0 ${-M_PI/2}" />
  <parent link="camera_left_ir_frame${sensor_name}" />
  <child link="camera_left_ir_optical_frame${sensor_name}" />
</joint>
<link name="camera_left_ir_optical_frame${sensor_name}"/>

<!-- camera right IR joints and links -->
<joint name="camera_right_ir_joint${sensor_name}" type="fixed">
  <origin xyz="0 ${d435_cam_depth_to_right_ir_offset} 0" rpy="0 0 0" />
  <parent link="camera_depth_frame${sensor_name}" />
  <child link="camera_right_ir_frame${sensor_name}" />
</joint>
<link name="camera_right_ir_frame${sensor_name}"/>

<joint name="camera_right_ir_optical_joint${sensor_name}" type="fixed">
  <origin xyz="0 0 0" rpy="${-M_PI/2} 0 ${-M_PI/2}" />
  <parent link="camera_right_ir_frame${sensor_name}" />
  <child link="camera_right_ir_optical_frame${sensor_name}" />
</joint>
<link name="camera_right_ir_optical_frame${sensor_name}"/>

<!-- camera color joints and links -->
<joint name="camera_color_joint${sensor_name}" type="fixed">
  <origin xyz="0 ${d435_cam_depth_to_color_offset} 0" rpy="0 0 0" />
  <parent link="camera_depth_frame" />
  <child link="camera_color_frame${sensor_name}" />
</joint>
<link name="camera_color_frame${sensor_name}"/>

<joint name="camera_color_optical_joint${sensor_name}" type="fixed">
  <origin xyz="0 0 0" rpy="${-M_PI/2} 0 ${-M_PI/2}" />
  <parent link="camera_color_frame${sensor_name}" />
  <child link="camera_color_optical_frame${sensor_name}" />
</joint>
<link name="camera_color_optical_frame"/>
</xacro:macro>
</robot>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54887810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档