| name | sdf-xacro-model |
| description | 多旋翼无人机 SDF/XACRO 模型开发技能 - 四旋翼、六旋翼、八旋翼模型创建、飞行物理配置、环境风力仿真 |
| argument-hint | 创建无人机模型 OR 四旋翼 OR 六旋翼 OR 无人机仿真 |
| user-invocable | true |
Multi-Rotor UAV SDF/XACRO Model Skill
用于创建多旋翼无人机的 SDF 和 XACRO 模型
何时使用
当需要以下帮助时使用此技能:
- 创建多旋翼无人机模型
- 配置飞行物理参数
- 添加风力/扰动仿真
- 设置负载和传感器
- 配置起飞/降落状态
快速参考
常见配置
四旋翼 (Quadrotor) - 简单、紧凑
六旋翼 (Hexrotor) - 更大负载、更稳定
八旋翼 (Octrotor) - 最大负载、高冗余
四旋翼无人机
SDF 模型 - 完整示例
<?xml version="1.0" ?>
<sdf version="1.11">
<model name="quadrotor">
<static>false</static>
<self_collide>false</self_collide>
<link name="base_link">
<pose>0 0 0.05 0 0 0</pose>
<inertial>
<mass>1.5</mass>
<inertia>
<ixx>0.01</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.01</iyy><iyz>0</iyz>
<izz>0.02</izz>
</inertia>
</inertial>
<collision name="base_collision">
<geometry>
<box>
<size>0.2 0.2 0.05</size>
</box>
</geometry>
</collision>
<visual name="base_visual">
<geometry>
<box>
<size>0.2 0.2 0.05</size>
</box>
</geometry>
<material>
<ambient>0.3 0.3 0.3 1</ambient>
<diffuse>0.3 0.3 0.3 1</diffuse>
</material>
</visual>
<visual name="prop_guard">
<pose>0 0 0.02 0 0 0</pose>
<geometry>
<cylinder>
<radius>0.15</radius>
<length>0.01</length>
</cylinder>
</geometry>
<material>
<ambient>0.5 0.5 0.8 1</ambient>
</material>
</visual>
</link>
<link name="motor_fl">
<pose>0.15 0.15 0.03 0 0 0</pose>
<inertial>
<mass>0.05</mass>
<inertia>
<ixx>0.0001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.0001</iyy><iyz>0</iyz>
<izz>0.0001</izz>
</inertia>
</inertial>
<collision name="motor_fl_collision">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
</collision>
<visual name="motor_fl_visual">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
<material>
<ambient>0.1 0.1 0.1 1</ambient>
</material>
</visual>
</link>
<joint name="motor_fl_joint" type="revolute">
<parent>base_link</parent>
<child>motor_fl</child>
<axis>
<xyz>0 0 1</xyz>
<limit>
<lower>-1000</lower>
<upper>1000</upper>
<effort>10</effort>
<velocity>1000</velocity>
</limit>
</axis>
</joint>
<link name="motor_fr">
<pose>0.15 -0.15 0.03 0 0 0</pose>
<inertial>
<mass>0.05</mass>
<inertia>
<ixx>0.0001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.0001</iyy><iyz>0</iyz>
<izz>0.0001</izz>
</inertia>
</inertial>
<collision name="motor_fr_collision">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
</collision>
<visual name="motor_fr_visual">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
<material>
<ambient>0.1 0.1 0.1 1</ambient>
</material>
</visual>
</link>
<joint name="motor_fr_joint" type="revolute">
<parent>base_link</parent>
<child>motor_fr</child>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<link name="motor_rl">
<pose>-0.15 0.15 0.03 0 0 0</pose>
<inertial>
<mass>0.05</mass>
<inertia>
<ixx>0.0001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.0001</iyy><iyz>0</iyz>
<izz>0.0001</izz>
</inertia>
</inertial>
<collision name="motor_rl_collision">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
</collision>
<visual name="motor_rl_visual">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
<material>
<ambient>0.1 0.1 0.1 1</ambient>
</material>
</visual>
</link>
<joint name="motor_rl_joint" type="revolute">
<parent>base_link</parent>
<child>motor_rl</child>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<link name="motor_rr">
<pose>-0.15 -0.15 0.03 0 0 0</pose>
<inertial>
<mass>0.05</mass>
<inertia>
<ixx>0.0001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.0001</iyy><iyz>0</iyz>
<izz>0.0001</izz>
</inertia>
</inertial>
<collision name="motor_rr_collision">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
</collision>
<visual name="motor_rr_visual">
<geometry>
<cylinder>
<radius>0.015</radius>
<height>0.02</height>
</cylinder>
</geometry>
<material>
<ambient>0.1 0.1 0.1 1</ambient>
</material>
</visual>
</link>
<joint name="motor_rr_joint" type="revolute">
<parent>base_link</parent>
<child>motor_rr</child>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<link name="prop_fl">
<pose>0.15 0.15 0.05 0 0 0</pose>
<inertial>
<mass>0.01</mass>
<inertia>
<ixx>0.00001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.00001</iyy><iyz>0</iyz>
<izz>0.00001</izz>
</inertia>
</inertial>
<visual name="prop_fl_visual">
<geometry>
<cylinder>
<radius>0.08</radius>
<height>0.005</height>
</cylinder>
</geometry>
<material>
<ambient>0.8 0.8 0.8 0.5</ambient>
<transparency>0.5</transparency>
</material>
</visual>
</link>
<joint name="prop_fl_joint" type="fixed">
<parent>motor_fl</parent>
<child>prop_fl</child>
</joint>
<link name="laser_link">
<pose>0 0 0.05 0 0 0</pose>
<sensor name="laser" type="gpu_lidar">
<update_rate>20</update_rate>
<ray>
<scan>
<horizontal>
<samples>360</samples>
<resolution>1</resolution>
</horizontal>
</scan>
<range>
<min>0.1</min>
<max>50</max>
</range>
</ray>
<plugin filename="gz-sim-sensors-gpu-lidar" name="gz::sim::systems::GpuRaySensor">
<ros>
<namespace>/uav</namespace>
</ros>
</plugin>
</sensor>
</link>
<joint name="laser_joint" type="fixed">
<parent>base_link</parent>
<child>laser_link</child>
</joint>
<link name="gps_link">
<pose>0 0.1 0.05 0 0 0</pose>
<sensor name="gps" type="gps">
<update_rate>10</update_rate>
<plugin filename="gz-sim-sensors-gps-system" name="gz::sim::systems::Gps">
<ros>
<namespace>/uav</namespace>
</ros>
</plugin>
</sensor>
</link>
<joint name="gps_joint" type="fixed">
<parent>base_link</parent>
<child>gps_link</child>
</joint>
<link name="imu_link">
<pose>0 0 0.02 0 0 0</pose>
<sensor name="imu" type="imu">
<update_rate>100</update_rate>
<plugin filename="gz-sim-sensors-imu-system" name="gz::sim::systems::Imu">
<ros>
<namespace>/uav</namespace>
</ros>
</plugin>
</sensor>
</link>
<joint name="imu_joint" type="fixed">
<parent>base_link</parent>
<child>imu_link</child>
</joint>
<plugin filename="gz-sim-multirotor-physics-plugin" name="gz::sim::systems::MultirotorPhysics">
<robotNamespace>uav</robotNamespace>
<robotName>quadrotor</robotName>
<motors>
<motor>
<name>motor_fl</name>
<link>prop_fl</link>
<direction>clockwise</direction>
<thrust_coefficient>8.548e-6</thrust_coefficient>
<torque_coefficient>1e-5</torque_coefficient>
</motor>
<motor>
<name>motor_fr</name>
<link>prop_fr</link>
<direction>counter_clockwise</direction>
<thrust_coefficient>8.548e-6</thrust_coefficient>
<torque_coefficient>1e-5</torque_coefficient>
</motor>
<motor>
<name>motor_rl</name>
<link>prop_rl</link>
<direction>counter_clockwise</direction>
<thrust_coefficient>8.548e-6</thrust_coefficient>
<torque_coefficient>1e-5</torque_coefficient>
</motor>
<motor>
<name>motor_rr</name>
<link>prop_rr</link>
<direction>clockwise</direction>
<thrust_coefficient>8.548e-6</thrust_coefficient>
<torque_coefficient>1e-5</torque_coefficient>
</motor>
</motors>
<control>
<type>velocity</type>
<takeoff>true</takeoff>
<land>true</land>
</control>
</plugin>
</model>
</sdf>
六旋翼无人机
SDF 模型
<?xml version="1.0" ?>
<sdf version="1.11">
<model name="hexrotor">
<static>false</static>
<link name="base_link">
<pose>0 0 0.08 0 0 0</pose>
<inertial>
<mass>3.0</mass>
<inertia>
<ixx>0.02</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.02</iyy><iyz>0</iyz>
<izz>0.04</izz>
</inertia>
</inertial>
<collision name="base_collision">
0.25 0.25 0.08
0.25 0.25 0.08
0.2 0.2 0.4 1
0.2 0.115 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
0.02
0.025
base_link
motor_1
0 0 1
0.1 0.23 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
0.02
0.025
base_link
motor_2
0 0 1
-0.1 0.23 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
base_link
motor_3
0 0 1
-0.2 0.115 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
base_link
motor_4
0 0 1
-0.2 -0.115 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
base_link
motor_5
0 0 1
-0.1 -0.23 0.05 0 0 0
0.08
0.000200
0.00020
0.0002
base_link
motor_6
0 0 1
uav
motor_1clockwise1.2e-5
motor_2counter_clockwise1.2e-5
motor_3clockwise1.2e-5
motor_4counter_clockwise1.2e-5
motor_5clockwise1.2e-5
motor_6counter_clockwise1.2e-5
飞行物理参数
空气动力学配置
<gazebo reference="base_link">
<velocity_decay>
<linear>0.1</linear>
<angular>0.1</angular>
</velocity_decay>
</gazebo>
<plugin filename="gz-sim-multirotor-physics-plugin" name="gz::sim::systems::MultirotorPhysics">
<thrust_coefficient>8.548e-6</thrust_coefficient>
<torque_coefficient>1e-5</torque_coefficient>
<motor_time_constant>0.05</motor_time_constant>
<propeller_diameter>0.15</propeller_diameter>
<motor_constant>2827.0</motor_constant>
</plugin>
环境条件仿真
风力扰动
<?xml version="1.0" ?>
<sdf version="1.11">
<world name="windy_world">
<plugin filename="gz-sim-wind-system" name="gz::sim::systems::Wind">
<frame_id>world</frame_id>
<namespace>wind</namespace>
<direction>
<x>0.5</x>
<y>0.866</y>
<z>0</z>
</direction>
<magnitude>
<type>constant</type>
<value>5.0</value>
</magnitude>
<variation>
gaussian
0
1.5
2.0
5.0
3.0
1
0
0.2
pulse
3.0
8.0
无人机风力响应
<gazebo reference="base_link">
<wind>
<linear_drag>0.1</linear_drag>
<angular_drag>0.05</angular_drag>
</wind>
</gazebo>
负载配置
云台相机
<link name="gimbal_link">
<pose>0 0 -0.05 0 0 0</pose>
<inertial>
<mass>0.3</mass>
<inertia>
<ixx>0.0001</ixx><ixy>0</ixy><ixz>0</ixz>
<iyy>0.0001</iyy><iyz>0</iyz>
<izz>0.0001</izz>
</inertia>
</inertial>
<visual name="gimbal_visual">
<geometry>
<box>
<size>0.08 0.06 0.04</size>
</box>
</geometry>
</visual>
< =>
0.08 0.06 0.04
base_link
gimbal_link
1 0 0
-1.57
1.57
gimbal_link
gimbal_camera_link
0 1 0
-3.14
3.14
货物挂载
<link name="cargo_hook">
<pose>0 0 -0.15 0 0 0</pose>
<inertial>
<mass>0.1</mass>
</inertial>
<visual name="cargo_hook_visual">
<geometry>
<sphere>
<radius>0.02</radius>
</sphere>
</geometry>
</visual>
</link>
<joint name="cargo_hook_joint" type="fixed">
<parent>base_link</parent>
<child>cargo_hook</child>
</joint>
传感器配置
无人机常用传感器
<link name="range_link">
<pose>0 0 -0.1 0 0 0</pose>
<sensor name="range" type="ray">
<update_rate>50</update_rate>
<ray>
<scan>
<horizontal>
<samples>1</samples>
<resolution>1</resolution>
</horizontal>
<vertical>
<samples>1</samples>
</vertical>
</scan>
<range>
<min>0.1</min>
<max>5.0</max>
<resolution>0.01</resolution>
</range>
</>
/uav
/range:=sensor/range
0 0.1 -0.02 0 0 0
30
0 0.06 0 0 0 0
1.047
640
480
0 -0.06 0 0 0 0
1.047
640
480
/uav
飞行模式配置
起降模式
<plugin filename="gz-sim-multirotor-physics-plugin" name="gz::sim::systems::MultirotorPhysics">
<control>
<type>velocity</type>
<takeoff>
<vertical_speed>0.5</vertical_speed>
<takeoff_altitude>1.5</takeoff_altitude>
</takeoff>
<land>
<vertical_speed>0.3</vertical_speed>
<descent_angle>0.1</descent_angle>
</land>
</control>
</plugin>
常见问题
问题 1: 无人机失控
解决方案:
问题 2: 飞行不稳定
解决方案:
- 调整 PID 参数
- 检查 IMU 校准
- 验证重心位置
问题 3: 风力影响过大
解决方案:
相关资源
另见