355 lines
16 KiB
XML
355 lines
16 KiB
XML
<?xml version="1.0"?>
|
||
<!--
|
||
哨兵整车 URDF —— 由「整车装配体」SolidWorks STL 直接生成(tools/build_vehicle.py)
|
||
|
||
相比早先分别导入「底盘」「云台」两套文件的版本,这一版的关键改进:
|
||
* 所有零件来自同一个装配体坐标系,云台/底盘/轮子的相对位置与真车一致
|
||
* 云台作为整车刚体的一部分(导航阶段不需要云台转动)
|
||
* 四个轮子位置从装配体量出来,不再靠推测
|
||
|
||
坐标系:REP-103(X 前、Y 左、Z 上),原点 = 车体几何中心的地面投影。
|
||
SW 装配体是 Y 向上:ROS_x = SW_z、ROS_y = SW_x、ROS_z = SW_y。
|
||
|
||
⚠️ PLACEHOLDER(等机械给真实数据后替换):
|
||
- 整车质量 25 kg、质心高度 0.18 m、惯量按长方体估算
|
||
- 轮子质量 1.5 kg
|
||
- 雷达安装位置(本装配体里没有雷达模型,位置未知)
|
||
|
||
mesh_prefix 默认以本 xacro 文件所在目录为基准,各调用方可指定自己的资源基准。
|
||
-->
|
||
<robot name="sentry" xmlns:xacro="http://www.ros.org/wiki/xacro">
|
||
|
||
<xacro:arg name="mesh_prefix" default="../meshes"/>
|
||
|
||
<!-- ================= 参数区 ================= -->
|
||
<xacro:property name="wheel_radius" value="0.0762"/>
|
||
<xacro:property name="wheel_width" value="0.0731"/>
|
||
|
||
<!-- 四轮位置(ROS,米)—— 整车装配体实测;斜置悬挂,四个位置互不相同 -->
|
||
<!-- 前 = +X(相机/枪口侧),左 = +Y -->
|
||
<xacro:property name="wheel_front_left" value=" 0.16634 0.21288 0.07620"/>
|
||
<xacro:property name="wheel_front_right" value=" 0.16553 -0.21352 0.07620"/>
|
||
<xacro:property name="wheel_rear_left" value="-0.16582 0.21352 0.07620"/>
|
||
<xacro:property name="wheel_rear_right" value="-0.16663 -0.21288 0.07620"/>
|
||
|
||
<!-- 车体包络(米):宽 0.6225 × 高 0.5008 × 长 0.8734(含枪管外伸) -->
|
||
<xacro:property name="body_l" value="0.578"/> <!-- 车体前后长(装配体实测) -->
|
||
<xacro:property name="body_w" value="0.521"/>
|
||
<xacro:property name="body_h" value="0.500"/>
|
||
|
||
<xacro:property name="body_mass" value="25.0"/>
|
||
<xacro:property name="wheel_mass" value="1.5"/>
|
||
|
||
<!-- MID-360 安装位置,装配体实测 ROS xyz=(-0.0935, -0.1512, 0.4052)。 -->
|
||
<xacro:property name="lidar_x" value="-0.0935"/>
|
||
<xacro:property name="lidar_y" value="-0.1512"/>
|
||
<xacro:property name="lidar_z" value="0.4052"/>
|
||
<xacro:property name="lidar_width" value="0.065"/>
|
||
<xacro:property name="lidar_height" value="0.060"/>
|
||
<xacro:property name="lidar_mass" value="0.265"/>
|
||
|
||
<!-- ============ 云台 yaw(连续旋转关节)============
|
||
yaw 轴在车体中心 (0, 0):由 tools/build_vehicle.py 的 split-gimbal 从 5 个
|
||
本该同轴的零件(70齿大带轮 / 云台内圈 / 15.5滑环 / 内70外86 轴承 ×2)求得,
|
||
实测共轴离散 0.03 mm。
|
||
⚠️ 不要用 GM6020 电机中心 —— 电机经 35齿小带轮 + 皮带 + 70齿大带轮 减速,
|
||
电机轴在 x=+0.0899,与 yaw 轴差一个皮带中心距(89.9 mm)。 -->
|
||
<xacro:property name="yaw_axis_x" value="0.0"/>
|
||
<xacro:property name="yaw_axis_y" value="0.0"/>
|
||
<!-- 云台安装面高度:等于云台组最低点(split-gimbal 输出的 gimbal_joint_origin_ros_m.z) -->
|
||
<xacro:property name="yaw_mount_z" value="0.1187"/>
|
||
|
||
<!-- 旋转组包络(相对 yaw 轴,装配体实测)。
|
||
绕 z 轴自由旋转后的扫掠半径 = 0.3021 m(= 最远角 √(0.2656² + 0.1439²)),
|
||
nav2 footprint 与 self_filter 剔除盒都按这个圆来。 -->
|
||
<xacro:property name="gimbal_min_x" value="-0.1953"/>
|
||
<xacro:property name="gimbal_max_x" value="0.2656"/>
|
||
<xacro:property name="gimbal_min_y" value="-0.1399"/>
|
||
<xacro:property name="gimbal_max_y" value="0.1439"/>
|
||
<xacro:property name="gimbal_top_z" value="0.5005"/>
|
||
<!-- TODO(机械):质量是估值,拿到 SolidWorks「质量属性」后替换 -->
|
||
<xacro:property name="gimbal_mass" value="2.0"/>
|
||
|
||
<material name="dark_gray"><color rgba="0.15 0.15 0.17 1"/></material>
|
||
<material name="rm_blue"><color rgba="0.10 0.25 0.60 1"/></material>
|
||
|
||
<!-- ================= 车体(底盘;云台已拆成 gimbal_yaw_link) ================= -->
|
||
<link name="base_link">
|
||
<visual>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<geometry>
|
||
<mesh filename="$(arg mesh_prefix)/base.stl"/>
|
||
</geometry>
|
||
<material name="dark_gray"/>
|
||
</visual>
|
||
<!-- 碰撞体只有底盘一个简化盒。云台的碰撞盒在 gimbal_yaw_link 上,
|
||
这样它能跟着 yaw 关节一起转。
|
||
不能用一个大盒子包住整车——MID-360 在 z=0.405,会被包在盒子内部,
|
||
雷达射线全打在盒子内壁上(实测距离只有 0.2~0.4 m)。 -->
|
||
<collision name="chassis_collision">
|
||
<!-- 底面必须离地!原来 z 从 0 开始,底盘盒会拖在地板上(静摩擦抵消轮子
|
||
推力),实测 0.3 m/s 指令只能走 ~0.11 m/s,导航报 "Failed to make
|
||
progress"。抬到离地 2 cm,让四个轮子独立承重。 -->
|
||
<origin xyz="0 0 0.145" rpy="0 0 0"/>
|
||
<geometry>
|
||
<box size="${body_l} ${body_w} 0.25"/>
|
||
</geometry>
|
||
</collision>
|
||
<inertial>
|
||
<origin xyz="0 0 0.18" rpy="0 0 0"/>
|
||
<mass value="${body_mass}"/>
|
||
<inertia
|
||
ixx="${body_mass/12*(body_w*body_w + body_h*body_h)}"
|
||
ixy="0" ixz="0"
|
||
iyy="${body_mass/12*(body_l*body_l + body_h*body_h)}"
|
||
iyz="0"
|
||
izz="${body_mass/12*(body_l*body_l + body_w*body_w)}"/>
|
||
</inertial>
|
||
</link>
|
||
|
||
<!-- ================= 云台 yaw(可 360° 连续旋转) =================
|
||
visual 用 gimbal.stl —— 由 tools/build_vehicle.py 的 split-gimbal 生成,
|
||
原点就在 yaw 轴 + 安装面上,所以这里 origin 是 (0,0,0)。 -->
|
||
<link name="gimbal_yaw_link">
|
||
<visual>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<geometry>
|
||
<mesh filename="$(arg mesh_prefix)/gimbal.stl"/>
|
||
</geometry>
|
||
<material name="dark_gray"/>
|
||
</visual>
|
||
<!-- 碰撞体=旋转组包络盒(相对 yaw 轴)。旋转时它跟着 link 转。 -->
|
||
<collision name="gimbal_collision">
|
||
<origin
|
||
xyz="${(gimbal_min_x + gimbal_max_x) / 2} ${(gimbal_min_y + gimbal_max_y) / 2} ${(gimbal_top_z - yaw_mount_z) / 2}"
|
||
rpy="0 0 0"/>
|
||
<geometry>
|
||
<box size="${gimbal_max_x - gimbal_min_x} ${gimbal_max_y - gimbal_min_y} ${gimbal_top_z - yaw_mount_z}"/>
|
||
</geometry>
|
||
</collision>
|
||
<inertial>
|
||
<origin
|
||
xyz="${(gimbal_min_x + gimbal_max_x) / 2} ${(gimbal_min_y + gimbal_max_y) / 2} ${(gimbal_top_z - yaw_mount_z) / 2}"
|
||
rpy="0 0 0"/>
|
||
<mass value="${gimbal_mass}"/>
|
||
<inertia
|
||
ixx="${gimbal_mass/12*((gimbal_max_y - gimbal_min_y)*(gimbal_max_y - gimbal_min_y) + (gimbal_top_z - yaw_mount_z)*(gimbal_top_z - yaw_mount_z))}"
|
||
ixy="0" ixz="0"
|
||
iyy="${gimbal_mass/12*((gimbal_max_x - gimbal_min_x)*(gimbal_max_x - gimbal_min_x) + (gimbal_top_z - yaw_mount_z)*(gimbal_top_z - yaw_mount_z))}"
|
||
iyz="0"
|
||
izz="${gimbal_mass/12*((gimbal_max_x - gimbal_min_x)*(gimbal_max_x - gimbal_min_x) + (gimbal_max_y - gimbal_min_y)*(gimbal_max_y - gimbal_min_y))}"/>
|
||
</inertial>
|
||
</link>
|
||
|
||
<!-- type="continuous" 才能 360° 连续转;revolute 必须有上下限。
|
||
continuous 关节在 URDF 里仍要写 effort/velocity 上限(没有 lower/upper)。 -->
|
||
<joint name="gimbal_yaw_joint" type="continuous">
|
||
<parent link="base_link"/>
|
||
<child link="gimbal_yaw_link"/>
|
||
<origin xyz="${yaw_axis_x} ${yaw_axis_y} ${yaw_mount_z}" rpy="0 0 0"/>
|
||
<axis xyz="0 0 1"/>
|
||
<limit effort="20.0" velocity="30.0"/>
|
||
<dynamics damping="0.1" friction="0.05"/>
|
||
</joint>
|
||
|
||
<!-- ================= 四个麦轮 ================= -->
|
||
<xacro:macro name="wheel_link" params="name xyz">
|
||
<link name="${name}">
|
||
<visual>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<geometry>
|
||
<mesh filename="$(arg mesh_prefix)/wheel.stl"/>
|
||
</geometry>
|
||
<material name="dark_gray"/>
|
||
</visual>
|
||
<collision>
|
||
<!-- 圆柱体绕 Y 轴(横向) -->
|
||
<origin xyz="0 0 0" rpy="1.5708 0 0"/>
|
||
<geometry>
|
||
<cylinder radius="${wheel_radius}" length="${wheel_width}"/>
|
||
</geometry>
|
||
</collision>
|
||
<inertial>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<mass value="${wheel_mass}"/>
|
||
<inertia
|
||
ixx="${wheel_mass/12*(3*wheel_radius*wheel_radius + wheel_width*wheel_width)}"
|
||
ixy="0" ixz="0"
|
||
iyy="${wheel_mass*wheel_radius*wheel_radius/2}"
|
||
iyz="0"
|
||
izz="${wheel_mass/12*(3*wheel_radius*wheel_radius + wheel_width*wheel_width)}"/>
|
||
</inertial>
|
||
</link>
|
||
<joint name="${name}_joint" type="revolute">
|
||
<parent link="base_link"/>
|
||
<child link="${name}"/>
|
||
<origin xyz="${xyz}" rpy="0 0 0"/>
|
||
<axis xyz="0 1 0"/>
|
||
<limit lower="-1e16" upper="1e16" effort="80" velocity="50"/>
|
||
</joint>
|
||
</xacro:macro>
|
||
|
||
<xacro:wheel_link name="wheel_fl" xyz="${wheel_front_left}"/>
|
||
<xacro:wheel_link name="wheel_fr" xyz="${wheel_front_right}"/>
|
||
<xacro:wheel_link name="wheel_bl" xyz="${wheel_rear_left}"/>
|
||
<xacro:wheel_link name="wheel_br" xyz="${wheel_rear_right}"/>
|
||
|
||
<!-- ================= 雷达 / IMU 安装点 ================= -->
|
||
<link name="lidar_link">
|
||
<visual>
|
||
<geometry>
|
||
<box size="${lidar_width} ${lidar_width} ${lidar_height}"/>
|
||
</geometry>
|
||
<material name="rm_blue"/>
|
||
</visual>
|
||
<inertial>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<mass value="${lidar_mass}"/>
|
||
<inertia ixx="${lidar_mass / 12 * (lidar_width**2 + lidar_height**2)}"
|
||
ixy="0" ixz="0"
|
||
iyy="${lidar_mass / 12 * (lidar_width**2 + lidar_height**2)}"
|
||
iyz="0" izz="${lidar_mass / 6 * lidar_width**2}"/>
|
||
</inertial>
|
||
</link>
|
||
<!-- 雷达装在弹仓上,弹仓随 yaw 轴一起转,所以父级是 gimbal_yaw_link 而不是 base_link。
|
||
原点必须换算到云台系:底盘系里的 lidar_z 减掉云台安装面高度 yaw_mount_z。
|
||
注意:type="fixed" 的关节在 URDF→SDF 转换时会被合并(fixed_joint_lump),
|
||
合并到哪个 link 取决于这里的 parent,所以 parent 一改,雷达就跟着云台转。 -->
|
||
<joint name="lidar_joint" type="fixed">
|
||
<parent link="gimbal_yaw_link"/>
|
||
<child link="lidar_link"/>
|
||
<origin xyz="${lidar_x} ${lidar_y} ${lidar_z - yaw_mount_z}" rpy="0 0 0"/>
|
||
</joint>
|
||
|
||
<link name="imu_link">
|
||
<inertial>
|
||
<origin xyz="0 0 0" rpy="0 0 0"/>
|
||
<mass value="0.05"/>
|
||
<inertia ixx="1e-5" ixy="0" ixz="0" iyy="1e-5" iyz="0" izz="1e-5"/>
|
||
</inertial>
|
||
</link>
|
||
<joint name="imu_joint" type="fixed">
|
||
<parent link="base_link"/>
|
||
<child link="imu_link"/>
|
||
<origin xyz="0 0 0.15" rpy="0 0 0"/>
|
||
</joint>
|
||
|
||
<!-- ================= Gazebo 扩展 ================= -->
|
||
<gazebo reference="wheel_fl"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
|
||
<gazebo reference="wheel_fr"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
|
||
<gazebo reference="wheel_bl"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
|
||
<gazebo reference="wheel_br"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
|
||
|
||
<gazebo>
|
||
<!-- Evaluation only: independent world pose, never consumed by localization. -->
|
||
<plugin filename="gz-sim-pose-publisher-system" name="gz::sim::systems::PosePublisher">
|
||
<publish_model_pose>true</publish_model_pose>
|
||
<publish_link_pose>false</publish_link_pose>
|
||
<publish_nested_model_pose>false</publish_nested_model_pose>
|
||
<use_pose_vector_msg>false</use_pose_vector_msg>
|
||
<update_frequency>100</update_frequency>
|
||
<topic>/evaluation/ground_truth</topic>
|
||
</plugin>
|
||
<plugin filename="gz-sim-mecanum-drive-system" name="gz::sim::systems::MecanumDrive">
|
||
<front_left_joint>wheel_fl_joint</front_left_joint>
|
||
<front_right_joint>wheel_fr_joint</front_right_joint>
|
||
<back_left_joint>wheel_bl_joint</back_left_joint>
|
||
<back_right_joint>wheel_br_joint</back_right_joint>
|
||
<!-- 斜置悬挂:取前后 / 左右的平均距离 -->
|
||
<wheel_separation>0.4263</wheel_separation>
|
||
<wheelbase>0.3323</wheelbase>
|
||
<wheel_radius>${wheel_radius}</wheel_radius>
|
||
<max_linear_velocity>2.0</max_linear_velocity>
|
||
<max_angular_velocity>4.0</max_angular_velocity>
|
||
<odom_topic>/odom</odom_topic>
|
||
<odom_publish_frequency>50</odom_publish_frequency>
|
||
<frame_id>odom</frame_id>
|
||
</plugin>
|
||
<!-- 云台 yaw:连续旋转由外部命令驱动。
|
||
use_velocity_commands=true → 话题上的 Double 是**目标角速度**(rad/s),
|
||
关节可以一直往同一个方向转,不受 ±π 限制。
|
||
话题:/model/sentry/gimbal_yaw_cmd
|
||
发 1.0 就是 1 rad/s 正转,发 -1.0 反转,发 0 停。
|
||
⚠️ 这个是纯仿真驱动;真机上由云台电机的 CAN 控制接管。 -->
|
||
<plugin filename="gz-sim-joint-position-controller-system"
|
||
name="gz::sim::systems::JointPositionController">
|
||
<joint_name>gimbal_yaw_joint</joint_name>
|
||
<sub_topic>gimbal_yaw_cmd</sub_topic>
|
||
<use_velocity_commands>true</use_velocity_commands>
|
||
<p_gain>20</p_gain>
|
||
<i_gain>0</i_gain>
|
||
<d_gain>2</d_gain>
|
||
<i_max>1</i_max>
|
||
<i_min>-1</i_min>
|
||
<cmd_max>30</cmd_max>
|
||
<cmd_min>-30</cmd_min>
|
||
</plugin>
|
||
|
||
<!-- 关节状态发布:雷达挂在云台上,云台转角必须能被 ROS 侧看到,
|
||
否则 TF 里 base_link→gimbal_yaw_link 永远是 0,点云姿态和实际对不上。
|
||
<topic> 显式指定成 /joint_states,省掉 "world 名 + model 名" 的长话题
|
||
(默认是 /world/<world>/model/<model>/joint_state,换世界就失效)。
|
||
不写 <joint_name> 就是发布全部关节,轮子也能在 RViz 里正常转。
|
||
必须挂在 model 上——挂到 world 会报
|
||
"The JointStatePublisher system should be attached to a model entity"。 -->
|
||
<plugin filename="gz-sim-joint-state-publisher-system"
|
||
name="gz::sim::systems::JointStatePublisher">
|
||
<topic>joint_states</topic>
|
||
</plugin>
|
||
</gazebo>
|
||
|
||
<!-- 3D 雷达由世界的 OGRE2 Sensors 系统渲染。 -->
|
||
<gazebo reference="lidar_link">
|
||
<sensor name="lidar" type="gpu_lidar">
|
||
<pose>0 0 0 0 0 0</pose>
|
||
<topic>scan</topic>
|
||
<gz_frame_id>lidar_link</gz_frame_id>
|
||
<update_rate>10</update_rate>
|
||
<always_on>true</always_on>
|
||
<visualize>true</visualize>
|
||
<lidar>
|
||
<scan>
|
||
<horizontal>
|
||
<samples>360</samples>
|
||
<resolution>1</resolution>
|
||
<min_angle>-3.14159265</min_angle>
|
||
<max_angle>3.14159265</max_angle>
|
||
</horizontal>
|
||
<!-- 垂直 FOV 对应 MID-360 的 -7° 至 +52°,共 40 线。 -->
|
||
<vertical>
|
||
<samples>40</samples>
|
||
<resolution>1</resolution>
|
||
<min_angle>-0.122173048</min_angle>
|
||
<max_angle>0.907571211</max_angle>
|
||
</vertical>
|
||
</scan>
|
||
<range>
|
||
<min>0.10</min>
|
||
<!-- Livox specifies 40 m at 10% target reflectivity. -->
|
||
<max>40.0</max>
|
||
<resolution>0.01</resolution>
|
||
</range>
|
||
<noise>
|
||
<type>gaussian</type>
|
||
<mean>0.0</mean>
|
||
<stddev>0.01</stddev>
|
||
</noise>
|
||
</lidar>
|
||
</sensor>
|
||
</gazebo>
|
||
|
||
<!-- scan2d 现在由 self_filter 从 3D 点云投影生成(取 z∈[0.05,0.50] m 车体碰撞带,
|
||
按 360 方位取最小距离;见 docs/定位接入AMCL.md §4.2)。
|
||
这里不再放单线传感器——单线雷达在几何上看不见 0.42 m 悬空平板,是跑飞根因。 -->
|
||
|
||
<gazebo reference="imu_link">
|
||
<sensor name="imu" type="imu">
|
||
<topic>imu</topic>
|
||
<gz_frame_id>imu_link</gz_frame_id>
|
||
<update_rate>100</update_rate>
|
||
<always_on>true</always_on>
|
||
</sensor>
|
||
</gazebo>
|
||
|
||
</robot>
|