简体   繁体   English

URDF文件中的多个Realsense摄像机

[英]Multiple Realsense Cameras in URDF File

I have been working with ROS for only a couple weeks, sorry if i misunderstand things. 我已经与ROS合作仅几个星期了,如果我误解了,抱歉。 I have made a URDF file with a robot in it. 我已经制作了带有机器人的URDF文件。 Now I wanted to add two Real-sense D435 cameras onto it so I can see it in Rviz. 现在,我想在上面添加两个Real-sense D435摄像机,以便可以在Rviz中看到它。 Following the test file given by Intel I got one camera to show up in the model however, when I try to create a second camera it just doesn't show up. 按照英特尔给出的测试文件,我在模型中显示了一个摄像头,但是,当我尝试创建第二个摄像头时,它却没有显示。

Question: How can I get two Real-sense cameras on my robot? 问:如何在机器人上安装两个实感摄像头?

This is my URDF file: 这是我的URDF文件:

<?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> 

Looks like the realsense xacro doesn't have a "name" parameter which you are supplying, so it doesn't seem to do anything. 看起来realsense xacro没有提供的“ name”参数,因此它似乎没有任何作用。 Ideally, you can modify the intel xacro line - 理想情况下,您可以修改intel xacro行-
<xacro:macro name="sensor_d415" params="parent *origin">
to
<xacro:macro name="sensor_d415" params="sensor_name parent *origin">
then add ${sensor_name} to every link and frame name in the intel xacro. 然后将${sensor_name}添加到intel xacro中的每个链接和框架名称。 Thus when you include this xacro in your URDF with different sensor_name, you recreate the full description each time. 因此,当您使用不同的sensor_name将此xacro包含在URDF中时,每次都会重新创建完整描述。

If you get this working cleanly, please do submit a pull request to the intel github page. 如果您可以正常工作,请向intel github页面提交拉取请求。

In the meantime while waiting for a response I made a second file and added 2 to the end of each variable and that worked. 同时,在等待响应的同时,我制作了第二个文件,并在每个变量的末尾添加了2,这样就可以了。 Of course I knew this was not a permanent solution and that I should just keep it to one file. 当然,我知道这不是一个永久性的解决方案,我应该将其保存在一个文件中。 Thanks to Vik I have a solution. 感谢Vik,我有一个解决方案。 I took all the variables from my second file and replaced them with ${sensor_name}. 我从第二个文件中取出所有变量,并用$ {sensor_name}替换了它们。 For some reason the camera doesn't show up in rviz anymore. 由于某些原因,相机不再显示在rviz中。 I'm not given any error messages but they just disappeared. 我没有收到任何错误消息,但它们只是消失了。 Are there any issues with my code that people can see? 人们可以看到我的代码中有任何问题吗?

   <?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM