ros2/ros 4轮2驱机器人xacro/urdf文件示例代码

这个实验中最重要的是:colcon build 之后要记得source install/setup.bash.否则修改的文件是不会更新的。知道了吧

html 复制代码
<robot name="half" xmlns:xacro="http://wiki.ros.org/wiki/xacro">
  <xacro:property name="PI" value="3.1415926"/><!--定义一个变量PI,后边用来调用的-->
  <xacro:property name="base_footprint_radius" value="0.001"/>
  <xacro:property name="base_radius" value="0.1"/>
  <xacro:property name="base_length" value="0.08"/>
  <xacro:property name="ground_clearance" value="0.015"/>
  <material name="black">
    <color rgba="0.3 0.3 0.0 0.5"/>
  </material>    <!--注意了这个不能少-->
  <link name="base_footprint">
    <visual>
      <geometry>
          <sphere radius="${base_footprint_radius}"/>
      </geometry>
    </visual>
  </link>
  <link name="base">
    <visual>
      <geometry>
        <cylinder radius="${base_radius}" length="${base_length}"/>
      </geometry>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <material name="yellow">
        <color rgba="0.3 0.3 0.0 0.5"/>
      </material>
    </visual>
  </link>
  <joint name="base2base_footprint" type="fixed">
    <parent link="base_footprint"/>
    <child link="base"/>
    <origin xyz="0 0 ${ground_clearance+base_length/2}"/>
  </joint>
  <xacro:property name="wheel_radius" value="0.0325"/>
  <xacro:property name="wheel_length" value="0.015"/>
  <xacro:macro name="add_wheel" params="name flag">
    <link name="${name}_wheel">
      <visual>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${wheel_length}"/>
        </geometry>
        <origin xyz="0.0 0.0 0.0" rpy="${PI/2} 0 0"/>
        <material name="black"/>
      </visual>
    </link>
    <joint name="${name}_wheel2base" type="continuous">
      <parent link="base"/>
      <child link="${name}_wheel"/>
      <origin xyz="0 ${flag*base_radius} ${-(ground_clearance+base_length/2-wheel_radius)}"/>
      <axis xyz="0 1 0"/>
    </joint>
  </xacro:macro>
  <xacro:add_wheel name="left" flag="1"/>
  <xacro:add_wheel name="right" flag="-1"/>
  <xacro:property name="support_wheel_radius" value="0.0075">
  </xacro:property>
  <xacro:macro name="add_support_wheel" params="name flag">
    <link name="${name}_wheel">
      <visual>
        <geometry>
            <sphere radius="${support_wheel_radius}"/>
        </geometry>
        <origin xyz="0 0 0" rpy="0.0 0.0 0.0"/>
        <material name="black">
        </material>
      </visual>
    </link>
    <joint name="${name}_wheel2base" type="continuous">
      <parent link="base"/>
      <child link="${name}_wheel"/>
      <origin xyz="${flag*(base_radius-support_wheel_radius)} 0 ${-(base_length/2+ground_clearance/2)}"/>
      <axis xyz="1 1 1"/>
    </joint>
  </xacro:macro>
  <xacro:add_support_wheel name="front" flag="1"/>
  <xacro:add_support_wheel name="back" flag="-1"/>
</robot>

上述代码中的:<material name="black">

<color rgba="0.3 0.3 0.0 0.5"/>

</material>

这段代码不能少,(虽然说少了也可以,但是不正常了)

不少之后没有任何错误,说明符合urdf文件,xacro文件规范。

相关推荐
沫儿笙6 小时前
OTC欧地希焊接机器人智能气阀
机器人
爱吃青菜的大力水手6 小时前
软银收购 ABB 机器人业务的背景与 Physical AI 的关联
人工智能·机器人
Mr.Winter`7 小时前
深度强化学习 | 基于SAC算法的动态避障(ROS C++仿真)
人工智能·深度学习·神经网络·机器人·自动驾驶·ros·具身智能
酌量7 小时前
路径平滑优化详解(二次规划): 数学建模与目标函数推导
经验分享·笔记·学习·机器人·自动驾驶
武子康8 小时前
AI-调查研究-102-具身智能 智能机械臂、自动驾驶与人形机器人的模仿学习、强化学习与多模态融合趋势
人工智能·深度学习·机器学习·ai·机器人·强化学习·具身智能
ARM+FPGA+AI工业主板定制专家1 天前
基于JETSON/RK3588机器人高动态双目视觉系统方案
人工智能·机器学习·fpga开发·机器人·自动驾驶
哈泽尔都1 天前
运动控制教学——5分钟学会PRM算法!
人工智能·单片机·算法·数学建模·贪心算法·机器人·无人机
孤独野指针*P1 天前
MoveIt 机械臂碰撞检测:从环境搭建到障碍物规避
linux·3d·机器人
搬砖的小码农_Sky2 天前
人形机器人:Tesla Optimus的AI集成细节
人工智能·ai·机器人
xwz小王子2 天前
Science Robotics 研究综述:基于学习方法的机器人操作动力学模型
机器人·学习方法