KELLRT 2024-04-03 16:33 采纳率: 0%
浏览 2
已结题

关于#ubuntu#的问题:对模型用check_urdf后缀为.urdf时显示的错误如图

img


对模型用check_urdf后缀为.urdf时显示的错误如图

而后缀为.urdf.xacro时显示的错误如下

img


下面是模型文件代码

<?xml version="1.0"?>
<robot name="racecar" xmlns:xacro="http://www.ros.org/wiki/xacro">
 

<!--macro-->
  <xacro:macro name="null_inertial">
    <inertial>
      <mass value="0.001"/>
      <inertia ixx="0.001" ixy="0" ixz="0" iyy="0.001" iyz="0" izz="0.001"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="solid_cuboid_inertial"
               params="width depth height mass *origin">
    <inertial>
      <xacro:insert_block name="origin"/>
      <mass value="${mass}"/>
      <inertia ixx="${mass * (depth * depth + height * height) / 12}"
               ixy="0" ixz="0"
               iyy="${mass * (width * width + height * height) / 12}"
               iyz="0"
               izz="${mass * (width * width + depth * depth) / 12}"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="thick_walled_tube_inertial"
               params="inner_rad outer_rad height mass">
    <inertial>
      <mass value="${mass}"/>
      <inertia ixx="${(1 / 12) * mass * (3 * (inner_rad * inner_rad +
                    outer_rad * outer_rad) + height * height)}"
               ixy="0" ixz="0"
               iyy="${(1 / 12) * mass * (3 * (inner_rad * inner_rad +
                    outer_rad * outer_rad) + height * height)}"
               iyz="0"
               izz="${mass * (inner_rad * inner_rad +
                    outer_rad * outer_rad) / 2}"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="shock"
               params="lr_prefix fr_prefix lr_reflect fr_reflect child">
    <joint name="${lr_prefix}_${fr_prefix}_shock" type="prismatic">
      <parent link="chassis"/>
      <child link="${child}"/>

      <origin xyz="${fr_reflect * wheelbase / 2}
                   ${lr_reflect * ((hex_hub_dist / 2) - axle_length)}
                   ${(wheel_travel / 2) - shock_z_offset}"/>
      <axis xyz="0 0 -1"/>
      <limit lower="${-wheel_travel / 2}" upper="${wheel_travel / 2}"
             effort="${shock_eff_limit}" velocity="${shock_vel_limit}"/>
    </joint>
    <transmission name="${lr_prefix}_${fr_prefix}_shock_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <joint name="${lr_prefix}_${fr_prefix}_shock">
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      </joint>
      <actuator name="${lr_prefix}_${fr_prefix}_shock_act">
        <!-- This hardwareInterface element exists for compatibility
             with ROS Hydro. -->
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
      </actuator>
    </transmission>
  </xacro:macro>

  <xacro:macro name="wheel" params="lr_prefix fr_prefix lr_reflect">
    <link name="${lr_prefix}_${fr_prefix}_axle_carrier">
      <xacro:null_inertial/>
    </link>

    <!-- The left and right axles have the same axis so that identical
         rotation values cause the wheels to rotate in the same direction. -->
    <joint name="${lr_prefix}_${fr_prefix}_axle" type="continuous">
      <parent link="${lr_prefix}_${fr_prefix}_axle_carrier"/>
      <child link="${lr_prefix}_${fr_prefix}_wheel"/>
      <origin rpy="${degrees_90} 0 0"/>
      <axis xyz="0 0 -1"/>
      <limit effort="${axle_eff_limit}" velocity="${axle_vel_limit}"/>
    </joint>
    <transmission name="${lr_prefix}_${fr_prefix}_axle_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <joint name="${lr_prefix}_${fr_prefix}_axle">
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      </joint>
      <actuator name="${lr_prefix}_${fr_prefix}_axle_act">
        <!-- This hardwareInterface element exists for compatibility
             with ROS Hydro. -->
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
      </actuator>
    </transmission>

    <link name="${lr_prefix}_${fr_prefix}_wheel">
      <visual>
        <origin xyz="0
                     ${lr_reflect * (axle_length - (tire_width /
                     2 - hex_hub_depth))}
                     0"/>
        <geometry>
          <cylinder radius="${tire_dia / 2}" length="${tire_width}"/>
        </geometry>
        <material name="tire_mat"/>
      </visual>

      <collision>
        <origin xyz="0
                     ${lr_reflect * (axle_length - (tire_width /
                     2 - hex_hub_depth))}
                     0"/>
        <geometry>
          <cylinder radius="${tire_dia / 2}" length="${tire_width}"/>
        </geometry>
      </collision>

      <xacro:thick_walled_tube_inertial
          inner_rad="${hub_dia / 2}" outer_rad="${tire_dia / 2}"
          height="${tire_width}" mass="${wheel_mass}"/>
    </link>

    <gazebo reference="${lr_prefix}_${fr_prefix}_wheel">
      <material>Gazebo/Black</material>
    </gazebo>
  </xacro:macro>

  <xacro:macro name="front_wheel"
               params="lr_prefix fr_prefix lr_reflect fr_reflect">
    <xacro:shock lr_prefix="${lr_prefix}" fr_prefix="${fr_prefix}"
                 lr_reflect="${lr_reflect}" fr_reflect="${fr_reflect}"
                 child="${lr_prefix}_steering_link"/>

    <link name="${lr_prefix}_steering_link">
      <xacro:null_inertial/>
    </link>

    <joint name="${lr_prefix}_steering_joint" type="revolute">
      <parent link="${lr_prefix}_steering_link"/>
      <child link="${lr_prefix}_${fr_prefix}_axle_carrier"/>
      <axis xyz="0 0 1"/>
      <limit lower="${-degrees_45}" upper="${degrees_45}"
             effort="${servo_stall_torque}" velocity="${servo_no_load_speed}"/>
    </joint>
    <transmission name="${lr_prefix}_steering_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <joint name="${lr_prefix}_steering_joint">
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      </joint>
      <actuator name="${lr_prefix}_steering_act">
        <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
      </actuator>
    </transmission>

    <xacro:wheel lr_prefix="${lr_prefix}" fr_prefix="${fr_prefix}"
                 lr_reflect="${lr_reflect}"/>
  </xacro:macro>

  <xacro:macro name="rear_wheel"
               params="lr_prefix fr_prefix lr_reflect fr_reflect">
    <xacro:shock lr_prefix="${lr_prefix}" fr_prefix="${fr_prefix}"
                 lr_reflect="${lr_reflect}" fr_reflect="${fr_reflect}"
                 child="${lr_prefix}_${fr_prefix}_axle_carrier"/>
    <xacro:wheel lr_prefix="${lr_prefix}" fr_prefix="${fr_prefix}"
                 lr_reflect="${lr_reflect}"/>
  </xacro:macro>

  <!-- chassis for sensors -->
  <xacro:macro name="layer" params="layer parent m x y z *joint_pose">
    <joint name="${layer}_joint" type="fixed">
      <xacro:insert_block name="joint_pose"/>
      <parent link="${parent}"/>
      <child link="${layer}_link" />
    </joint>

    <link name="${layer}_link">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <box size="${x} ${y} ${z}" />
        </geometry>
        <material name="yellow" />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <box size="${x} ${y} ${z}" />
        </geometry>
      </collision>
      <xacro:solid_cuboid_inertial
              width="${x}" depth="${y}"
              height="${z}" mass="${m}">
        <origin xyz="0 0 ${-z / 2}"/>
      </xacro:solid_cuboid_inertial>
    </link>

    <gazebo reference="${layer}_link">
      <material>Gazebo/Orange</material>
    </gazebo>
  </xacro:macro>

  <link name="base_footprint"/>
  <!-- base_link must have geometry so that its axes can be displayed in
       rviz. -->
  <link name="base_link">
    <visual>
      <geometry>
        <box size="0.01 0.01 0.01"/>
      </geometry>
      <material name="chassis_mat"/>
    </visual>
  </link>
  <gazebo reference="base_link">
    <material>Gazebo/Grey</material>
  </gazebo>

  <joint name="base_footprint_to_base_link" type="fixed">
    <parent link="base_footprint"/>
    <child link="base_link"/>
    <origin xyz="0 0 ${(wheel_travel/2)+shock_z_offset}" />
  </joint>

  <!-- Chassis -->
  <link name="chassis">
    <visual>W
      <origin xyz="0 0 ${-chassis_height / 2}"/>
      <geometry>
        <box size="${chassis_length} ${chassis_width} ${chassis_height}"/>
      </geometry>
      <material name="chassis_mat"/>
    </visual>

    <collision>
      <origin xyz="0 0 ${-chassis_height / 2}"/>
      <geometry>
        <box size="${chassis_length} ${chassis_width} ${chassis_height}"/>
      </geometry>
    </collision>

    <xacro:solid_cuboid_inertial
        width="${chassis_length}" depth="${chassis_width}"
        height="${chassis_height}" mass="${chassis_mass}">
      <origin xyz="0 0 ${-chassis_height / 2}"/>
    </xacro:solid_cuboid_inertial>
  </link>
  <gazebo reference="chassis">
    <material>Gazebo/Grey</material>
  </gazebo>

  <joint name="base_link_to_chassis" type="fixed">
    <parent link="base_link"/>
    <child link="chassis"/>
  </joint>

  <!-- Wheels -->
  <xacro:front_wheel lr_prefix="left" fr_prefix="front"
                     lr_reflect="1" fr_reflect="1"/>
  <xacro:front_wheel lr_prefix="right" fr_prefix="front"
                     lr_reflect="-1" fr_reflect="1"/>
  <xacro:rear_wheel lr_prefix="left" fr_prefix="rear"
                    lr_reflect="1" fr_reflect="-1"/>
  <xacro:rear_wheel lr_prefix="right" fr_prefix="rear"
                    lr_reflect="-1" fr_reflect="-1"/>

  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <legacyModeNS>true</legacyModeNS>
    <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
    <robotNamespace>/racecar</robotNamespace>
    </plugin>
  </gazebo>

  <!-- layers -->
  <layer layer="platform" parent="chassis" m="${layer_mass}" x="${layer_x}" y="${layer_y}" z="${layer_z}">
    <origin xyz="0 0 ${layer_height}" rpy="0 0 0" />
  </layer>

  <layer layer="lidar_platform" parent="platform_link" m="${layer_mass}" x="0.12" y="0.10" z="0.01">
    <origin xyz="0.08 0 ${layer_height}" rpy="0 0 0" />
  </layer>

  <joint name="lidar_joint" type="fixed">
    <origin xyz="0 0 0.03" rpy="0 0 0" />
    <parent link="lidar_platform_link"/>
    <child link="laser_link"/>
  </joint>

  <lidar prefix="laser"/>

  <joint name="camera_joint" type="fixed">
    <origin xyz="0.16 0 0.05" rpy="0 0 0" />
    <parent link="platform_link"/>
    <child link="camera_link"/>
  </joint>

  <camera prefix="camera"/>
