第三章 Webots官方Tutorial 2
目录
- 第三章 Webots官方Tutorial 2
- 一、Tutorial 2: Modification of the Environment
- 二、一个新仿真
- 三、修改地板Floor
- 四、Solid (刚体)结点
- 五、创建一个球
- 六、几何形状
- 七、DEF-USE机制
- 八、添加墙
- 总结
一、Tutorial 2: Modification of the Environment
目的是创建一个与环境交互的球。学会刚体的建立、物理参数设置和 DEF-USE机制的使用。
二、一个新仿真
2.1 Hands-on #1
教程1另存一个新项目obstacles.wbt
三、修改地板Floor
3.1 Hands-on #2
del 删除旧地板,+添加新地板:
PROTO nodes (Webots Projects) / objects / floors / Floor (Solid)
3.2 Hands-on #3
size设置为1x1
四、Solid (刚体)结点
- Solid: 刚体
- physics:物理特性
- boundingObject: 碰撞边界
- children: 子节点
- Shape: 形状结点
- geometry:几何形状(可以与碰撞边界boundingObject不同)
- Shape: 形状结点
五、创建一个球
5.1 Hands-on #4
添加刚体
:+/Base nodes/Solid
添加子节点children
:选中Solid的子节点children,+/Base nodes/Shape,选中appearance/+/Base nodes/PBRAppearance
其他设置
:
1.children/Shape/geometry/Shape/+/Base nodes/Sphere.
2.children/Shape/ appearance PBRAppearance/metalness 置 0 且 roughness 置 1.
3.Solid/boundingObject/+/Base nodes/Sphere.
4.Solid/physics/+/Base nodes/Physics.
5.设置合适的坐标translation
6.保存.
六、几何形状
6.1 Hands-on #5
我们现在将通过增加用于表示球体的三角形的数量来减小球体的大小并提高其图形质量。
对每个Sphere 结点设置半径radius 为 0.05 且分割数 subdivision 为 2.
七、DEF-USE机制
7.1 Hands-on #6
选择第一个球的Sphere结点(children/Shape/geometry Sphere):
1.DEF设置为 BALL_GEOMETRY.
2.选择boundingObject,删除.
3.再选择boundingObject,+/USE / BALL_GEOMETRY(Sphere).
此时球体几何形状geometry和碰撞边界boundingObject同时共享参数。
7.2 Hands-on #7
使用DEF-USE机制的Shape结点再创建一个球。
关键步骤
:
1.+/Base nodes/Solid
2.Solid/children/+/Base nodes/Shape
3.Solid/children/geometry NULL /+/USE / BALL_GEOMETRY(Sphere)
八、添加墙
8.1 Hands-on #8
与建立ball同理,按照Solid的组成结构图创建nodes。
最终效果图:
总结
本教程为基于刚体solid创建简单的环境。
熟悉了“Solid”、“Physics”、“Shape”、“Sphere”和“Box”节点。
推荐使用允许减少场景树节点冗余的DEF-USE机制。