构建世界


预计完成时间:1 分钟

4.9   地面

你需要一个地面平面,才能在上面放置各种仿真对象、模型和实体。否则,场景就只会是一片空白的灰色空间。地面平面需要通过 <model> ... </model> 标签来定义。

请把 ground_plane 模型添加到 world 标签内部。

复制并粘贴

In [ ]:
<model name='ground_plane'>
    <pose>0 0 0 0 0 0</pose>
    <self_collide>false</self_collide>
    <static>true</static>
    <link name='ground'>
        <pose>0 0 0 0 0 0</pose>
        <enable_wind>false</enable_wind>
        <visual name='visual'>
            <geometry>
                <plane>
                    <normal>0 0 1</normal>
                    <size>100 100</size>
                </plane>
            </geometry>
            <material>
                <ambient>0.8 0.8 0.8 1</ambient>
                <diffuse>0.8 0.8 0.8 1</diffuse>
                <specular>0.8 0.8 0.8 1</specular>
                <emissive>0.0 0.0 0.0 1</emissive>
            </material>
        </visual>
        <collision name='collision'>
            <geometry>
                <plane>
                    <normal>0 0 1</normal>
                    <size>100 100</size>
                </plane>
            </geometry>
            <surface>
                <friction>
                    <ode>
                    </ode>
                </friction>
                <bounce/>
                <contact/>
            </surface>
        </collision>
        <inertial>
            <pose>0 0 0 0 0 0</pose>
            <mass>1</mass>
            <inertia>
                <ixx>1</ixx>
                <ixy>0</ixy>
                <ixz>0</ixz>
                <iyy>1</iyy>
                <iyz>0</iyz>
                <izz>1</izz>
            </inertia>
        </inertial>
    </link>
</model>

这个模型的定义方式和你在 URDF 文件中定义机器人连杆很相似,只不过这里是在 SDF 文件中的 model 标签下进行定义。由于模型内部还定义了 link,因此也会同时包含 visual、collision 和 inertial 等标签。