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文件规范。

相关推荐
沫儿笙10 小时前
克鲁斯焊接机器人保护气省气方案
人工智能·机器人
VR最前沿16 小时前
AI+医疗!VR和MR解剖学和针灸平台,智能时代如何重塑健康未来
科技·机器人·制造
Yuroo zhou2 天前
MEMS IMU如何赋能无人机与机器人精准感知?
人工智能·单片机·嵌入式硬件·机器人·硬件架构·无人机
Deepoch2 天前
疗愈之手的智慧觉醒:Deepoc具身智能如何重塑按摩机器人的触觉神经
机器人
草履虫建模2 天前
前后端分离项目中的接口设计与调用流程——以高仙机器人集成为例
java·前端·spring boot·机器人·intellij-idea·ruoyi·js
Axis tech2 天前
Xsens人形机器人拟人动作AI训练,提升机器人工作精度与效率
人工智能·机器人
yy鹈鹕灌顶2 天前
Java+Ollama 本地部署 DeepSeek-R1 对话机器人:从 0 到 1 实战指南
java·开发语言·机器人
想要成为计算机高手3 天前
6.isaac sim4.2 教程-Core API-多机器人,多任务
人工智能·python·机器人·英伟达·模拟器·仿真环境
一颗小树x3 天前
【机器人】REGNav 具身导航 | 跨房间引导 | 图像目标导航 AAAI 2025
机器人·具身导航·regnav·跨房间·图像目标导航
触想工业平板电脑一体机3 天前
触想CX-3588主板在安保巡检领域的落地实践:解锁机器人自主智能
人工智能·机器人