--- name: robot-sdf-modeling description: 机器人 SDF 建模技能 - SDF 模型结构、链接关节、摩擦阻尼、ROS2 gazebo_ros argument-hint: SDF建模 OR sdf OR robot model OR link OR joint user-invocable: true --- # 机器人 SDF 建模技能 > Gazebo SDF 模型创建 --- ## 何时使用 当需要以下帮助时使用此技能: - SDF 模型结构 - 链接 (link) 定义 - 关节 (joint) 配置 - 碰撞和摩擦 - ROS2 Gazebo 模型 --- ## 核心实现 ### SDF 模型结构 ```xml false 0.001 1.0 1000 0 0 0.1 0 0 0 10.0 0.01 0 0 0.01 0 0.01 0.5 0.5 0.1 1.0 1.0 0.5 0.5 0.1 0.8 0.8 0.8 1 base_link link1 0 0 1 -3.14 3.14 100 10 ``` ### ROS2 Gazebo 模型加载 ```python # launch/gazebo.launch.py from launch import LaunchDescription from launch_ros.actions import Node from launch.actions import ExecuteProcess def generate_launch_description(): return LaunchDescription([ # 启动 Gazebo ExecuteProcess( cmd=['gzserver', '-s', 'libgazebo_ros_factory.so'], output='screen' ), # 加载模型 Node( package='gazebo_ros', executable='spawn_entity', arguments=['-entity', 'robot_name', '-file', '/path/to/model.sdf'], output='screen' ), # ROS2-Gazebo 桥接 Node( package='ros_gz_bridge', executable='parameter_bridge', arguments=['/model/robot_name/pose@tf2_msgs/msg/TF@gz.msgs.Pose'], output='screen' ) ]) ``` ### 摩擦和阻尼配置 ```xml 0.8 0.8 1 0 0 0 0 1e7 1e6 0.1 0.001 0 0.2 ```