</robot>



求解决

  • 写回答

22条回答 默认 最新

  • 码农阿豪 Java领域优质创作者 2024-04-03 16:33
    关注
    获得0.30元问题酬金
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    问题描述: 对于一个URDF模型,在使用check_urdf命令检查时,使用后缀为.urdf文件时没有问题,但是使用后缀为.urdf.xacro时出现错误。 原因分析: URDF模型文件有两种格式,一种是纯URDF格式(.urdf),一种是使用xacro脚本语言生成的格式(.urdf.xacro)。使用xacro格式文件需要通过xacro工具将其转换为纯URDF格式文件后再使用check_urdf命令进行检查。 解决方法: 1.将xacro文件转换为urdf文件 可以使用以下命令将xacro文件转换为urdf文件:
    rosrun xacro xacro.py your_file.urdf.xacro > your_file.urdf
    

    2.检查urdf文件 使用转换后的纯urdf文件进行check_urdf命令检查即可。 示例代码: 假设需要将my_robot.urdf.xacro转换为my_robot.urdf文件,并对其进行检查。 1.转换xacro文件为urdf文件

    rosrun xacro xacro.py my_robot.urdf.xacro > my_robot.urdf
    

    2.检查urdf文件

    check_urdf my_robot.urdf
    
    评论

报告相同问题?

问题事件

  • 系统已结题 4月11日
  • 修改了问题 4月3日
  • 赞助了问题酬金15元 4月3日
  • 创建了问题 4月3日

悬赏问题

  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。
  • ¥15 SQL Server analysis services 服务安装失败
  • ¥15 基于面向对象的图书馆借阅管理系统
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥20 centos linux 7.9安装php8.2.18不支持mysqli模块的问题
  • ¥15 stata空间计量LM检验